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();
|
||||
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;
|
||||
if (Token::simpleMatch(tok, "{")) {
|
||||
values = getInitListSize(tok, tok->valueType(), settings, true);
|
||||
|
|
|
@ -6615,6 +6615,9 @@ private:
|
|||
|
||||
code = "std::vector<int> f() { return {}; }";
|
||||
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()
|
||||
|
|
Loading…
Reference in New Issue