Fixed #1119 (false positve: uninitialized variable y when y is assigned in inner expression 'x = (y = 10)')
This commit is contained in:
parent
191a913ff9
commit
d9cf70c1c6
|
@ -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, ") {"))
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue