Fixed #929 (Uninitialized variable false positive)
This commit is contained in:
parent
51f983629b
commit
e0b1303b50
|
@ -1203,6 +1203,17 @@ static const Token *uninitvar_checkscope(const Token * const tokens, const Token
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (Token::Match(tok, "= {"))
|
||||
{
|
||||
tok = tok->next()->link();
|
||||
if (!tok)
|
||||
{
|
||||
init = true;
|
||||
return 0;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tok->str() == "if")
|
||||
{
|
||||
bool canInit = false;
|
||||
|
|
|
@ -1048,6 +1048,20 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("int foo()\n"
|
||||
"{\n"
|
||||
" int i;\n"
|
||||
" if (x)\n"
|
||||
" i = 22;\n"
|
||||
" else\n"
|
||||
" {\n"
|
||||
" char *y = {0};\n"
|
||||
" i = 33;\n"
|
||||
" }\n"
|
||||
" return i;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("static void foo()\n"
|
||||
"{\n"
|
||||
" Foo *p;\n"
|
||||
|
|
Loading…
Reference in New Issue