Fixed #1075 (False positive: uninitialized variable 'return bar(s);')

This commit is contained in:
Daniel Marjamäki 2009-12-11 19:58:29 +01:00
parent e52fb36c5c
commit 9646f62ec1
2 changed files with 10 additions and 9 deletions

View File

@ -1364,17 +1364,11 @@ private:
if (tok.str() == "return")
{
for (const Token *tok2 = &tok; tok2; tok2 = tok2->next())
if (!array && Token::Match(tok.next(), "%varid% ;", varId))
{
if (tok2->str() == ";")
return &tok;
if (tok2->varId() == varId)
{
use(foundError, checks);
return &tok;
}
use(foundError, checks);
}
return &tok;
}
if (tok.varId() == varId)

View File

@ -1172,6 +1172,13 @@ private:
"}\n");
ASSERT_EQUALS("", errout.str());
checkUninitVar("int f()\n"
"{\n"
" char s[10];\n"
" return bar(s);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// arrays..
checkUninitVar("void f()\n"
"{\n"