diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 627544009..df176c3a0 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -7394,9 +7394,9 @@ bool Tokenizer::simplifyCalculations() // + and - are calculated after * and / else if (Token::Match(tok->next(), "[+-/]")) { - if (tok->previous()->str() == "*") + if (Token::Match(tok->previous(), "[*/%]")) continue; - if (Token::Match(tok->tokAt(3), "[*/]")) + if (Token::Match(tok->tokAt(3), "[*/%]")) continue; } diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 329fa0276..82a18ca89 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -2723,6 +2723,9 @@ private: ASSERT_EQUALS("if ( a == 2 )", tok("if (a==1+1)")); ASSERT_EQUALS("if ( a + 2 != 6 )", tok("if (a+1+1!=1+2+3)")); ASSERT_EQUALS("if ( 4 < a )", tok("if (14-2*5