Uninitialized variables: Fixed false positives when using typeof()

This commit is contained in:
Daniel Marjamäki 2011-12-27 17:03:48 +01:00
parent 9f1fc14ea3
commit 32ed84f4c5
2 changed files with 8 additions and 2 deletions

View File

@ -1172,7 +1172,7 @@ bool CheckUninitVar::checkScopeForVariable(const Token *tok, const unsigned int
}
// skip sizeof / offsetof
if (Token::Match(tok, "sizeof|offsetof|decltype ("))
if (Token::Match(tok, "sizeof|typeof|offsetof|decltype ("))
tok = tok->next()->link();
// for..

View File

@ -1974,7 +1974,7 @@ private:
"}");
ASSERT_EQUALS("", errout.str());
// sizeof / offsetof
// sizeof / typeof / offsetof / etc
checkUninitVar2("void f() {\n"
" int i;\n"
" sizeof(i+1);\n"
@ -1992,6 +1992,12 @@ private:
" int i = ARRAY_SIZE(abc.a);"
"}");
ASSERT_EQUALS("", errout.str());
checkUninitVar2("void f() {\n"
" int *abc;\n"
" typeof(*abc);\n"
"}");
ASSERT_EQUALS("", errout.str());
}
};