This commit is contained in:
parent
617b7a39cd
commit
8f432880fa
|
@ -7835,18 +7835,6 @@ bool Tokenizer::simplifyRedundantParentheses()
|
|||
ret = true;
|
||||
}
|
||||
|
||||
if (Token::simpleMatch(tok->previous(), "? (") && Token::simpleMatch(tok->link(), ") :")) {
|
||||
const Token *tok2 = tok->next();
|
||||
while (tok2 && (Token::Match(tok2,"%bool%|%num%|%name%") || tok2->isArithmeticalOp()))
|
||||
tok2 = tok2->next();
|
||||
if (tok2 && tok2->str() == ")") {
|
||||
tok->link()->deleteThis();
|
||||
tok->deleteThis();
|
||||
ret = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
while (Token::Match(tok->previous(), "[{([,] ( !!{") &&
|
||||
Token::Match(tok->link(), ") [;,])]") &&
|
||||
!Token::simpleMatch(tok->tokAt(-2), "operator ,") && // Ticket #5709
|
||||
|
|
|
@ -171,6 +171,7 @@ private:
|
|||
TEST_CASE(removeParentheses25); // daca@home - a=(b,c)
|
||||
TEST_CASE(removeParentheses26); // Ticket #8875 a[0](0)
|
||||
TEST_CASE(removeParentheses27);
|
||||
TEST_CASE(removeParentheses28); // #12164 - don't remove parentheses in '(expr1) ? (expr2) : (expr3);'
|
||||
|
||||
TEST_CASE(tokenize_double);
|
||||
TEST_CASE(tokenize_strings);
|
||||
|
@ -1809,7 +1810,7 @@ private:
|
|||
void removeParentheses15() {
|
||||
ASSERT_EQUALS("a = b ? c : 123 ;", tokenizeAndStringify("a = b ? c : (123);"));
|
||||
ASSERT_EQUALS("a = b ? c : ( 123 + 456 ) ;", tokenizeAndStringify("a = b ? c : ((123)+(456));"));
|
||||
ASSERT_EQUALS("a = b ? 123 : c ;", tokenizeAndStringify("a = b ? (123) : c;"));
|
||||
ASSERT_EQUALS("a = b ? ( 123 ) : c ;", tokenizeAndStringify("a = b ? (123) : c;"));
|
||||
|
||||
// #4316
|
||||
ASSERT_EQUALS("a = b ? c : ( d = 1 , 0 ) ;", tokenizeAndStringify("a = b ? c : (d=1,0);"));
|
||||
|
@ -1918,6 +1919,12 @@ private:
|
|||
ASSERT_EQUALS(exp, tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void removeParentheses28() { // Ticket #12164
|
||||
static char code[] = "temp1 = (value > 100U) ? (value+100U) : (value-50U);";
|
||||
static const char exp[] = "temp1 = ( value > 100U ) ? ( value + 100U ) : ( value - 50U ) ;";
|
||||
ASSERT_EQUALS(exp, tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void tokenize_double() {
|
||||
const char code[] = "void f() {\n"
|
||||
" double a = 4.2;\n"
|
||||
|
|
Loading…
Reference in New Issue