Fixed #3222 (false positive: Uninitialized variable with function pointer)
This commit is contained in:
parent
68cb7a2731
commit
71f08d0a66
|
@ -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()) {
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue