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
|
// ?: => bailout
|
||||||
if (tok->str() == "?")
|
if (tok->str() == "?")
|
||||||
{
|
{
|
||||||
ExecutionPath::bailOut(checks);
|
for (const Token *tok2 = tok; tok2 && tok2->str() != ";"; tok2 = tok2->next())
|
||||||
return;
|
{
|
||||||
|
if (tok2->varId() > 0)
|
||||||
|
ExecutionPath::bailOutVar(checks, tok2->varId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tok->str() == "switch")
|
if (tok->str() == "switch")
|
||||||
|
|
|
@ -1817,6 +1817,13 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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..
|
// while..
|
||||||
checkUninitVar("int f()\n"
|
checkUninitVar("int f()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
Loading…
Reference in New Issue