Do not ask that calculation is clarified when different order would be invalid

This commit is contained in:
Daniel Marjamäki 2020-08-05 13:20:18 +02:00
parent 242fc4e9a2
commit 7a85b8e452
2 changed files with 7 additions and 0 deletions

View File

@ -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()) {

View File

@ -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() {