From 033e4a2c1f28dec0ef2e9f2940df70db8a37d3cb Mon Sep 17 00:00:00 2001 From: PKEuS Date: Mon, 2 Apr 2012 11:21:04 +0200 Subject: [PATCH] Fixed #3676. --- lib/checkother.cpp | 3 +++ test/testother.cpp | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index b944a3df7..cdda9f979 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -1164,6 +1164,9 @@ void CheckOther::checkIncorrectLogicOperator() if (conditions[i].after != 0 && !Token::Match(nextTok, conditions[i].after)) continue; + if (tok->previous()->isArithmeticalOp() || nextTok->isArithmeticalOp()) + continue; + std::string cond1str = var1Tok->str() + " " + (varFirst1?op1Tok->str():invertOperatorForOperandSwap(op1Tok->str())) + " " + firstConstant; std::string cond2str = var2Tok->str() + " " + (varFirst2?op3Tok->str():invertOperatorForOperandSwap(op3Tok->str())) + " " + secondConstant; // cond1 op cond2 diff --git a/test/testother.cpp b/test/testother.cpp index 0f7a7af4f..65f235d8f 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -2888,6 +2888,13 @@ private: " if ( &q != &a && &q != &b ) { }\n" "}"); ASSERT_EQUALS("", errout.str()); + + // #3676 + check("void f(int m_x2, int w, int x) {\n" + " if (x + w - 1 > m_x2 || m_x2 < 0 )\n" + " m_x2 = x + w - 1;\n" + "}"); + ASSERT_EQUALS("", errout.str()); } void incorrectLogicOperator3() {