diff --git a/lib/checkother.cpp b/lib/checkother.cpp index bf25276f7..89a67dc75 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -152,7 +152,7 @@ void CheckOther::clarifyCondition() tok2 = tok2->link(); else if (Token::Match(tok2, "&&|%oror%|?|)")) break; - else if (Token::Match(tok2, "<|<=|==|!=|>|>= %num% )")) + else if (Token::Match(tok2, "<|<=|==|!=|>|>=")) { clarifyConditionError(tok, tok->strAt(2) == "="); break; diff --git a/test/testother.cpp b/test/testother.cpp index a9de95018..3f02f717f 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -2639,6 +2639,11 @@ private: " if (x & 2 == 2) {}\n" "}"); ASSERT_EQUALS("[test.cpp:2]: (style) Suspicious condition (bitwise operator + comparison), it can be clarified with parentheses\n", errout.str()); + + check("void f() {\n" + " if (a & fred1.x == fred2.y) {}\n" + "}"); + ASSERT_EQUALS("[test.cpp:2]: (style) Suspicious condition (bitwise operator + comparison), it can be clarified with parentheses\n", errout.str()); } void incorrectStringCompare()