Fixed #902 (false positive: uninitialized variable when variable is initialized in macro)
This commit is contained in:
parent
58c54d2ed4
commit
53f7b12b4f
|
@ -1343,6 +1343,17 @@ static const Token *uninitvar_checkscope(const Token * const tokens, const Token
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tok->str() == "return")
|
||||||
|
{
|
||||||
|
for (const Token *tok2 = tok; tok2; tok2 = tok2->next())
|
||||||
|
{
|
||||||
|
if (tok2->str() == ";")
|
||||||
|
return 0;
|
||||||
|
if (tok2->varId() == varid)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (tok->varId() == varid)
|
if (tok->varId() == varid)
|
||||||
{
|
{
|
||||||
if (Token::simpleMatch(tok->previous(), "return"))
|
if (Token::simpleMatch(tok->previous(), "return"))
|
||||||
|
|
|
@ -1010,6 +1010,23 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// goto..
|
||||||
|
checkUninitVar("void foo(int x)\n"
|
||||||
|
"{\n"
|
||||||
|
" long b;\n"
|
||||||
|
" if (g()) {\n"
|
||||||
|
" b =2;\n"
|
||||||
|
" goto found;\n"
|
||||||
|
" }\n"
|
||||||
|
"\n"
|
||||||
|
" return;\n"
|
||||||
|
"\n"
|
||||||
|
"found:\n"
|
||||||
|
" int a = b;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
|
||||||
// if..
|
// if..
|
||||||
checkUninitVar("static void foo()\n"
|
checkUninitVar("static void foo()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
Loading…
Reference in New Issue