Fixed #2945 (False positive: Uninitialized variable reading from stream)
This commit is contained in:
parent
a6740200cf
commit
4e55fb604c
|
@ -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;
|
||||||
|
|
|
@ -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"
|
||||||
|
|
Loading…
Reference in New Issue