diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 96ed875ee..8dcbb62c9 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -160,6 +160,10 @@ void CheckOther::clarifyCalculation() if (!tok->astOperand1()->isArithmeticalOp() && tok->astOperand1()->tokType() != Token::eBitOp) continue; + // bit operation in lhs and pointer in rhs => no clarification is needed + if (tok->astOperand1()->tokType() == Token::eBitOp && tok->astOperand2()->valueType() && tok->astOperand2()->valueType()->pointer > 0) + continue; + // Is code clarified by parentheses already? const Token *tok2 = tok->astOperand1(); for (; tok2; tok2 = tok2->next()) { diff --git a/test/testother.cpp b/test/testother.cpp index b6463cbac..dc278af30 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -4022,6 +4022,9 @@ private: check("void f() { a = *p ? 1 : 2; }"); ASSERT_EQUALS("", errout.str()); + + check("void f(int x) { const char *p = x & 1 ? \"1\" : \"0\"; }"); + ASSERT_EQUALS("", errout.str()); } void clarifyStatement() {