CheckCondition: Fixed FP when condition contains global static variable

This commit is contained in:
Daniel Marjamäki 2017-09-08 15:44:56 +02:00
parent d9adb5432a
commit 899ad8479d
2 changed files with 9 additions and 1 deletions

View File

@ -516,7 +516,7 @@ void CheckCondition::multiCondition2()
vars.insert(cond->varId());
const Variable *var = cond->variable();
if (!nonlocal && var) {
if (!(var->isLocal() || var->isStatic() || var->isArgument()))
if (!(var->isLocal() || var->isArgument()))
nonlocal = true;
else if ((var->isPointer() || var->isReference()) && !Token::Match(cond->astParent(), "%oror%|&&|!"))
// TODO: if var is pointer check what it points at

View File

@ -1835,6 +1835,14 @@ private:
" return 0;\n"
"}");
ASSERT_EQUALS("", errout.str());
check("static int failed = 0;\n"
"void f() {\n"
" if (failed) return;\n"
" checkBuffer();\n"
" if (failed) {}\n"
"}");
ASSERT_EQUALS("", errout.str());
}
// clarify conditions with = and comparison