diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 0436d8517..cc8ae10e3 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -6599,7 +6599,9 @@ bool Tokenizer::simplifyRedundantParenthesis() } } - while (Token::Match(tok->previous(), "[{([,:] ( !!{") && Token::Match(tok->link(), ") [;,])]")) { + while (Token::Match(tok->previous(), "[{([,:] ( !!{") && + Token::Match(tok->link(), ") [;,])]") && + !Token::findmatch(tok, ",",tok->link())) { // We have "( ... )", remove the parenthesis tok->link()->deleteThis(); tok->deleteThis(); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index e2eec9b3c..a2e75d4b9 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -4942,6 +4942,9 @@ private: ASSERT_EQUALS("a = b ? c : 123 ;", tokenizeAndStringify("a = b ? c : (123);", false)); ASSERT_EQUALS("a = b ? c : 579 ;", tokenizeAndStringify("a = b ? c : ((123)+(456));", false)); ASSERT_EQUALS("a = b ? 123 : c ;", tokenizeAndStringify("a = b ? (123) : c;", false)); + + // #4316 + ASSERT_EQUALS("a = b ? c : ( d = 1 , 0 ) ;", tokenizeAndStringify("a = b ? c : (d=1,0);", false)); } void tokenize_double() {