Fixed #1835 (false positive: uninitialized variable when using ?)

This commit is contained in:
Daniel Marjamäki 2010-07-08 11:16:49 +02:00
parent ee2f785529
commit 11a72461f3
2 changed files with 19 additions and 0 deletions

View File

@ -183,6 +183,13 @@ static void checkExecutionPaths_(const Token *tok, std::list<ExecutionPath *> &c
return; return;
} }
// ?: => bailout
if (tok->str() == "?")
{
ExecutionPath::bailOut(checks);
return;
}
if (tok->str() == "switch") if (tok->str() == "switch")
{ {
const Token *tok2 = tok->next()->link(); const Token *tok2 = tok->next()->link();

View File

@ -1713,6 +1713,18 @@ private:
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void foo()\n"
"{\n"
" const char *msgid1, *msgid2;\n"
" int ret = bar(&msgid1);\n"
" if (ret > 0) {\n"
" ret = bar(&msgid2);\n"
" }\n"
" ret = ret <= 0 ? -1 :\n"
" strcmp(msgid1, msgid2) == 0;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// while.. // while..
checkUninitVar("int f()\n" checkUninitVar("int f()\n"
"{\n" "{\n"