Fixed #2938 (Uninitialized variable not detected when part of expression)
This commit is contained in:
parent
7346d07871
commit
1bb7a1c23c
|
@ -471,6 +471,18 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
if (tok.str() == "return")
|
||||
{
|
||||
for (const Token *tok2 = tok.next(); tok2 && tok2->str() != ";"; tok2 = tok2->next())
|
||||
{
|
||||
if (tok2->isName() && tok2->strAt(1) == "(")
|
||||
tok2 = tok2->next()->link();
|
||||
|
||||
else if (tok2->varId())
|
||||
use(checks, tok2);
|
||||
}
|
||||
}
|
||||
|
||||
if (tok.varId())
|
||||
{
|
||||
// array variable passed as function parameter..
|
||||
|
|
|
@ -168,6 +168,13 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: ret\n", errout.str());
|
||||
|
||||
checkUninitVar("static int foo()\n"
|
||||
"{\n"
|
||||
" int ret;\n"
|
||||
" return ret+5;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: ret\n", errout.str());
|
||||
|
||||
checkUninitVar("void f()\n"
|
||||
"{\n"
|
||||
" int a;\n"
|
||||
|
|
Loading…
Reference in New Issue