diff --git a/src/shared/cplusplus/AST.h b/src/shared/cplusplus/AST.h index b56fed68c710af24c7ff72a45cc8cb7ffa0be085..e1b901dca5810030678808f2f69b18a2ec2a9ceb 100644 --- a/src/shared/cplusplus/AST.h +++ b/src/shared/cplusplus/AST.h @@ -296,7 +296,7 @@ public: unsigned attribute_token; unsigned first_lparen_token; unsigned second_lparen_token; - AttributeAST *attributes; + AttributeListAST *attributes; unsigned first_rparen_token; unsigned second_rparen_token; @@ -318,7 +318,6 @@ public: unsigned tag_token; ExpressionListAST *expression_list; unsigned rparen_token; - AttributeAST *next; public: virtual AttributeAST *asAttribute() { return this; } diff --git a/src/shared/cplusplus/ASTVisit.cpp b/src/shared/cplusplus/ASTVisit.cpp index e8fbdce3284461a145422023c903b6d6ec0ca7f5..2a9160094fea2f9be43ef34cec39c5e0b3dce14e 100644 --- a/src/shared/cplusplus/ASTVisit.cpp +++ b/src/shared/cplusplus/ASTVisit.cpp @@ -42,8 +42,7 @@ void SimpleSpecifierAST::accept0(ASTVisitor *visitor) void AttributeSpecifierAST::accept0(ASTVisitor *visitor) { if (visitor->visit(this)) { - for (AttributeAST *it = attributes; it; it = it->next) - accept(it, visitor); + accept(attributes, visitor); } visitor->endVisit(this); } diff --git a/src/shared/cplusplus/ASTfwd.h b/src/shared/cplusplus/ASTfwd.h index 922dd6b2760e779b77897f64e11ae96ea915b62d..07f51b40ae647d6d5c9e15d74514b85c85bd47e0 100644 --- a/src/shared/cplusplus/ASTfwd.h +++ b/src/shared/cplusplus/ASTfwd.h @@ -201,6 +201,7 @@ typedef List<MemInitializerAST *> MemInitializerListAST; typedef List<NewArrayDeclaratorAST *> NewArrayDeclaratorListAST; typedef List<PostfixAST *> PostfixListAST; typedef List<PostfixDeclaratorAST *> PostfixDeclaratorListAST; +typedef List<AttributeAST *> AttributeListAST; typedef List<NameAST *> ObjCIdentifierListAST; typedef List<ObjCMessageArgumentAST *> ObjCMessageArgumentListAST; diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index c74b3ca96026a28e80abfd401398ce660221af76..d9b3635e4b73a1a57023b6ec5f16001998797bc4 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -2689,32 +2689,24 @@ bool Parser::parseAttributeSpecifier(SpecifierAST *&node) return true; } -bool Parser::parseAttributeList(AttributeAST *&node) +bool Parser::parseAttributeList(AttributeListAST *&node) // ### create the AST { DEBUG_THIS_RULE(); - AttributeAST **attribute_ptr = &node; - while (LA() == T_IDENTIFIER || LA() == T_CONST) { - AttributeAST *ast = new (_pool) AttributeAST; - ast->identifier_token = consumeToken(); - if (LA() == T_LPAREN) { - ast->lparen_token = consumeToken(); - if (LA() == T_IDENTIFIER && (LA(2) == T_COMMA || LA(2) == T_RPAREN)) { - ast->tag_token = consumeToken(); - if (LA() == T_COMMA) - parseExpressionList(ast->expression_list); - } else { - parseExpressionList(ast->expression_list); - } - match(T_RPAREN, &ast->rparen_token); + + while (LA() == T_CONST || LA() == T_IDENTIFIER) { + if (LA() == T_CONST) + consumeToken(); + else if (LA() == T_IDENTIFIER) { + ExpressionAST *expression = 0; + parseExpression(expression); } - *attribute_ptr = ast; if (LA() != T_COMMA) break; - consumeToken(); - attribute_ptr = &(*attribute_ptr)->next; + consumeToken(); // skip T_COMMA } + return true; } diff --git a/src/shared/cplusplus/Parser.h b/src/shared/cplusplus/Parser.h index 57a7eaf760a130e12d38a4b75a4424eca5330a14..39f42ba0bbcbbe71565e047f5a891e885881a395 100644 --- a/src/shared/cplusplus/Parser.h +++ b/src/shared/cplusplus/Parser.h @@ -190,7 +190,7 @@ public: bool parseBuiltinTypeSpecifier(SpecifierAST *&node); bool parseAttributeSpecifier(SpecifierAST *&node); - bool parseAttributeList(AttributeAST *&node); + bool parseAttributeList(AttributeListAST *&node); bool parseSimpleTypeSpecifier(SpecifierAST *&node) { return parseDeclSpecifierSeq(node, true, true); }