diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index a0b07ed61..8358c9da9 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -6868,6 +6868,9 @@ bool Tokenizer::simplifyRedundantParentheses() if (tok->str() != "(") continue; + if (Token::simpleMatch(tok, "( {")) + continue; + if (Token::Match(tok->link(), ") %num%")) { tok = tok->link(); continue; diff --git a/test/testvarid.cpp b/test/testvarid.cpp index 925dfa893..bfc000227 100644 --- a/test/testvarid.cpp +++ b/test/testvarid.cpp @@ -1007,8 +1007,8 @@ private: "}\n"; const char expected1[] = "1: void f ( ) {\n" "2: for ( int i@1 ;\n" - "3: { for ( int i@2 ; i@2 ; ++ i@2 ) { i@2 ++ ; } i@1 ++ ; } , i@1 ;\n" - "4: { for ( int i@3 ; i@3 ; ++ i@3 ) { i@3 ++ ; } i@1 ++ ; } , i@1 ++ ) {\n" + "3: ( { for ( int i@2 ; i@2 ; ++ i@2 ) { i@2 ++ ; } i@1 ++ ; } ) , i@1 ;\n" + "4: ( { for ( int i@3 ; i@3 ; ++ i@3 ) { i@3 ++ ; } i@1 ++ ; } ) , i@1 ++ ) {\n" "5: i@1 ++ ;\n" "6: }\n" "7: }\n";