Fix FP when using - as a binary operator (#1201)

This commit is contained in:
Paul Fultz II 2018-05-04 00:58:30 -05:00 committed by Daniel Marjamäki
parent f94e9c5447
commit cac68c6b81
2 changed files with 5 additions and 2 deletions

View File

@ -365,9 +365,9 @@ bool isOppositeExpression(bool cpp, const Token * const tok1, const Token * cons
return false;
if (isOppositeCond(true, cpp, tok1, tok2, library, pure))
return true;
if (tok1->str() == "-")
if (tok1->str() == "-" && !tok1->astOperand2())
return isSameExpression(cpp, true, tok1->astOperand1(), tok2, library, pure);
if (tok2->str() == "-")
if (tok2->str() == "-" && !tok1->astOperand2())
return isSameExpression(cpp, true, tok2->astOperand1(), tok1, library, pure);
return false;
}

View File

@ -3955,6 +3955,9 @@ private:
check("void f(int a) { a = a / (-a); }");
ASSERT_EQUALS("", errout.str());
check("bool f(int i){ return !((i - 1) & i); }");
ASSERT_EQUALS("", errout.str());
}
void duplicateVarExpression() {