Fix FP in CheckCondition::multiCondition2

This commit is contained in:
Daniel Marjamäki 2017-09-03 14:46:37 +02:00
parent e5c6379d01
commit ef4a7ba7f2
2 changed files with 10 additions and 1 deletions

View File

@ -491,7 +491,7 @@ void CheckCondition::multiCondition2()
nonlocal |= (var && (var->isPointer() || var->isReference()));
} else if (!nonlocal && cond->isName()) {
// varid is 0. this is possibly a nonlocal variable..
nonlocal = Token::Match(cond->astParent(), "%cop%|(");
nonlocal = Token::Match(cond->astParent(), "%cop%|(|[");
} else {
tokens.push(cond->astOperand1());
tokens.push(cond->astOperand2());

View File

@ -1532,6 +1532,15 @@ private:
"}");
ASSERT_EQUALS("", errout.str());
// undeclared array
check("void f(int x) {\n"
" if (a[x] > 0) {\n"
" a[x] -= dt;\n"
" if (a[x] < 0) {}\n"
" }\n"
"}");
ASSERT_EQUALS("", errout.str());
// #6313 - false positive: opposite conditions in nested if blocks when condition changed
check("void Foo::Bar() {\n"
" if(var){\n"