Commit aff9a743 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Cleanup NewArrayDeclaratorAST

parent 73a4f297
......@@ -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)
......
......@@ -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; }
......
......@@ -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);
}
......
......@@ -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;
......
......@@ -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);
}
}
}
......
......@@ -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;
}
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment