Fixed #2712 (false positive: Division by zero)
This commit is contained in:
parent
3e528777bd
commit
11bd6bcd30
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<a*4/(2*2))"));
|
||||
|
||||
ASSERT_EQUALS("( y / 2 - 2 )", tok("(y / 2 - 2)"));
|
||||
ASSERT_EQUALS("( y % 2 - 2 )", tok("(y % 2 - 2)"));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue