Uninitialized variables: better handling when uninitialized variables are used in function calls
This commit is contained in:
parent
ab41879246
commit
1ec49430e3
|
@ -3054,9 +3054,13 @@ private:
|
|||
else if (tok2->varId())
|
||||
{
|
||||
if (Token::Match(tok2->tokAt(-2), "[(,] *") || Token::Match(tok2->next(), ". %var%"))
|
||||
use_dead_pointer(checks, tok2);
|
||||
{
|
||||
if (use_dead_pointer(checks, tok2))
|
||||
ExecutionPath::bailOutVar(checks, tok2->varId());
|
||||
}
|
||||
|
||||
// it is possible that the variable is initialized here
|
||||
if (Token::Match(tok2->previous(), "[(,] %var% [,)]"))
|
||||
bailouts.insert(tok2->varId());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1245,6 +1245,13 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: a\n", errout.str());
|
||||
|
||||
checkUninitVar("void f()\n"
|
||||
"{\n"
|
||||
" int a;\n"
|
||||
" bar(4 * a);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: a\n", errout.str());
|
||||
|
||||
checkUninitVar("static void foo()\n"
|
||||
"{\n"
|
||||
" int i;\n"
|
||||
|
|
Loading…
Reference in New Issue