Fixed #2712 (false positive: Division by zero)

This commit is contained in:
Daniel Marjamäki 2011-04-10 21:27:09 +02:00
parent 3e528777bd
commit 11bd6bcd30
2 changed files with 5 additions and 2 deletions

View File

@ -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;
}

View File

@ -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)"));
}