Fix false positive with oppositeExpression when using binary op (#1211)
* Fix false positive with oppositeExpression when using binary op * Simplify conditional
This commit is contained in:
parent
d934065d21
commit
f5dbfce8ff
|
@ -367,7 +367,7 @@ bool isOppositeExpression(bool cpp, const Token * const tok1, const Token * cons
|
|||
return true;
|
||||
if (tok1->str() == "-" && !tok1->astOperand2())
|
||||
return isSameExpression(cpp, true, tok1->astOperand1(), tok2, library, pure);
|
||||
if (tok2->str() == "-" && !tok1->astOperand2())
|
||||
if (tok2->str() == "-" && !tok2->astOperand2())
|
||||
return isSameExpression(cpp, true, tok2->astOperand1(), tok1, library, pure);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -3958,6 +3958,9 @@ private:
|
|||
|
||||
check("bool f(int i){ return !((i - 1) & i); }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("bool f(unsigned i){ return (x > 0) && (x & (x-1)) == 0; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void duplicateVarExpression() {
|
||||
|
|
Loading…
Reference in New Issue