Fixed #1402 (false positive: uninitialized variable)
This commit is contained in:
parent
2befb74a07
commit
6a03fa604c
|
@ -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();
|
||||
|
|
|
@ -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..
|
||||
|
|
Loading…
Reference in New Issue