From 8c707876edad505586ec9f738eef506304de5066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 8 Mar 2017 11:41:18 +0100 Subject: [PATCH] Tokenizer: Don't simplify '({..})' wrongly --- lib/tokenize.cpp | 3 +++ test/testvarid.cpp | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) 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";