Fixed #1061 (false positve: uninitialized variable)

This commit is contained in:
Daniel Marjamäki 2009-12-09 20:05:06 +01:00
parent e2473314b5
commit 91114c50d2
2 changed files with 10 additions and 1 deletions

View File

@ -1576,7 +1576,7 @@ void CheckOther::executionPaths()
for (; tok; tok = tok->next())
{
// skip structs
if (Token::Match(tok->previous(), "[;{}] struct %var% {"))
if (Token::Match(tok, "struct %var% {"))
{
tok = tok->tokAt(2)->link();
continue;

View File

@ -1242,6 +1242,15 @@ private:
" };\n"
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar("void f()\n"
"{\n"
" static const struct ab {\n"
" int a,b;\n"
" int get_a() { return a; }"
" } = { 0, 0 };\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}