Fixed #2066 (false positive: uninitialized variable when initializing through function pointer)

This commit is contained in:
Daniel Marjamäki 2010-09-27 19:26:09 +02:00
parent 80069f016e
commit 415cbc63c3
2 changed files with 10 additions and 1 deletions

View File

@ -3291,7 +3291,7 @@ private:
} }
} }
else if (Token::Match(&tok, "%var% (") && uvarFunctions.find(tok.str()) == uvarFunctions.end()) if (Token::Match(&tok, "%var% (") && uvarFunctions.find(tok.str()) == uvarFunctions.end())
{ {
if (Token::simpleMatch(&tok, "sizeof (")) if (Token::simpleMatch(&tok, "sizeof ("))
return tok.next()->link(); return tok.next()->link();

View File

@ -2274,6 +2274,15 @@ private:
" return x;\n" " return x;\n"
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
checkUninitVar("void (*init)(char *str);\n"
"\n"
"char x() {\n"
" char cmd[10];\n"
" init(cmd);\n"
" return cmd[0];\n"
"}\n");
ASSERT_EQUALS("", errout.str());
} }