File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1536,7 +1536,6 @@ void CheckConditionImpl::alwaysTrueFalse()
15361536 }
15371537 if (!tok->hasKnownIntValue ())
15381538 continue ;
1539- const bool isZeroOrOne = (tok->getKnownIntValue () & ~MathLib::bigint (1 )) == 0 ;
15401539 const Token* condition = nullptr ;
15411540 {
15421541 // is this a condition..
@@ -1578,12 +1577,17 @@ void CheckConditionImpl::alwaysTrueFalse()
15781577 continue ;
15791578 bool warnForNumber = false ;
15801579 if (Token::Match (tok, " %num%|%bool%|%char%" )) {
1580+ const bool isZeroOrOne = (tok->getKnownIntValue () >> 1 ) == 0 ;
15811581 warnForNumber = !isZeroOrOne && tok->tokType () == Token::eNumber && tok->astParent () == condition->astParent ();
15821582 if (!warnForNumber)
15831583 continue ;
15841584 }
1585- if (Token::Match (tok, " ! %num%|%bool%|%char%" ))
1586- continue ;
1585+ if (Token::Match (tok, " ! %num%|%bool%|%char%" )) {
1586+ const bool isZeroOrOne = tok->next ()->hasKnownIntValue () && (tok->next ()->getKnownIntValue () >> 1 ) == 0 ;
1587+ warnForNumber = !isZeroOrOne && tok->next ()->tokType () == Token::eNumber && tok->astParent () == condition->astParent ();
1588+ if (!warnForNumber)
1589+ continue ;
1590+ }
15871591 if (Token::Match (tok, " %oror%|&&" )) {
15881592 bool bail = false ;
15891593 for (const Token* op : { tok->astOperand1 (), tok->astOperand2 () }) {
You can’t perform that action at this time.
0 commit comments