Fixed #1119 (false positve: uninitialized variable y when y is assigned in inner expression 'x = (y = 10)')

This commit is contained in:
Daniel Marjamäki 2009-12-20 13:55:17 +01:00
parent 191a913ff9
commit d9cf70c1c6
2 changed files with 9 additions and 1 deletions

View File

@ -41,7 +41,7 @@ const Token *checkExecutionPaths(const Token *tok, std::list<ExecutionPath *> &c
return 0;
}
if (Token::Match(tok, "= {|("))
if (Token::Match(tok, "= {") || Token::Match(tok, "= ( %type% !!="))
{
tok = tok->next()->link();
if (Token::simpleMatch(tok, ") {"))

View File

@ -981,6 +981,14 @@ private:
"}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: p\n", errout.str());
checkUninitVar("static void foo()\n"
"{\n"
" int x, y;\n"
" x = (y = 10);\n"
" int z = y * 2;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar("static void foo()\n"
"{\n"
" Foo p;\n"