Fix simplifyRedundantParanthesis() to work after '}'

This commit is contained in:
Reijo Tomperi 2009-10-05 14:30:05 +03:00
parent 5a0a5422c3
commit 036f3894f1
2 changed files with 2 additions and 1 deletions

View File

@ -3408,7 +3408,7 @@ bool Tokenizer::simplifyRedundantParanthesis()
ret = true;
}
if (Token::Match(tok->previous(), "[(!*;] ( %var% )") && tok->next()->varId() != 0)
if (Token::Match(tok->previous(), "[(!*;}] ( %var% )") && tok->next()->varId() != 0)
{
// We have "( var )", remove the paranthesis
tok = tok->previous();

View File

@ -421,6 +421,7 @@ private:
ASSERT_EQUALS("void f ( ) { int p [ 10 ] ; p [ 0 ] = 1 ; }", tok("void f(){int p[10]; (p)[0] = 1;}"));
ASSERT_EQUALS("void f ( ) { int p ; if ( ! p ) { } }", tok("void f(){int p; if ((p) == 0) {}}"));
ASSERT_EQUALS("void f ( ) { int * p ; * p = 1 ; }", tok("void f(){int *p; *(p) = 1;}"));
ASSERT_EQUALS("void f ( ) { int p ; if ( p ) { } p = 1 ; }", tok("void f(){int p; if ( p ) { } (p) = 1;}"));
// keep parantheses..
ASSERT_EQUALS("= a ;", tok("= (char)a;"));