Fixed #1075 (False positive: uninitialized variable 'return bar(s);')
This commit is contained in:
parent
e52fb36c5c
commit
9646f62ec1
|
@ -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)
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue