forked from qt-creator/qt-creator
Cleanup postfix declarators.
This commit is contained in:
@@ -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();
|
||||
|
@@ -374,9 +374,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;
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user