diff options
author | Roberto Raggi <roberto.raggi@nokia.com> | 2009-11-10 14:16:39 +0100 |
---|---|---|
committer | Roberto Raggi <roberto.raggi@nokia.com> | 2009-11-10 16:20:11 +0100 |
commit | aff9a743668575898d5eafe30e8e240e4a53342a (patch) | |
tree | 0fe33338c6c51ae25d85055021a64f75996724a8 /src/shared/cplusplus | |
parent | 73a4f2977aaf68a46bd46062e41144349feda878 (diff) | |
download | qt-creator-aff9a743668575898d5eafe30e8e240e4a53342a.tar.gz |
Cleanup NewArrayDeclaratorAST
Diffstat (limited to 'src/shared/cplusplus')
-rw-r--r-- | src/shared/cplusplus/AST.cpp | 6 | ||||
-rw-r--r-- | src/shared/cplusplus/AST.h | 3 | ||||
-rw-r--r-- | src/shared/cplusplus/ASTVisit.cpp | 3 | ||||
-rw-r--r-- | src/shared/cplusplus/ASTfwd.h | 1 | ||||
-rw-r--r-- | src/shared/cplusplus/CheckExpression.cpp | 6 | ||||
-rw-r--r-- | src/shared/cplusplus/Parser.cpp | 8 | ||||
-rw-r--r-- | src/shared/cplusplus/Parser.h | 2 |
7 files changed, 15 insertions, 14 deletions
diff --git a/src/shared/cplusplus/AST.cpp b/src/shared/cplusplus/AST.cpp index a20f74372b..987c6a1664 100644 --- a/src/shared/cplusplus/AST.cpp +++ b/src/shared/cplusplus/AST.cpp @@ -1175,10 +1175,8 @@ unsigned NewTypeIdAST::firstToken() const unsigned NewTypeIdAST::lastToken() const { - for (NewArrayDeclaratorAST *it = new_array_declarators; it; it = it->next) { - if (! it->next) - return it->lastToken(); - } + if (new_array_declarators) + return new_array_declarators->lastToken(); for (PtrOperatorAST *it = ptr_operators; it; it = it->next) { if (it->next) diff --git a/src/shared/cplusplus/AST.h b/src/shared/cplusplus/AST.h index 3dd95c5e53..310b3d39e2 100644 --- a/src/shared/cplusplus/AST.h +++ b/src/shared/cplusplus/AST.h @@ -1333,7 +1333,6 @@ public: unsigned lbracket_token; ExpressionAST *expression; unsigned rbracket_token; - NewArrayDeclaratorAST *next; public: virtual NewArrayDeclaratorAST *asNewArrayDeclarator() { return this; } @@ -1392,7 +1391,7 @@ class CPLUSPLUS_EXPORT NewTypeIdAST: public AST public: SpecifierAST *type_specifier; PtrOperatorAST *ptr_operators; - NewArrayDeclaratorAST *new_array_declarators; + NewArrayDeclaratorListAST *new_array_declarators; public: virtual NewTypeIdAST *asNewTypeId() { return this; } diff --git a/src/shared/cplusplus/ASTVisit.cpp b/src/shared/cplusplus/ASTVisit.cpp index 1188eb0991..c9e86fb07f 100644 --- a/src/shared/cplusplus/ASTVisit.cpp +++ b/src/shared/cplusplus/ASTVisit.cpp @@ -565,8 +565,7 @@ void NewTypeIdAST::accept0(ASTVisitor *visitor) accept(it, visitor); for (PtrOperatorAST *it = ptr_operators; it; it = it->next) accept(it, visitor); - for (NewArrayDeclaratorAST *it = new_array_declarators; it; it = it->next) - accept(it, visitor); + accept(new_array_declarators, visitor); } visitor->endVisit(this); } diff --git a/src/shared/cplusplus/ASTfwd.h b/src/shared/cplusplus/ASTfwd.h index fbf3743fac..1eae7c3fff 100644 --- a/src/shared/cplusplus/ASTfwd.h +++ b/src/shared/cplusplus/ASTfwd.h @@ -198,6 +198,7 @@ typedef List<DeclaratorAST *> DeclaratorListAST; typedef List<BaseSpecifierAST *> BaseSpecifierListAST; typedef List<EnumeratorAST *> EnumeratorListAST; typedef List<MemInitializerAST *> MemInitializerListAST; +typedef List<NewArrayDeclaratorAST *> NewArrayDeclaratorListAST; typedef List<NameAST *> ObjCIdentifierListAST; typedef List<ObjCMessageArgumentAST *> ObjCMessageArgumentListAST; diff --git a/src/shared/cplusplus/CheckExpression.cpp b/src/shared/cplusplus/CheckExpression.cpp index 14ced9509a..763258dfda 100644 --- a/src/shared/cplusplus/CheckExpression.cpp +++ b/src/shared/cplusplus/CheckExpression.cpp @@ -207,8 +207,10 @@ bool CheckExpression::visit(NewExpressionAST *ast) if (ast->new_type_id) { FullySpecifiedType ty = semantic()->check(ast->new_type_id->type_specifier, _scope); - for (NewArrayDeclaratorAST *it = ast->new_type_id->new_array_declarators; it; it = it->next) { - FullySpecifiedType exprTy = semantic()->check(it->expression, _scope); + for (NewArrayDeclaratorListAST *it = ast->new_type_id->new_array_declarators; it; it = it->next) { + if (NewArrayDeclaratorAST *declarator = it->value) { + FullySpecifiedType exprTy = semantic()->check(declarator->expression, _scope); + } } } diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index 86f046b9c5..9179f21db1 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -3810,7 +3810,7 @@ bool Parser::parseNewTypeId(NewTypeIdAST *&node) PtrOperatorAST **ptrop_it = &ast->ptr_operators; while (parsePtrOperator(*ptrop_it)) ptrop_it = &(*ptrop_it)->next; - NewArrayDeclaratorAST **it = &ast->new_array_declarators; + NewArrayDeclaratorListAST **it = &ast->new_array_declarators; while (parseNewArrayDeclarator(*it)) it = &(*it)->next; node = ast; @@ -3818,7 +3818,7 @@ bool Parser::parseNewTypeId(NewTypeIdAST *&node) } -bool Parser::parseNewArrayDeclarator(NewArrayDeclaratorAST *&node) +bool Parser::parseNewArrayDeclarator(NewArrayDeclaratorListAST *&node) { DEBUG_THIS_RULE(); if (LA() != T_LBRACKET) @@ -3828,7 +3828,9 @@ bool Parser::parseNewArrayDeclarator(NewArrayDeclaratorAST *&node) ast->lbracket_token = consumeToken(); parseExpression(ast->expression); match(T_RBRACKET, &ast->rbracket_token); - node = ast; + + node = new (_pool) NewArrayDeclaratorListAST; + node->value = ast; return true; } diff --git a/src/shared/cplusplus/Parser.h b/src/shared/cplusplus/Parser.h index 40f2f7e558..57a7eaf760 100644 --- a/src/shared/cplusplus/Parser.h +++ b/src/shared/cplusplus/Parser.h @@ -146,7 +146,7 @@ public: bool parseNestedNameSpecifierOpt(NestedNameSpecifierAST *&name, bool acceptTemplateId); bool parseNamespace(DeclarationAST *&node); bool parseNamespaceAliasDefinition(DeclarationAST *&node); - bool parseNewArrayDeclarator(NewArrayDeclaratorAST *&node); + bool parseNewArrayDeclarator(NewArrayDeclaratorListAST *&node); bool parseNewExpression(ExpressionAST *&node); bool parseNewPlacement(NewPlacementAST *&node); bool parseNewInitializer(NewInitializerAST *&node); |