Fix internalASTError with decltype() (#5047)
This commit is contained in:
parent
e1d5d9988d
commit
f5b1537ed1
|
@ -7549,7 +7549,7 @@ bool Tokenizer::simplifyRedundantParentheses()
|
|||
ret = true;
|
||||
}
|
||||
|
||||
if (Token::Match(tok->previous(), "[(,;{}] ( %name% (") &&
|
||||
if (Token::Match(tok->previous(), "[(,;{}] ( %name% (") && !tok->next()->isKeyword() &&
|
||||
tok->link()->previous() == tok->linkAt(2)) {
|
||||
// We have "( func ( *something* ))", remove the outer
|
||||
// parentheses
|
||||
|
|
|
@ -176,6 +176,7 @@ private:
|
|||
TEST_CASE(removeParentheses24); // Ticket #7040
|
||||
TEST_CASE(removeParentheses25); // daca@home - a=(b,c)
|
||||
TEST_CASE(removeParentheses26); // Ticket #8875 a[0](0)
|
||||
TEST_CASE(removeParentheses27);
|
||||
|
||||
TEST_CASE(tokenize_double);
|
||||
TEST_CASE(tokenize_strings);
|
||||
|
@ -1909,6 +1910,20 @@ private:
|
|||
ASSERT_EQUALS(exp, tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void removeParentheses27() {
|
||||
static char code[] = "struct S { int i; };\n"
|
||||
"void g(int, int);\n"
|
||||
"void f(S s, int j) {\n"
|
||||
" g(j, (decltype(s.i))j * s.i);\n"
|
||||
"}\n";
|
||||
static const char exp[] = "struct S { int i ; } ;\n"
|
||||
"void g ( int , int ) ;\n"
|
||||
"void f ( S s , int j ) {\n"
|
||||
"g ( j , ( decltype ( s . i ) ) j * s . i ) ;\n"
|
||||
"}";
|
||||
ASSERT_EQUALS(exp, tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void tokenize_double() {
|
||||
const char code[] = "void f() {\n"
|
||||
" double a = 4.2;\n"
|
||||
|
|
Loading…
Reference in New Issue