Fixed #2049 (False negative: 'Uninitialized variable' error won't show)

This commit is contained in:
Daniel Marjamäki 2010-09-15 20:04:50 +02:00
parent 416f093fc3
commit 7e67bb53b8
2 changed files with 12 additions and 2 deletions

View File

@ -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")

View File

@ -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"