simplifyCalculations: Fix simplification of '( %num% )' when parentheses must be kept

This commit is contained in:
Daniel Marjamäki 2014-10-10 13:19:25 +02:00
parent 66d4614a87
commit d0d2a0faf8
2 changed files with 4 additions and 1 deletions

View File

@ -1087,7 +1087,7 @@ bool TemplateSimplifier::simplifyCalculations(Token *_tokens)
}
// Remove parentheses around number..
if (Token::Match(tok->tokAt(-2), "%any% ( %num% )") && !tok->tokAt(-2)->isName() && tok->strAt(-2) != ">") {
if (Token::Match(tok->tokAt(-2), "%op%|< ( %num% )") && !tok->tokAt(-2)->isName() && tok->strAt(-2) != ">") {
tok = tok->previous();
tok->deleteThis();
tok->deleteNext();

View File

@ -2059,6 +2059,9 @@ private:
ASSERT_EQUALS("( y % 2 - 2 )", tok("(y % 2 - 2)"));
ASSERT_EQUALS("( 4 )", tok("(1 * 2 / 1 * 2)")); // #3722
// don't remove these spaces..
ASSERT_EQUALS("new ( auto ) ( 4 ) ;", tok("new (auto)(4);"));
}
void comparisons() {