Fixed #1183 (False positive: uninitialized variable p 'd = bar(sizeof(*p));')

This commit is contained in:
Daniel Marjamäki 2009-12-31 09:10:20 +01:00
parent 0ee3d7e46a
commit 0159287437
2 changed files with 14 additions and 0 deletions

View File

@ -1628,6 +1628,13 @@ private:
--parlevel; --parlevel;
} }
else if (Token::simpleMatch(tok2, "sizeof ("))
{
tok2 = tok2->link();
if (!tok2)
break;
}
else if (tok2->varId()) else if (tok2->varId())
{ {
if (Token::Match(tok2->tokAt(-2), "[(,] *")) if (Token::Match(tok2->tokAt(-2), "[(,] *"))

View File

@ -1302,6 +1302,13 @@ private:
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void foo()\n"
"{\n"
" Foo *p;\n"
" x = bar(sizeof(*p));\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// arrays.. // arrays..
checkUninitVar("void f()\n" checkUninitVar("void f()\n"
"{\n" "{\n"