From 4d085dd3fdae5de3c135d59ff66d1b9c190e8760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 29 Dec 2012 17:13:06 +0100 Subject: [PATCH] Fixed #4316 (False positive: (constStatement) Redundant code) --- lib/tokenize.cpp | 4 +++- test/testtokenize.cpp | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) 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() {