Fixed #2367 (false positive: (error) Uninitialized variable: s)

This commit is contained in:
Daniel Marjamäki 2010-12-27 21:05:33 +01:00
parent 92acca3d0c
commit 448c03c6e6
2 changed files with 11 additions and 1 deletions

View File

@ -578,7 +578,7 @@ private:
if (Token::Match(&tok, "%var% (") && uvarFunctions.find(tok.str()) == uvarFunctions.end())
{
if (Token::simpleMatch(&tok, "sizeof ("))
if (Token::Match(&tok, "sizeof|typeof ("))
return tok.next()->link();
// deallocate pointer

View File

@ -46,6 +46,7 @@ private:
TEST_CASE(uninitvar_references); // references
TEST_CASE(uninitvar_strncpy); // strncpy doesn't always 0-terminate
TEST_CASE(uninitvar_func); // analyse functions
TEST_CASE(uninitvar_typeof); // typeof
}
void checkUninitVar(const char code[])
@ -1391,6 +1392,15 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
}
void uninitvar_typeof()
{
checkUninitVar("void f() {\n"
" struct Fred *fred;\n"
" typeof(fred->x);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestUninitVar)