Fixed #2367 (false positive: (error) Uninitialized variable: s)
This commit is contained in:
parent
92acca3d0c
commit
448c03c6e6
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue