diff --git a/src/tokenize.cpp b/src/tokenize.cpp index dcac6d11d..cab2c954b 100644 --- a/src/tokenize.cpp +++ b/src/tokenize.cpp @@ -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(); diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index f22caaaf8..f260d28f8 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -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;"));