Fixed #1402 (false positive: uninitialized variable)

This commit is contained in:
Daniel Marjamäki 2010-02-20 09:35:57 +01:00
parent 2befb74a07
commit 6a03fa604c
2 changed files with 14 additions and 1 deletions

View File

@ -140,7 +140,7 @@ static const Token *checkExecutionPaths_(const Token *tok, std::list<ExecutionPa
}
// don't parse into "struct type { .."
if (Token::Match(tok, "struct|class %type% {|:"))
if (Token::Match(tok, "struct|union|class %type% {|:"))
{
while (tok && tok->str() != "{" && tok->str() != ";")
tok = tok->next();

View File

@ -1683,6 +1683,19 @@ private:
" } = { 0, 0 };\n"
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar("void f()\n"
"{\n"
" int i;\n"
" {\n"
" union ab {\n"
" int a,b;\n"
" }\n"
" i = 0;\n"
" }\n"
" return i;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
// enum..