Fixed #4316 (False positive: (constStatement) Redundant code)

This commit is contained in:
Daniel Marjamäki 2012-12-29 17:13:06 +01:00
parent e7aa1ec396
commit 4d085dd3fd
2 changed files with 6 additions and 1 deletions

View File

@ -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();

View File

@ -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() {