diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2009-06-18 17:48:55 +0200 |
---|---|---|
committer | Roberto Raggi <roberto.raggi@nokia.com> | 2009-06-18 17:49:17 +0200 |
commit | 9c038180d81be6506554907998cab4cb1dd8b3c2 (patch) | |
tree | 82807dd4c03805045ce8c534f84218252db8961c /src/shared/cplusplus | |
parent | c3c98cca785d24c05e552ed5ed113a7b73341965 (diff) | |
download | qt-creator-9c038180d81be6506554907998cab4cb1dd8b3c2.tar.gz |
Improved compatibility with the gcc extensions.
Diffstat (limited to 'src/shared/cplusplus')
-rw-r--r-- | src/shared/cplusplus/AST.cpp | 9 | ||||
-rw-r--r-- | src/shared/cplusplus/AST.h | 3 | ||||
-rw-r--r-- | src/shared/cplusplus/ASTClone.cpp | 3 | ||||
-rw-r--r-- | src/shared/cplusplus/ASTVisit.cpp | 4 | ||||
-rw-r--r-- | src/shared/cplusplus/Parser.cpp | 19 |
5 files changed, 33 insertions, 5 deletions
diff --git a/src/shared/cplusplus/AST.cpp b/src/shared/cplusplus/AST.cpp index 39c3795116..c809f6e1d0 100644 --- a/src/shared/cplusplus/AST.cpp +++ b/src/shared/cplusplus/AST.cpp @@ -570,6 +570,8 @@ unsigned DeclarationListAST::lastToken() const unsigned DeclaratorAST::firstToken() const { + if (attributes) + return attributes->firstToken(); if (ptr_operators) return ptr_operators->firstToken(); else if (core_declarator) @@ -589,7 +591,7 @@ unsigned DeclaratorAST::lastToken() const if (initializer) return initializer->lastToken(); - for (SpecifierAST *it = attributes; it; it = it->next) { + for (SpecifierAST *it = post_attributes; it; it = it->next) { if (! it->next) return it->lastToken(); } @@ -607,6 +609,11 @@ unsigned DeclaratorAST::lastToken() const return it->lastToken(); } + for (SpecifierAST *it = attributes; it; it = it->next) { + if (! it->next) + return it->lastToken(); + } + // ### assert? return 0; } diff --git a/src/shared/cplusplus/AST.h b/src/shared/cplusplus/AST.h index bf4da2014a..f345fd76b0 100644 --- a/src/shared/cplusplus/AST.h +++ b/src/shared/cplusplus/AST.h @@ -371,10 +371,11 @@ public: class CPLUSPLUS_EXPORT DeclaratorAST: public AST { public: + SpecifierAST *attributes; PtrOperatorAST *ptr_operators; CoreDeclaratorAST *core_declarator; PostfixDeclaratorAST *postfix_declarators; - SpecifierAST *attributes; + SpecifierAST *post_attributes; unsigned equals_token; ExpressionAST *initializer; diff --git a/src/shared/cplusplus/ASTClone.cpp b/src/shared/cplusplus/ASTClone.cpp index a48f7b4c8b..c3eb1ab40f 100644 --- a/src/shared/cplusplus/ASTClone.cpp +++ b/src/shared/cplusplus/ASTClone.cpp @@ -97,10 +97,11 @@ DeclaratorAST *DeclaratorAST::clone(MemoryPool *pool) const { DeclaratorAST *ast = new (pool) DeclaratorAST; // copy DeclaratorAST + if (attributes) ast->attributes = attributes->clone(pool); if (ptr_operators) ast->ptr_operators = ptr_operators->clone(pool); if (core_declarator) ast->core_declarator = core_declarator->clone(pool); if (postfix_declarators) ast->postfix_declarators = postfix_declarators->clone(pool); - if (attributes) ast->attributes = attributes->clone(pool); + if (post_attributes) ast->post_attributes = post_attributes->clone(pool); ast->equals_token = equals_token; if (initializer) ast->initializer = initializer->clone(pool); return ast; diff --git a/src/shared/cplusplus/ASTVisit.cpp b/src/shared/cplusplus/ASTVisit.cpp index c904e6d3f3..c85ce39707 100644 --- a/src/shared/cplusplus/ASTVisit.cpp +++ b/src/shared/cplusplus/ASTVisit.cpp @@ -85,12 +85,14 @@ void DeclaratorAST::accept0(ASTVisitor *visitor) { if (visitor->visit(this)) { // visit DeclaratorAST + for (SpecifierAST *it = attributes; it; it = it->next) + accept(it, visitor); for (PtrOperatorAST *it = ptr_operators; it; it = it->next) accept(it, visitor); accept(core_declarator, visitor); for (PostfixDeclaratorAST *it = postfix_declarators; it; it = it->next) accept(it, visitor); - for (SpecifierAST *it = attributes; it; it = it->next) + for (SpecifierAST *it = post_attributes; it; it = it->next) accept(it, visitor); accept(initializer, visitor); } diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index d70d8f40d7..b65d9fc4e4 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -671,6 +671,9 @@ bool Parser::parseAsmDefinition(DeclarationAST *&node) bool Parser::parseAsmOperandList() { + if (LA() != T_STRING_LITERAL) + return true; + if (parseAsmOperand()) { while (LA() == T_COMMA) { consumeToken(); @@ -678,6 +681,7 @@ bool Parser::parseAsmOperandList() } return true; } + return false; } @@ -949,6 +953,14 @@ bool Parser::parseDeclaratorOrAbstractDeclarator(DeclaratorAST *&node) bool Parser::parseCoreDeclarator(DeclaratorAST *&node) { + unsigned start = cursor(); + SpecifierAST *attributes = 0; + SpecifierAST **attribute_ptr = &attributes; + while (LA() == T___ATTRIBUTE__) { + parseAttributeSpecifier(*attribute_ptr); + attribute_ptr = &(*attribute_ptr)->next; + } + PtrOperatorAST *ptr_operators = 0, **ptr_operators_tail = &ptr_operators; while (parsePtrOperator(*ptr_operators_tail)) ptr_operators_tail = &(*ptr_operators_tail)->next; @@ -960,12 +972,16 @@ bool Parser::parseCoreDeclarator(DeclaratorAST *&node) DeclaratorIdAST *declarator_id = new (_pool) DeclaratorIdAST; declarator_id->name = name; DeclaratorAST *ast = new (_pool) DeclaratorAST; + ast->attributes = attributes; ast->ptr_operators = ptr_operators; ast->core_declarator = declarator_id; node = ast; return true; } } else if (LA() == T_LPAREN) { + if (attributes) + _translationUnit->warning(attributes->firstToken(), "unexpected attribtues"); + unsigned lparen_token = consumeToken(); DeclaratorAST *declarator = 0; if (parseDeclarator(declarator) && LA() == T_RPAREN) { @@ -980,6 +996,7 @@ bool Parser::parseCoreDeclarator(DeclaratorAST *&node) return true; } } + rewind(start); return false; } @@ -1060,7 +1077,7 @@ bool Parser::parseDeclarator(DeclaratorAST *&node, bool stopAtCppInitializer) break; } - SpecifierAST **spec_ptr = &node->attributes; + SpecifierAST **spec_ptr = &node->post_attributes; while (LA() == T___ATTRIBUTE__) { parseAttributeSpecifier(*spec_ptr); spec_ptr = &(*spec_ptr)->next; |