Fixed #1533 (False positive: Uninitialized variable)

This commit is contained in:
Daniel Marjamäki 2010-03-28 10:42:37 +02:00
parent 86fabd03b3
commit c7867af3c5
2 changed files with 17 additions and 0 deletions

View File

@ -149,6 +149,13 @@ static const Token *checkExecutionPaths_(const Token *tok, std::list<ExecutionPa
if (Token::Match(tok, "= {"))
{
// GCC struct initialization.. bail out
if (Token::Match(tok->tokAt(2), ". %var% ="))
{
ExecutionPath::bailOut(checks);
return 0;
}
tok = tok->next()->link();
if (!tok)
{

View File

@ -1280,6 +1280,16 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
// #1533
checkUninitVar("char a()\n"
"{\n"
" char key;\n"
" struct A msg = { .buf = {&key} };\n"
" init(&msg);\n"
" return key;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar("void foo()\n"
"{\n"
" char *buf = malloc(100);\n"