Fixed #4718 (False positive: unititialized variable (value flow))
This commit is contained in:
parent
c0ad2a209c
commit
894a2435ae
|
@ -1235,6 +1235,9 @@ bool CheckUninitVar::checkScopeForVariable(const Scope* scope, const Token *tok,
|
|||
return true;
|
||||
}
|
||||
|
||||
if (alwaysTrue && noreturnIf)
|
||||
return true;
|
||||
|
||||
std::map<unsigned int, int> varValueIf;
|
||||
if (!initif && !noreturnIf) {
|
||||
for (const Token *tok2 = tok; tok2 && tok2 != tok->link(); tok2 = tok2->next()) {
|
||||
|
|
|
@ -2563,6 +2563,14 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar2("int f(int x) {\n"
|
||||
" int y;\n"
|
||||
" if (x) y = do_something();\n"
|
||||
" if (!x) return 0;\n"
|
||||
" return y;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// Unknown => bail out..
|
||||
checkUninitVar2("void f(int x) {\n"
|
||||
" int i;\n"
|
||||
|
|
Loading…
Reference in New Issue