Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/astutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 3 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3955,6 +3955,9 @@ class TestOther : public TestFixture {

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() {
Expand Down