File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -317,8 +317,15 @@ void CheckCondition::checkBadBitmaskCheck()
317317
318318 const bool isZero1 = (tok->astOperand1 ()->hasKnownIntValue () && tok->astOperand1 ()->values ().front ().intvalue == 0 );
319319 const bool isZero2 = (tok->astOperand2 ()->hasKnownIntValue () && tok->astOperand2 ()->values ().front ().intvalue == 0 );
320+ if (!isZero1 && !isZero2)
321+ continue ;
320322
321- if ((isZero1 || isZero2) && !tok->isExpandedMacro () && !(isZero1 && tok->astOperand1 ()->isExpandedMacro ()) && !(isZero2 && tok->astOperand2 ()->isExpandedMacro ()))
323+ auto isOperandExpanded = [](const Token *op) {
324+ return op->isExpandedMacro () || op->isEnumerator ();
325+ };
326+ if (!tok->isExpandedMacro () &&
327+ !(isZero1 && isOperandExpanded (tok->astOperand1 ())) &&
328+ !(isZero2 && isOperandExpanded (tok->astOperand2 ())))
322329 badBitmaskCheckError (tok, /* isNoOp*/ true );
323330 }
324331 }
Original file line number Diff line number Diff line change @@ -912,6 +912,11 @@ class TestCondition : public TestFixture {
912912 " #endif\n "
913913 " 0;" );
914914 ASSERT_EQUALS (" " , errout.str ());
915+
916+ check (" enum precedence { PC0, UNARY };\n "
917+ " int x = PC0 | UNARY;\n "
918+ " int y = UNARY | PC0;\n " );
919+ ASSERT_EQUALS (" " , errout.str ());
915920 }
916921
917922
You can’t perform that action at this time.
0 commit comments