Fixed #1177 (False positive: pointer is not dereferenced 'sizeof(*p)')

This commit is contained in:
Daniel Marjamäki 2009-12-30 11:32:46 +01:00
parent 2de2ecafe4
commit 06ee643c6a
2 changed files with 10 additions and 0 deletions

View File

@ -1557,6 +1557,9 @@ private:
if (Token::Match(&tok, "%var% ("))
{
if (Token::simpleMatch(&tok, "sizeof ("))
return tok.next()->link();
// deallocate pointer
if (Token::Match(&tok, "free|kfree|fclose ( %var% )"))
{

View File

@ -1274,6 +1274,13 @@ private:
"}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: f\n", errout.str());
checkUninitVar("void f()\n"
"{\n"
" Abc *p;\n"
" int sz = sizeof(*p);\n"
"}");
ASSERT_EQUALS("", errout.str());
// arrays..
checkUninitVar("void f()\n"
"{\n"