Fixed #3222 (false positive: Uninitialized variable with function pointer)

This commit is contained in:
Daniel Marjamaki 2011-10-30 17:22:30 +01:00
parent 68cb7a2731
commit 71f08d0a66
2 changed files with 10 additions and 1 deletions

View File

@ -703,7 +703,8 @@ private:
}
// function call via function pointer
if (Token::Match(&tok, "( * %var% ) (")) {
if (Token::Match(&tok, "( * %var% ) (") ||
(Token::Match(&tok, "( *| %var% .|::") && Token::Match(tok.link()->tokAt(-2), ".|:: %var% ) ("))) {
// is the variable passed as a parameter to some function?
unsigned int parlevel = 0;
for (const Token *tok2 = tok.link()->next(); tok2; tok2 = tok2->next()) {

View File

@ -1502,6 +1502,14 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
// #3222 - calling function through function pointer
checkUninitVar("char f() {\n"
" char buffer[100];\n"
" (foo.init)(buffer);\n"
" return buffer[0];\n"
"}");
ASSERT_EQUALS("", errout.str());
// using uninitialized function pointer..
checkUninitVar("void foo()\n"
"{\n"