File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -368,13 +368,13 @@ void CheckCondition::comparison()
368368 const Token *expr2 = tok->astOperand2 ();
369369 if (!expr1 || !expr2)
370370 continue ;
371- if (expr1->isNumber ())
371+ if (expr1->hasKnownIntValue ())
372372 std::swap (expr1,expr2);
373- if (!expr2->isNumber ())
373+ if (!expr2->hasKnownIntValue ())
374374 continue ;
375375 if (!compareTokenFlags (expr1, expr2, /* macro*/ true ))
376376 continue ;
377- const MathLib::bigint num2 = MathLib::toBigNumber ( expr2->str () );
377+ const MathLib::bigint num2 = expr2->getKnownIntValue ( );
378378 if (num2 < 0 )
379379 continue ;
380380 if (!Token::Match (expr1," [&|]" ))
Original file line number Diff line number Diff line change @@ -503,6 +503,15 @@ class TestCondition : public TestFixture {
503503 " if (MACRO_ALL == 0) {}\n "
504504 " }\n " );
505505 ASSERT_EQUALS (" " , errout_str ());
506+
507+ checkP (" void f(int i, int j) {\n " // #13360
508+ " int X = 0x10;\n "
509+ " if ((i & 0xff00) == X) {}\n "
510+ " if (X == (j & 0xff00)) {}\n "
511+ " }\n " );
512+ ASSERT_EQUALS (" [test.cpp:3]: (style) Expression '(X & 0xff00) == 0x10' is always false.\n "
513+ " [test.cpp:4]: (style) Expression '(X & 0xff00) == 0x10' is always false.\n " ,
514+ errout_str ());
506515 }
507516
508517#define checkPureFunction (code ) checkPureFunction_(code, __FILE__, __LINE__)
You can’t perform that action at this time.
0 commit comments