summaryrefslogtreecommitdiff
path: root/src/shared/cplusplus
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2009-11-10 14:33:51 +0100
committerRoberto Raggi <roberto.raggi@nokia.com>2009-11-10 16:20:12 +0100
commit24b6c858ebc3a16e9a82c0ea6e8fc6743f0e3229 (patch)
treecf837fd4dfbf50cdc00ac9c6e3b8ff6b86649cef /src/shared/cplusplus
parenta7219736b6081888a35aa5f58fcec4abc8dfad44 (diff)
downloadqt-creator-24b6c858ebc3a16e9a82c0ea6e8fc6743f0e3229.tar.gz
Cleanup postfix declarators.
Diffstat (limited to 'src/shared/cplusplus')
-rw-r--r--src/shared/cplusplus/AST.cpp6
-rw-r--r--src/shared/cplusplus/AST.h5
-rw-r--r--src/shared/cplusplus/ASTVisit.cpp3
-rw-r--r--src/shared/cplusplus/ASTfwd.h1
-rw-r--r--src/shared/cplusplus/CheckDeclarator.cpp5
-rw-r--r--src/shared/cplusplus/Parser.cpp16
6 files changed, 13 insertions, 23 deletions
diff --git a/src/shared/cplusplus/AST.cpp b/src/shared/cplusplus/AST.cpp
index 035f5dae37..30ba2cba5a 100644
--- a/src/shared/cplusplus/AST.cpp
+++ b/src/shared/cplusplus/AST.cpp
@@ -560,10 +560,8 @@ unsigned DeclaratorAST::lastToken() const
return it->lastToken();
}
- for (PostfixDeclaratorAST *it = postfix_declarators; it; it = it->next) {
- if (! it->next)
- return it->lastToken();
- }
+ if (postfix_declarators)
+ return postfix_declarators->lastToken();
if (core_declarator)
return core_declarator->lastToken();
diff --git a/src/shared/cplusplus/AST.h b/src/shared/cplusplus/AST.h
index bd5b91f4ad..b56fed68c7 100644
--- a/src/shared/cplusplus/AST.h
+++ b/src/shared/cplusplus/AST.h
@@ -375,9 +375,6 @@ public:
class CPLUSPLUS_EXPORT PostfixDeclaratorAST: public AST
{
public:
- PostfixDeclaratorAST *next;
-
-public:
virtual PostfixDeclaratorAST *asPostfixDeclarator() { return this; }
};
@@ -387,7 +384,7 @@ public:
SpecifierAST *attributes;
PtrOperatorAST *ptr_operators;
CoreDeclaratorAST *core_declarator;
- PostfixDeclaratorAST *postfix_declarators;
+ PostfixDeclaratorListAST *postfix_declarators;
SpecifierAST *post_attributes;
unsigned equals_token;
ExpressionAST *initializer;
diff --git a/src/shared/cplusplus/ASTVisit.cpp b/src/shared/cplusplus/ASTVisit.cpp
index 5345471140..e8fbdce328 100644
--- a/src/shared/cplusplus/ASTVisit.cpp
+++ b/src/shared/cplusplus/ASTVisit.cpp
@@ -73,8 +73,7 @@ void DeclaratorAST::accept0(ASTVisitor *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);
+ accept(postfix_declarators, visitor);
for (SpecifierAST *it = post_attributes; it; it = it->next)
accept(it, visitor);
accept(initializer, visitor);
diff --git a/src/shared/cplusplus/ASTfwd.h b/src/shared/cplusplus/ASTfwd.h
index 9bbf9681f0..922dd6b276 100644
--- a/src/shared/cplusplus/ASTfwd.h
+++ b/src/shared/cplusplus/ASTfwd.h
@@ -200,6 +200,7 @@ typedef List<EnumeratorAST *> EnumeratorListAST;
typedef List<MemInitializerAST *> MemInitializerListAST;
typedef List<NewArrayDeclaratorAST *> NewArrayDeclaratorListAST;
typedef List<PostfixAST *> PostfixListAST;
+typedef List<PostfixDeclaratorAST *> PostfixDeclaratorListAST;
typedef List<NameAST *> ObjCIdentifierListAST;
typedef List<ObjCMessageArgumentAST *> ObjCMessageArgumentListAST;
diff --git a/src/shared/cplusplus/CheckDeclarator.cpp b/src/shared/cplusplus/CheckDeclarator.cpp
index f89f796fe4..d32926e2eb 100644
--- a/src/shared/cplusplus/CheckDeclarator.cpp
+++ b/src/shared/cplusplus/CheckDeclarator.cpp
@@ -205,7 +205,6 @@ bool CheckDeclarator::visit(FunctionDeclaratorAST *ast)
fun->setVolatile(true);
}
- accept(ast->next);
return false;
}
@@ -215,7 +214,6 @@ bool CheckDeclarator::visit(ArrayDeclaratorAST *ast)
FullySpecifiedType exprTy = semantic()->check(ast->expression, _scope);
FullySpecifiedType arrTy(ty);
_fullySpecifiedType = ty;
- accept(ast->next);
return false;
}
@@ -226,7 +224,6 @@ bool CheckDeclarator::visit(PointerToMemberAST *ast)
FullySpecifiedType ty(ptrTy);
_fullySpecifiedType = ty;
applyCvQualifiers(ast->cv_qualifier_seq);
- accept(ast->next);
return false;
}
@@ -236,7 +233,6 @@ bool CheckDeclarator::visit(PointerAST *ast)
FullySpecifiedType ty(ptrTy);
_fullySpecifiedType = ty;
applyCvQualifiers(ast->cv_qualifier_seq);
- accept(ast->next);
return false;
}
@@ -245,7 +241,6 @@ bool CheckDeclarator::visit(ReferenceAST *ast)
ReferenceType *refTy = control()->referenceType(_fullySpecifiedType);
FullySpecifiedType ty(refTy);
_fullySpecifiedType = ty;
- accept(ast->next);
return false;
}
diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp
index f951973616..c74b3ca960 100644
--- a/src/shared/cplusplus/Parser.cpp
+++ b/src/shared/cplusplus/Parser.cpp
@@ -1127,7 +1127,7 @@ bool Parser::parseDeclarator(DeclaratorAST *&node, bool stopAtCppInitializer)
if (! parseCoreDeclarator(node))
return false;
- PostfixDeclaratorAST **postfix_ptr = &node->postfix_declarators;
+ PostfixDeclaratorListAST **postfix_ptr = &node->postfix_declarators;
for (;;) {
unsigned startOfPostDeclarator = cursor();
@@ -1155,7 +1155,7 @@ bool Parser::parseDeclarator(DeclaratorAST *&node, bool stopAtCppInitializer)
ast->parameters = parameter_declaration_clause;
ast->as_cpp_initializer = initializer;
ast->rparen_token = rparen_token;
- *postfix_ptr = ast;
+ *postfix_ptr = new (_pool) PostfixDeclaratorListAST(ast);
postfix_ptr = &(*postfix_ptr)->next;
blockErrors(blocked);
@@ -1185,7 +1185,7 @@ bool Parser::parseDeclarator(DeclaratorAST *&node, bool stopAtCppInitializer)
ast->rparen_token = consumeToken();
parseCvQualifiers(ast->cv_qualifier_seq);
parseExceptionSpecification(ast->exception_specification);
- *postfix_ptr = ast;
+ *postfix_ptr = new (_pool) PostfixDeclaratorListAST(ast);
postfix_ptr = &(*postfix_ptr)->next;
} else if (LA() == T_LBRACKET) {
ArrayDeclaratorAST *ast = new (_pool) ArrayDeclaratorAST;
@@ -1193,7 +1193,7 @@ bool Parser::parseDeclarator(DeclaratorAST *&node, bool stopAtCppInitializer)
if (LA() == T_RBRACKET || parseConstantExpression(ast->expression)) {
match(T_RBRACKET, &ast->rbracket_token);
}
- *postfix_ptr = ast;
+ *postfix_ptr = new (_pool) PostfixDeclaratorListAST(ast);
postfix_ptr = &(*postfix_ptr)->next;
} else
break;
@@ -1257,7 +1257,7 @@ bool Parser::parseAbstractDeclarator(DeclaratorAST *&node)
if (! parseAbstractCoreDeclarator(node))
return false;
- PostfixDeclaratorAST *postfix_declarators = 0,
+ PostfixDeclaratorListAST *postfix_declarators = 0,
**postfix_ptr = &postfix_declarators;
for (;;) {
@@ -1270,7 +1270,7 @@ bool Parser::parseAbstractDeclarator(DeclaratorAST *&node)
}
parseCvQualifiers(ast->cv_qualifier_seq);
parseExceptionSpecification(ast->exception_specification);
- *postfix_ptr = ast;
+ *postfix_ptr = new (_pool) PostfixDeclaratorListAST(ast);
postfix_ptr = &(*postfix_ptr)->next;
} else if (LA() == T_LBRACKET) {
ArrayDeclaratorAST *ast = new (_pool) ArrayDeclaratorAST;
@@ -1279,7 +1279,7 @@ bool Parser::parseAbstractDeclarator(DeclaratorAST *&node)
if (LA() == T_RBRACKET)
ast->rbracket_token = consumeToken();
}
- *postfix_ptr = ast;
+ *postfix_ptr = new (_pool) PostfixDeclaratorListAST(ast);
postfix_ptr = &(*postfix_ptr)->next;
} else
break;
@@ -2206,7 +2206,7 @@ bool Parser::maybeAmbiguousStatement(DeclarationStatementAST *ast) const
} else if (DeclaratorListAST *declarators = declaration->declarators) {
// no decl_specifiers...
if (DeclaratorAST *declarator = declarators->value) {
- if (declarator->postfix_declarators && declarator->postfix_declarators->asFunctionDeclarator()
+ if (declarator->postfix_declarators && declarator->postfix_declarators->value->asFunctionDeclarator()
&& ! declarator->initializer) {
return false;
}