Fixed #936 (false positive: uninitialized variable '.. else return; .. ')
This commit is contained in:
parent
91433587d2
commit
ebf907cbc0
|
@ -1366,7 +1366,10 @@ static const Token *uninitvar_checkscope(const Token * const tokens, const Token
|
|||
for (const Token *tok2 = tok; tok2; tok2 = tok2->next())
|
||||
{
|
||||
if (tok2->str() == ";")
|
||||
{
|
||||
init = true;
|
||||
return 0;
|
||||
}
|
||||
if (tok2->varId() == varid)
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1096,6 +1096,17 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("int foo(int x)\n"
|
||||
"{\n"
|
||||
" int i;\n"
|
||||
" if (one())\n"
|
||||
" i = 1;\n"
|
||||
" else\n"
|
||||
" return 3;\n"
|
||||
" return i;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// switch..
|
||||
checkUninitVar("char * f()\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue