Fixed #2945 (False positive: Uninitialized variable reading from stream)

This commit is contained in:
Daniel Marjamäki 2011-07-26 21:30:58 +02:00
parent a6740200cf
commit 4e55fb604c
2 changed files with 7 additions and 1 deletions

View File

@ -477,7 +477,7 @@ private:
bool assignment = false; bool assignment = false;
for (const Token *tok2 = tok.next(); tok2 && tok2->str() != ";"; tok2 = tok2->next()) for (const Token *tok2 = tok.next(); tok2 && tok2->str() != ";"; tok2 = tok2->next())
{ {
if (tok2->str() == "=") if (tok2->str() == "=" || tok2->str() == ">>")
{ {
assignment = true; assignment = true;
break; break;

View File

@ -181,6 +181,12 @@ private:
"}\n"); "}\n");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("static int foo() {\n"
" int ret;\n"
" return cin >> ret;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar("void f()\n" checkUninitVar("void f()\n"
"{\n" "{\n"
" int a;\n" " int a;\n"