simplifyCalculations: Fix simplification of '( %num% )' when parentheses must be kept
This commit is contained in:
parent
66d4614a87
commit
d0d2a0faf8
|
@ -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();
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue