Fixed #2049 (False negative: 'Uninitialized variable' error won't show)
This commit is contained in:
parent
416f093fc3
commit
7e67bb53b8
|
@ -186,8 +186,11 @@ static void checkExecutionPaths_(const Token *tok, std::list<ExecutionPath *> &c
|
|||
// ?: => bailout
|
||||
if (tok->str() == "?")
|
||||
{
|
||||
ExecutionPath::bailOut(checks);
|
||||
return;
|
||||
for (const Token *tok2 = tok; tok2 && tok2->str() != ";"; tok2 = tok2->next())
|
||||
{
|
||||
if (tok2->varId() > 0)
|
||||
ExecutionPath::bailOutVar(checks, tok2->varId());
|
||||
}
|
||||
}
|
||||
|
||||
if (tok->str() == "switch")
|
||||
|
|
|
@ -1817,6 +1817,13 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("void foo(int a, int b)\n"
|
||||
"{\n"
|
||||
" int x; x = (a<b) ? 1 : 0;\n"
|
||||
" int y = y;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: y\n", errout.str());
|
||||
|
||||
// while..
|
||||
checkUninitVar("int f()\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue