Fixed #9314 (false positive: (error) Uninitialized variable: ret)
This commit is contained in:
parent
cf5dd48994
commit
210232d35c
|
@ -244,6 +244,14 @@ static void conditionAlwaysTrueOrFalse(const Token *tok, const std::map<int, Var
|
|||
if (!tok)
|
||||
return;
|
||||
|
||||
if (tok->hasKnownIntValue()) {
|
||||
if (tok->getKnownIntValue() == 0)
|
||||
*alwaysFalse = true;
|
||||
else
|
||||
*alwaysTrue = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (tok->isName() || tok->str() == ".") {
|
||||
while (tok && tok->str() == ".")
|
||||
tok = tok->astOperand2();
|
||||
|
|
|
@ -790,6 +790,14 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:6]: (error) Uninitialized variable: a\n", errout.str());
|
||||
|
||||
checkUninitVar("int foo() {\n"
|
||||
" int i;\n"
|
||||
" if (1)\n"
|
||||
" i = 11;\n"
|
||||
" return i;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("int foo()\n"
|
||||
"{\n"
|
||||
" int i;\n"
|
||||
|
|
Loading…
Reference in New Issue