Tokenizer: Don't simplify '({..})' wrongly

This commit is contained in:
Daniel Marjamäki 2017-03-08 11:41:18 +01:00
parent 5d7fa590af
commit 8c707876ed
2 changed files with 5 additions and 2 deletions

View File

@ -6868,6 +6868,9 @@ bool Tokenizer::simplifyRedundantParentheses()
if (tok->str() != "(") if (tok->str() != "(")
continue; continue;
if (Token::simpleMatch(tok, "( {"))
continue;
if (Token::Match(tok->link(), ") %num%")) { if (Token::Match(tok->link(), ") %num%")) {
tok = tok->link(); tok = tok->link();
continue; continue;

View File

@ -1007,8 +1007,8 @@ private:
"}\n"; "}\n";
const char expected1[] = "1: void f ( ) {\n" const char expected1[] = "1: void f ( ) {\n"
"2: for ( int i@1 ;\n" "2: for ( int i@1 ;\n"
"3: { for ( int i@2 ; i@2 ; ++ i@2 ) { i@2 ++ ; } 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" "4: ( { for ( int i@3 ; i@3 ; ++ i@3 ) { i@3 ++ ; } i@1 ++ ; } ) , i@1 ++ ) {\n"
"5: i@1 ++ ;\n" "5: i@1 ++ ;\n"
"6: }\n" "6: }\n"
"7: }\n"; "7: }\n";