Fix issue 9319: FP knownConditionTrueFalse related to aggregate initialization of struct (#2147)

This commit is contained in:
Paul Fultz II 2019-09-05 12:36:45 -05:00 committed by Daniel Marjamäki
parent 9e140831eb
commit 70cad280ea
2 changed files with 14 additions and 1 deletions

View File

@ -991,7 +991,7 @@ bool isVariableChangedByFunctionCall(const Token *tok, int indirect, const Setti
while (tok && !Token::simpleMatch(tok, ";") && !isScopeBracket(tok)) {
if (tok->str() == ",")
++argnr;
else if (tok->str() == ")")
else if (Token::Match(tok, ")|}"))
tok = tok->link();
else if (Token::Match(tok->previous(), "%name% (|{"))
break;

View File

@ -3216,6 +3216,19 @@ private:
" return 1;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// #9319
check("struct S {\n"
" int a;\n"
" int b;\n"
"};\n"
"void g(S s, bool& x);\n"
"void f() {\n"
" bool x = false;\n"
" g({0, 1}, x);\n"
" if (x) {}\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void alwaysTrueContainer() {