Fix regression: wrong array size (#5194)
This commit is contained in:
parent
9dc38f80c0
commit
7507d400de
|
@ -8801,7 +8801,7 @@ static void valueFlowContainerSize(TokenList* tokenlist,
|
||||||
value.setKnown();
|
value.setKnown();
|
||||||
valueFlowForward(containerTok->next(), containerTok, value, tokenlist, settings);
|
valueFlowForward(containerTok->next(), containerTok, value, tokenlist, settings);
|
||||||
}
|
}
|
||||||
} else if (Token::Match(tok->previous(), ">|return (|{") && astIsContainer(tok)) {
|
} else if (Token::Match(tok->previous(), ">|return (|{") && astIsContainer(tok) && getLibraryContainer(tok)->size_templateArgNo < 0) {
|
||||||
std::vector<ValueFlow::Value> values;
|
std::vector<ValueFlow::Value> values;
|
||||||
if (Token::simpleMatch(tok, "{")) {
|
if (Token::simpleMatch(tok, "{")) {
|
||||||
values = getInitListSize(tok, tok->valueType(), settings, true);
|
values = getInitListSize(tok, tok->valueType(), settings, true);
|
||||||
|
|
|
@ -6615,6 +6615,9 @@ private:
|
||||||
|
|
||||||
code = "std::vector<int> f() { return {}; }";
|
code = "std::vector<int> f() { return {}; }";
|
||||||
ASSERT_EQUALS("", isKnownContainerSizeValue(tokenValues(code, "{ } ;"), 0));
|
ASSERT_EQUALS("", isKnownContainerSizeValue(tokenValues(code, "{ } ;"), 0));
|
||||||
|
|
||||||
|
code = "int f() { auto a = std::array<int, 2>{}; return a[1]; }";
|
||||||
|
ASSERT_EQUALS("values.size():0", isKnownContainerSizeValue(tokenValues(code, "a ["), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void valueFlowContainerElement()
|
void valueFlowContainerElement()
|
||||||
|
|
Loading…
Reference in New Issue