forked from qt-creator/qt-creator
Improved compatibility with the gcc extensions.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user