CheckCondition: Fixed FP when condition contains global static variable
This commit is contained in:
parent
d9adb5432a
commit
899ad8479d
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue