Fixed #913 (false positive: uninitialized variable)
This commit is contained in:
parent
a36c410d45
commit
ec6d66ff45
|
@ -1203,9 +1203,11 @@ static const Token *uninitvar_checkscope(const Token * const tokens, const Token
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Token::Match(tok, "= {"))
|
if (Token::Match(tok, "= {|("))
|
||||||
{
|
{
|
||||||
tok = tok->next()->link();
|
tok = tok->next()->link();
|
||||||
|
if (Token::simpleMatch(tok, ") {"))
|
||||||
|
tok = tok->next()->link();
|
||||||
if (!tok)
|
if (!tok)
|
||||||
{
|
{
|
||||||
init = true;
|
init = true;
|
||||||
|
|
|
@ -1062,6 +1062,22 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkUninitVar("int foo()\n"
|
||||||
|
"{\n"
|
||||||
|
" int i;\n"
|
||||||
|
" if (x)\n"
|
||||||
|
" {\n"
|
||||||
|
" struct abc abc1 = (struct abc) { .a=0, .b=0, .c=0 };\n"
|
||||||
|
" i = 22;\n"
|
||||||
|
" }\n"
|
||||||
|
" else\n"
|
||||||
|
" {\n"
|
||||||
|
" i = 33;\n"
|
||||||
|
" }\n"
|
||||||
|
" return i;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
checkUninitVar("static void foo()\n"
|
checkUninitVar("static void foo()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" Foo *p;\n"
|
" Foo *p;\n"
|
||||||
|
|
Loading…
Reference in New Issue