summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libs/3rdparty/cplusplus/AST.cpp42
-rw-r--r--src/libs/3rdparty/cplusplus/AST.h62
-rw-r--r--src/libs/3rdparty/cplusplus/ASTClone.cpp24
-rw-r--r--src/libs/3rdparty/cplusplus/ASTMatch0.cpp16
-rw-r--r--src/libs/3rdparty/cplusplus/ASTMatcher.cpp25
-rw-r--r--src/libs/3rdparty/cplusplus/ASTMatcher.h5
-rw-r--r--src/libs/3rdparty/cplusplus/ASTPatternBuilder.h31
-rw-r--r--src/libs/3rdparty/cplusplus/ASTVisit.cpp12
-rw-r--r--src/libs/3rdparty/cplusplus/ASTVisitor.h10
-rw-r--r--src/libs/3rdparty/cplusplus/ASTfwd.h6
-rw-r--r--src/libs/3rdparty/cplusplus/Bind.cpp16
-rw-r--r--src/libs/3rdparty/cplusplus/Bind.h7
-rw-r--r--src/libs/3rdparty/cplusplus/Parser.cpp118
-rw-r--r--src/libs/3rdparty/cplusplus/Parser.h6
-rw-r--r--src/libs/cplusplus/FindUsages.cpp8
-rw-r--r--src/libs/cplusplus/FindUsages.h6
-rw-r--r--tests/auto/cplusplus/ast/tst_ast.cpp12
-rw-r--r--tests/auto/cplusplus/cxx11/data/alignofAlignas.1.cpp6
-rw-r--r--tests/auto/cplusplus/findusages/tst_findusages.cpp33
-rw-r--r--tests/tools/cplusplus-ast2png/dumpers.inc20
20 files changed, 345 insertions, 120 deletions
diff --git a/src/libs/3rdparty/cplusplus/AST.cpp b/src/libs/3rdparty/cplusplus/AST.cpp
index 312b1dcfc2..0eb73f58fb 100644
--- a/src/libs/3rdparty/cplusplus/AST.cpp
+++ b/src/libs/3rdparty/cplusplus/AST.cpp
@@ -68,7 +68,7 @@ bool AST::match(AST *pattern, ASTMatcher *matcher)
return match0(pattern, matcher);
}
-unsigned AttributeSpecifierAST::firstToken() const
+unsigned GnuAttributeSpecifierAST::firstToken() const
{
return attribute_token;
}
@@ -242,7 +242,7 @@ unsigned AsmDefinitionAST::lastToken() const
}
/** \generated */
-unsigned AttributeAST::firstToken() const
+unsigned GnuAttributeAST::firstToken() const
{
if (identifier_token)
return identifier_token;
@@ -259,7 +259,7 @@ unsigned AttributeAST::firstToken() const
}
/** \generated */
-unsigned AttributeAST::lastToken() const
+unsigned GnuAttributeAST::lastToken() const
{
if (rparen_token)
return rparen_token + 1;
@@ -4194,7 +4194,7 @@ unsigned WhileStatementAST::lastToken() const
}
/** \generated */
-unsigned AttributeSpecifierAST::lastToken() const
+unsigned GnuAttributeSpecifierAST::lastToken() const
{
if (second_rparen_token)
return second_rparen_token + 1;
@@ -4524,3 +4524,37 @@ unsigned DotDesignatorAST::lastToken() const
return 1;
}
+/** \generated */
+unsigned AlignmentSpecifierAST::firstToken() const
+{
+ if (align_token)
+ return align_token;
+ if (lparen_token)
+ return lparen_token;
+ if (typeIdExprOrAlignmentExpr)
+ if (unsigned candidate = typeIdExprOrAlignmentExpr->firstToken())
+ return candidate;
+ if (ellipses_token)
+ return ellipses_token;
+ if (rparen_token)
+ return rparen_token;
+ return 0;
+}
+
+/** \generated */
+unsigned AlignmentSpecifierAST::lastToken() const
+{
+ if (rparen_token)
+ return rparen_token + 1;
+ if (ellipses_token)
+ return ellipses_token + 1;
+ if (typeIdExprOrAlignmentExpr)
+ if (unsigned candidate = typeIdExprOrAlignmentExpr->lastToken())
+ return candidate;
+ if (lparen_token)
+ return lparen_token + 1;
+ if (align_token)
+ return align_token + 1;
+ return 1;
+}
+
diff --git a/src/libs/3rdparty/cplusplus/AST.h b/src/libs/3rdparty/cplusplus/AST.h
index a0f5a2fa64..e0e76f0323 100644
--- a/src/libs/3rdparty/cplusplus/AST.h
+++ b/src/libs/3rdparty/cplusplus/AST.h
@@ -126,13 +126,13 @@ public:
virtual AccessDeclarationAST *asAccessDeclaration() { return 0; }
virtual AliasDeclarationAST *asAliasDeclaration() { return 0; }
+ virtual AlignmentSpecifierAST *asAlignmentSpecifier() { return 0; }
virtual AlignofExpressionAST *asAlignofExpression() { return 0; }
virtual AnonymousNameAST *asAnonymousName() { return 0; }
virtual ArrayAccessAST *asArrayAccess() { return 0; }
virtual ArrayDeclaratorAST *asArrayDeclarator() { return 0; }
virtual ArrayInitializerAST *asArrayInitializer() { return 0; }
virtual AsmDefinitionAST *asAsmDefinition() { return 0; }
- virtual AttributeAST *asAttribute() { return 0; }
virtual AttributeSpecifierAST *asAttributeSpecifier() { return 0; }
virtual BaseSpecifierAST *asBaseSpecifier() { return 0; }
virtual BinaryExpressionAST *asBinaryExpression() { return 0; }
@@ -182,6 +182,8 @@ public:
virtual ForeachStatementAST *asForeachStatement() { return 0; }
virtual FunctionDeclaratorAST *asFunctionDeclarator() { return 0; }
virtual FunctionDefinitionAST *asFunctionDefinition() { return 0; }
+ virtual GnuAttributeAST *asGnuAttribute() { return 0; }
+ virtual GnuAttributeSpecifierAST *asGnuAttributeSpecifier() { return 0; }
virtual GotoStatementAST *asGotoStatement() { return 0; }
virtual IdExpressionAST *asIdExpression() { return 0; }
virtual IfStatementAST *asIfStatement() { return 0; }
@@ -463,15 +465,57 @@ protected:
class CPLUSPLUS_EXPORT AttributeSpecifierAST: public SpecifierAST
{
public:
+ AttributeSpecifierAST()
+ {}
+
+ virtual AttributeSpecifierAST *asAttributeSpecifier() { return this; }
+
+ virtual AttributeSpecifierAST *clone(MemoryPool *pool) const = 0;
+};
+
+class CPLUSPLUS_EXPORT AlignmentSpecifierAST: public AttributeSpecifierAST
+{
+public:
+ unsigned align_token;
+ unsigned lparen_token;
+ ExpressionAST *typeIdExprOrAlignmentExpr;
+ unsigned ellipses_token;
+ unsigned rparen_token;
+
+public:
+ AlignmentSpecifierAST()
+ : align_token(0)
+ , lparen_token(0)
+ , typeIdExprOrAlignmentExpr(0)
+ , ellipses_token(0)
+ , rparen_token(0)
+ {}
+
+ virtual AlignmentSpecifierAST *asAlignmentSpecifier() { return this; }
+
+ virtual unsigned firstToken() const;
+ virtual unsigned lastToken() const;
+
+ virtual AlignmentSpecifierAST *clone(MemoryPool *pool) const;
+
+protected:
+ virtual void accept0(ASTVisitor *visitor);
+ virtual bool match0(AST *, ASTMatcher *);
+};
+
+
+class CPLUSPLUS_EXPORT GnuAttributeSpecifierAST: public AttributeSpecifierAST
+{
+public:
unsigned attribute_token;
unsigned first_lparen_token;
unsigned second_lparen_token;
- AttributeListAST *attribute_list;
+ GnuAttributeListAST *attribute_list;
unsigned first_rparen_token;
unsigned second_rparen_token;
public:
- AttributeSpecifierAST()
+ GnuAttributeSpecifierAST()
: attribute_token(0)
, first_lparen_token(0)
, second_lparen_token(0)
@@ -480,19 +524,19 @@ public:
, second_rparen_token(0)
{}
- virtual AttributeSpecifierAST *asAttributeSpecifier() { return this; }
+ virtual GnuAttributeSpecifierAST *asGnuAttributeSpecifier() { return this; }
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
- virtual AttributeSpecifierAST *clone(MemoryPool *pool) const;
+ virtual GnuAttributeSpecifierAST *clone(MemoryPool *pool) const;
protected:
virtual void accept0(ASTVisitor *visitor);
virtual bool match0(AST *, ASTMatcher *);
};
-class CPLUSPLUS_EXPORT AttributeAST: public AST
+class CPLUSPLUS_EXPORT GnuAttributeAST: public AST
{
public:
unsigned identifier_token;
@@ -502,7 +546,7 @@ public:
unsigned rparen_token;
public:
- AttributeAST()
+ GnuAttributeAST()
: identifier_token(0)
, lparen_token(0)
, tag_token(0)
@@ -510,12 +554,12 @@ public:
, rparen_token(0)
{}
- virtual AttributeAST *asAttribute() { return this; }
+ virtual GnuAttributeAST *asGnuAttribute() { return this; }
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
- virtual AttributeAST *clone(MemoryPool *pool) const;
+ virtual GnuAttributeAST *clone(MemoryPool *pool) const;
protected:
virtual void accept0(ASTVisitor *visitor);
diff --git a/src/libs/3rdparty/cplusplus/ASTClone.cpp b/src/libs/3rdparty/cplusplus/ASTClone.cpp
index 969adef311..3458846ea0 100644
--- a/src/libs/3rdparty/cplusplus/ASTClone.cpp
+++ b/src/libs/3rdparty/cplusplus/ASTClone.cpp
@@ -55,23 +55,35 @@ SimpleSpecifierAST *SimpleSpecifierAST::clone(MemoryPool *pool) const
return ast;
}
-AttributeSpecifierAST *AttributeSpecifierAST::clone(MemoryPool *pool) const
+AlignmentSpecifierAST *AlignmentSpecifierAST::clone(MemoryPool *pool) const
{
- AttributeSpecifierAST *ast = new (pool) AttributeSpecifierAST;
+ AlignmentSpecifierAST *ast = new (pool) AlignmentSpecifierAST;
+ ast->align_token = align_token;
+ ast->lparen_token = lparen_token;
+ if (typeIdExprOrAlignmentExpr)
+ ast->typeIdExprOrAlignmentExpr = typeIdExprOrAlignmentExpr->clone(pool);
+ ast->ellipses_token = ellipses_token;
+ ast->rparen_token = rparen_token;
+ return ast;
+}
+
+GnuAttributeSpecifierAST *GnuAttributeSpecifierAST::clone(MemoryPool *pool) const
+{
+ GnuAttributeSpecifierAST *ast = new (pool) GnuAttributeSpecifierAST;
ast->attribute_token = attribute_token;
ast->first_lparen_token = first_lparen_token;
ast->second_lparen_token = second_lparen_token;
- for (AttributeListAST *iter = attribute_list, **ast_iter = &ast->attribute_list;
+ for (GnuAttributeListAST *iter = attribute_list, **ast_iter = &ast->attribute_list;
iter; iter = iter->next, ast_iter = &(*ast_iter)->next)
- *ast_iter = new (pool) AttributeListAST((iter->value) ? iter->value->clone(pool) : 0);
+ *ast_iter = new (pool) GnuAttributeListAST((iter->value) ? iter->value->clone(pool) : 0);
ast->first_rparen_token = first_rparen_token;
ast->second_rparen_token = second_rparen_token;
return ast;
}
-AttributeAST *AttributeAST::clone(MemoryPool *pool) const
+GnuAttributeAST *GnuAttributeAST::clone(MemoryPool *pool) const
{
- AttributeAST *ast = new (pool) AttributeAST;
+ GnuAttributeAST *ast = new (pool) GnuAttributeAST;
ast->identifier_token = identifier_token;
ast->lparen_token = lparen_token;
ast->tag_token = tag_token;
diff --git a/src/libs/3rdparty/cplusplus/ASTMatch0.cpp b/src/libs/3rdparty/cplusplus/ASTMatch0.cpp
index ff51efcd1a..b0e732b257 100644
--- a/src/libs/3rdparty/cplusplus/ASTMatch0.cpp
+++ b/src/libs/3rdparty/cplusplus/ASTMatch0.cpp
@@ -56,17 +56,25 @@ bool SimpleSpecifierAST::match0(AST *pattern, ASTMatcher *matcher)
return false;
}
-bool AttributeSpecifierAST::match0(AST *pattern, ASTMatcher *matcher)
+bool AlignmentSpecifierAST::match0(AST *pattern, ASTMatcher *matcher)
{
- if (AttributeSpecifierAST *_other = pattern->asAttributeSpecifier())
+ if (AlignmentSpecifierAST *_other = pattern->asAlignmentSpecifier())
return matcher->match(this, _other);
return false;
}
-bool AttributeAST::match0(AST *pattern, ASTMatcher *matcher)
+bool GnuAttributeSpecifierAST::match0(AST *pattern, ASTMatcher *matcher)
{
- if (AttributeAST *_other = pattern->asAttribute())
+ if (GnuAttributeSpecifierAST *_other = pattern->asGnuAttributeSpecifier())
+ return matcher->match(this, _other);
+
+ return false;
+}
+
+bool GnuAttributeAST::match0(AST *pattern, ASTMatcher *matcher)
+{
+ if (GnuAttributeAST *_other = pattern->asGnuAttribute())
return matcher->match(this, _other);
return false;
diff --git a/src/libs/3rdparty/cplusplus/ASTMatcher.cpp b/src/libs/3rdparty/cplusplus/ASTMatcher.cpp
index 415adbcf3d..055b55a32d 100644
--- a/src/libs/3rdparty/cplusplus/ASTMatcher.cpp
+++ b/src/libs/3rdparty/cplusplus/ASTMatcher.cpp
@@ -73,7 +73,28 @@ bool ASTMatcher::match(SimpleSpecifierAST *node, SimpleSpecifierAST *pattern)
return true;
}
-bool ASTMatcher::match(AttributeSpecifierAST *node, AttributeSpecifierAST *pattern)
+bool ASTMatcher::match(AlignmentSpecifierAST *node, AlignmentSpecifierAST *pattern)
+{
+ (void) node;
+ (void) pattern;
+
+ pattern->align_token = node->align_token;
+
+ pattern->lparen_token = node->lparen_token;
+
+ if (! pattern->typeIdExprOrAlignmentExpr)
+ pattern->typeIdExprOrAlignmentExpr = node->typeIdExprOrAlignmentExpr;
+ else if (! AST::match(node->typeIdExprOrAlignmentExpr, pattern->typeIdExprOrAlignmentExpr, this))
+ return false;
+
+ pattern->ellipses_token = node->ellipses_token;
+
+ pattern->rparen_token = node->rparen_token;
+
+ return true;
+}
+
+bool ASTMatcher::match(GnuAttributeSpecifierAST *node, GnuAttributeSpecifierAST *pattern)
{
(void) node;
(void) pattern;
@@ -96,7 +117,7 @@ bool ASTMatcher::match(AttributeSpecifierAST *node, AttributeSpecifierAST *patte
return true;
}
-bool ASTMatcher::match(AttributeAST *node, AttributeAST *pattern)
+bool ASTMatcher::match(GnuAttributeAST *node, GnuAttributeAST *pattern)
{
(void) node;
(void) pattern;
diff --git a/src/libs/3rdparty/cplusplus/ASTMatcher.h b/src/libs/3rdparty/cplusplus/ASTMatcher.h
index 042d5c9c9d..888ada0c20 100644
--- a/src/libs/3rdparty/cplusplus/ASTMatcher.h
+++ b/src/libs/3rdparty/cplusplus/ASTMatcher.h
@@ -33,14 +33,13 @@ public:
virtual bool match(AccessDeclarationAST *node, AccessDeclarationAST *pattern);
virtual bool match(AliasDeclarationAST *node, AliasDeclarationAST *pattern);
+ virtual bool match(AlignmentSpecifierAST *node, AlignmentSpecifierAST *pattern);
virtual bool match(AlignofExpressionAST *node, AlignofExpressionAST *pattern);
virtual bool match(AnonymousNameAST *node, AnonymousNameAST *pattern);
virtual bool match(ArrayAccessAST *node, ArrayAccessAST *pattern);
virtual bool match(ArrayDeclaratorAST *node, ArrayDeclaratorAST *pattern);
virtual bool match(ArrayInitializerAST *node, ArrayInitializerAST *pattern);
virtual bool match(AsmDefinitionAST *node, AsmDefinitionAST *pattern);
- virtual bool match(AttributeAST *node, AttributeAST *pattern);
- virtual bool match(AttributeSpecifierAST *node, AttributeSpecifierAST *pattern);
virtual bool match(BaseSpecifierAST *node, BaseSpecifierAST *pattern);
virtual bool match(BinaryExpressionAST *node, BinaryExpressionAST *pattern);
virtual bool match(BoolLiteralAST *node, BoolLiteralAST *pattern);
@@ -84,6 +83,8 @@ public:
virtual bool match(ForeachStatementAST *node, ForeachStatementAST *pattern);
virtual bool match(FunctionDeclaratorAST *node, FunctionDeclaratorAST *pattern);
virtual bool match(FunctionDefinitionAST *node, FunctionDefinitionAST *pattern);
+ virtual bool match(GnuAttributeAST *node, GnuAttributeAST *pattern);
+ virtual bool match(GnuAttributeSpecifierAST *node, GnuAttributeSpecifierAST *pattern);
virtual bool match(GotoStatementAST *node, GotoStatementAST *pattern);
virtual bool match(IdExpressionAST *node, IdExpressionAST *pattern);
virtual bool match(IfStatementAST *node, IfStatementAST *pattern);
diff --git a/src/libs/3rdparty/cplusplus/ASTPatternBuilder.h b/src/libs/3rdparty/cplusplus/ASTPatternBuilder.h
index 929337ee9b..c8c9d50d6d 100644
--- a/src/libs/3rdparty/cplusplus/ASTPatternBuilder.h
+++ b/src/libs/3rdparty/cplusplus/ASTPatternBuilder.h
@@ -63,16 +63,23 @@ public:
return __ast;
}
- AttributeSpecifierAST *AttributeSpecifier(AttributeListAST *attribute_list = 0)
+ AlignmentSpecifierAST *AlignmentSpecifier(ExpressionAST *typeIdExprOrAlignmentExpr = 0)
{
- AttributeSpecifierAST *__ast = new (&pool) AttributeSpecifierAST;
+ AlignmentSpecifierAST *__ast = new (&pool) AlignmentSpecifierAST;
+ __ast->typeIdExprOrAlignmentExpr = typeIdExprOrAlignmentExpr;
+ return __ast;
+ }
+
+ GnuAttributeSpecifierAST *GnuAttributeSpecifier(GnuAttributeListAST *attribute_list = 0)
+ {
+ GnuAttributeSpecifierAST *__ast = new (&pool) GnuAttributeSpecifierAST;
__ast->attribute_list = attribute_list;
return __ast;
}
- AttributeAST *Attribute(ExpressionListAST *expression_list = 0)
+ GnuAttributeAST *GnuAttribute(ExpressionListAST *expression_list = 0)
{
- AttributeAST *__ast = new (&pool) AttributeAST;
+ GnuAttributeAST *__ast = new (&pool) GnuAttributeAST;
__ast->expression_list = expression_list;
return __ast;
}
@@ -1168,14 +1175,6 @@ public:
return __ast;
}
- AttributeListAST *AttributeList(AttributeAST *value, AttributeListAST *next = 0)
- {
- AttributeListAST *__list = new (&pool) AttributeListAST;
- __list->next = next;
- __list->value = value;
- return __list;
- }
-
BaseSpecifierListAST *BaseSpecifierList(BaseSpecifierAST *value, BaseSpecifierListAST *next = 0)
{
BaseSpecifierListAST *__list = new (&pool) BaseSpecifierListAST;
@@ -1240,6 +1239,14 @@ public:
return __list;
}
+ GnuAttributeListAST *GnuAttributeList(GnuAttributeAST *value, GnuAttributeListAST *next = 0)
+ {
+ GnuAttributeListAST *__list = new (&pool) GnuAttributeListAST;
+ __list->next = next;
+ __list->value = value;
+ return __list;
+ }
+
MemInitializerListAST *MemInitializerList(MemInitializerAST *value, MemInitializerListAST *next = 0)
{
MemInitializerListAST *__list = new (&pool) MemInitializerListAST;
diff --git a/src/libs/3rdparty/cplusplus/ASTVisit.cpp b/src/libs/3rdparty/cplusplus/ASTVisit.cpp
index af8b916c9b..77b7e1b3fd 100644
--- a/src/libs/3rdparty/cplusplus/ASTVisit.cpp
+++ b/src/libs/3rdparty/cplusplus/ASTVisit.cpp
@@ -54,7 +54,15 @@ void SimpleSpecifierAST::accept0(ASTVisitor *visitor)
visitor->endVisit(this);
}
-void AttributeSpecifierAST::accept0(ASTVisitor *visitor)
+void AlignmentSpecifierAST::accept0(ASTVisitor *visitor)
+{
+ if (visitor->visit(this)) {
+ accept(typeIdExprOrAlignmentExpr, visitor);
+ }
+ visitor->endVisit(this);
+}
+
+void GnuAttributeSpecifierAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
accept(attribute_list, visitor);
@@ -62,7 +70,7 @@ void AttributeSpecifierAST::accept0(ASTVisitor *visitor)
visitor->endVisit(this);
}
-void AttributeAST::accept0(ASTVisitor *visitor)
+void GnuAttributeAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
accept(expression_list, visitor);
diff --git a/src/libs/3rdparty/cplusplus/ASTVisitor.h b/src/libs/3rdparty/cplusplus/ASTVisitor.h
index 2d22680380..16b6ebd58b 100644
--- a/src/libs/3rdparty/cplusplus/ASTVisitor.h
+++ b/src/libs/3rdparty/cplusplus/ASTVisitor.h
@@ -75,14 +75,13 @@ public:
virtual bool visit(AccessDeclarationAST *) { return true; }
virtual bool visit(AliasDeclarationAST *) { return true; }
+ virtual bool visit(AlignmentSpecifierAST *) { return true; }
virtual bool visit(AlignofExpressionAST *) { return true; }
virtual bool visit(AnonymousNameAST *) { return true; }
virtual bool visit(ArrayAccessAST *) { return true; }
virtual bool visit(ArrayDeclaratorAST *) { return true; }
virtual bool visit(ArrayInitializerAST *) { return true; }
virtual bool visit(AsmDefinitionAST *) { return true; }
- virtual bool visit(AttributeAST *) { return true; }
- virtual bool visit(AttributeSpecifierAST *) { return true; }
virtual bool visit(BaseSpecifierAST *) { return true; }
virtual bool visit(BinaryExpressionAST *) { return true; }
virtual bool visit(BoolLiteralAST *) { return true; }
@@ -126,6 +125,8 @@ public:
virtual bool visit(ForeachStatementAST *) { return true; }
virtual bool visit(FunctionDeclaratorAST *) { return true; }
virtual bool visit(FunctionDefinitionAST *) { return true; }
+ virtual bool visit(GnuAttributeAST *) { return true; }
+ virtual bool visit(GnuAttributeSpecifierAST *) { return true; }
virtual bool visit(GotoStatementAST *) { return true; }
virtual bool visit(IdExpressionAST *) { return true; }
virtual bool visit(IfStatementAST *) { return true; }
@@ -224,14 +225,13 @@ public:
virtual void endVisit(AccessDeclarationAST *) {}
virtual void endVisit(AliasDeclarationAST *) {}
+ virtual void endVisit(AlignmentSpecifierAST *) {}
virtual void endVisit(AlignofExpressionAST *) {}
virtual void endVisit(AnonymousNameAST *) {}
virtual void endVisit(ArrayAccessAST *) {}
virtual void endVisit(ArrayDeclaratorAST *) {}
virtual void endVisit(ArrayInitializerAST *) {}
virtual void endVisit(AsmDefinitionAST *) {}
- virtual void endVisit(AttributeAST *) {}
- virtual void endVisit(AttributeSpecifierAST *) {}
virtual void endVisit(BaseSpecifierAST *) {}
virtual void endVisit(BinaryExpressionAST *) {}
virtual void endVisit(BoolLiteralAST *) {}
@@ -275,6 +275,8 @@ public:
virtual void endVisit(ForeachStatementAST *) {}
virtual void endVisit(FunctionDeclaratorAST *) {}
virtual void endVisit(FunctionDefinitionAST *) {}
+ virtual void endVisit(GnuAttributeAST *) {}
+ virtual void endVisit(GnuAttributeSpecifierAST *) {}
virtual void endVisit(GotoStatementAST *) {}
virtual void endVisit(IdExpressionAST *) {}
virtual void endVisit(IfStatementAST *) {}
diff --git a/src/libs/3rdparty/cplusplus/ASTfwd.h b/src/libs/3rdparty/cplusplus/ASTfwd.h
index 744fd57756..f48ae335f6 100644
--- a/src/libs/3rdparty/cplusplus/ASTfwd.h
+++ b/src/libs/3rdparty/cplusplus/ASTfwd.h
@@ -33,13 +33,13 @@ class ASTMatcher;
class AccessDeclarationAST;
class AliasDeclarationAST;
+class AlignmentSpecifierAST;
class AlignofExpressionAST;
class AnonymousNameAST;
class ArrayAccessAST;
class ArrayDeclaratorAST;
class ArrayInitializerAST;
class AsmDefinitionAST;
-class AttributeAST;
class AttributeSpecifierAST;
class BaseSpecifierAST;
class BinaryExpressionAST;
@@ -89,6 +89,8 @@ class ForStatementAST;
class ForeachStatementAST;
class FunctionDeclaratorAST;
class FunctionDefinitionAST;
+class GnuAttributeAST;
+class GnuAttributeSpecifierAST;
class GotoStatementAST;
class IdExpressionAST;
class IfStatementAST;
@@ -201,7 +203,7 @@ typedef List<MemInitializerAST *> MemInitializerListAST;
typedef List<NewArrayDeclaratorAST *> NewArrayDeclaratorListAST;
typedef List<PostfixAST *> PostfixListAST;
typedef List<PostfixDeclaratorAST *> PostfixDeclaratorListAST;
-typedef List<AttributeAST *> AttributeListAST;
+typedef List<GnuAttributeAST *> GnuAttributeListAST;
typedef List<NestedNameSpecifierAST *> NestedNameSpecifierListAST;
typedef List<CatchClauseAST *> CatchClauseListAST;
typedef List<PtrOperatorAST *> PtrOperatorListAST;
diff --git a/src/libs/3rdparty/cplusplus/Bind.cpp b/src/libs/3rdparty/cplusplus/Bind.cpp
index 4f7be860df..ed39f95c1c 100644
--- a/src/libs/3rdparty/cplusplus/Bind.cpp
+++ b/src/libs/3rdparty/cplusplus/Bind.cpp
@@ -303,14 +303,14 @@ const Name *Bind::objCSelectorArgument(ObjCSelectorArgumentAST *ast, bool *hasAr
return identifier(ast->name_token);
}
-bool Bind::visit(AttributeAST *ast)
+bool Bind::visit(GnuAttributeAST *ast)
{
(void) ast;
CPP_CHECK(!"unreachable");
return false;
}
-void Bind::attribute(AttributeAST *ast)
+void Bind::attribute(GnuAttributeAST *ast)
{
if (! ast)
return;
@@ -2902,12 +2902,20 @@ bool Bind::visit(SimpleSpecifierAST *ast)
return false;
}
-bool Bind::visit(AttributeSpecifierAST *ast)
+bool Bind::visit(AlignmentSpecifierAST *ast)
+{
+ // Prevent visiting the type-id or alignment expression from changing the currently
+ // calculated type:
+ expression(ast->typeIdExprOrAlignmentExpr);
+ return false;
+}
+
+bool Bind::visit(GnuAttributeSpecifierAST *ast)
{
// unsigned attribute_token = ast->attribute_token;
// unsigned first_lparen_token = ast->first_lparen_token;
// unsigned second_lparen_token = ast->second_lparen_token;
- for (AttributeListAST *it = ast->attribute_list; it; it = it->next) {
+ for (GnuAttributeListAST *it = ast->attribute_list; it; it = it->next) {
this->attribute(it->value);
}
// unsigned first_rparen_token = ast->first_rparen_token;
diff --git a/src/libs/3rdparty/cplusplus/Bind.h b/src/libs/3rdparty/cplusplus/Bind.h
index ded74a9da8..d7dc7073db 100644
--- a/src/libs/3rdparty/cplusplus/Bind.h
+++ b/src/libs/3rdparty/cplusplus/Bind.h
@@ -77,7 +77,7 @@ protected:
unsigned calculateScopeStart(ObjCProtocolDeclarationAST *ast) const;
const Name *objCSelectorArgument(ObjCSelectorArgumentAST *ast, bool *hasArg);
- void attribute(AttributeAST *ast);
+ void attribute(GnuAttributeAST *ast);
FullySpecifiedType declarator(DeclaratorAST *ast, const FullySpecifiedType &init, DeclaratorIdAST **declaratorId);
void qtInterfaceName(QtInterfaceNameAST *ast);
void baseSpecifier(BaseSpecifierAST *ast, unsigned colon_token, Class *klass);
@@ -112,7 +112,7 @@ protected:
// AST
virtual bool visit(ObjCSelectorArgumentAST *ast);
- virtual bool visit(AttributeAST *ast);
+ virtual bool visit(GnuAttributeAST *ast);
virtual bool visit(DeclaratorAST *ast);
virtual bool visit(QtPropertyDeclarationItemAST *ast);
virtual bool visit(QtInterfaceNameAST *ast);
@@ -245,7 +245,8 @@ protected:
// SpecifierAST
virtual bool visit(SimpleSpecifierAST *ast);
- virtual bool visit(AttributeSpecifierAST *ast);
+ virtual bool visit(AlignmentSpecifierAST *ast);
+ virtual bool visit(GnuAttributeSpecifierAST *ast);
virtual bool visit(TypeofSpecifierAST *ast);
virtual bool visit(DecltypeSpecifierAST *ast);
virtual bool visit(ClassSpecifierAST *ast);
diff --git a/src/libs/3rdparty/cplusplus/Parser.cpp b/src/libs/3rdparty/cplusplus/Parser.cpp
index 5023e982dd..75580a2efa 100644
--- a/src/libs/3rdparty/cplusplus/Parser.cpp
+++ b/src/libs/3rdparty/cplusplus/Parser.cpp
@@ -633,7 +633,7 @@ bool Parser::parseDeclaration(DeclarationAST *&node)
if (_languageFeatures.objCEnabled && LA() == T___ATTRIBUTE__) {
const unsigned start = cursor();
SpecifierListAST *attributes = 0, **attr = &attributes;
- while (parseAttributeSpecifier(*attr))
+ while (parseGnuAttributeSpecifier(*attr))
attr = &(*attr)->next;
if (LA() == T_AT_INTERFACE)
return parseObjCInterface(node, attributes);
@@ -761,11 +761,7 @@ bool Parser::parseNamespace(DeclarationAST *&node)
ast->namespace_token = namespace_token;
if (LA() == T_IDENTIFIER)
ast->identifier_token = consumeToken();
- SpecifierListAST **attr_ptr = &ast->attribute_list;
- while (LA() == T___ATTRIBUTE__) {
- parseAttributeSpecifier(*attr_ptr);
- attr_ptr = &(*attr_ptr)->next;
- }
+ parseOptionalAttributeSpecifierSequence(ast->attribute_list);
if (LA() == T_LBRACE) {
parseLinkageBody(ast->linkage_body);
} else { // attempt to do error recovery
@@ -1196,9 +1192,8 @@ bool Parser::parseCvQualifiers(SpecifierListAST *&node)
spec->specifier_token = consumeToken();
*ast = new (_pool) SpecifierListAST(spec);
ast = &(*ast)->next;
- } else if (LA() == T___ATTRIBUTE__) {
- parseAttributeSpecifier(*ast);
- ast = &(*ast)->next;
+ } else if (parseOptionalAttributeSpecifierSequence(*ast)) {
+ continue;
} else {
break;
}
@@ -1398,11 +1393,7 @@ bool Parser::parseCoreDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_sp
DEBUG_THIS_RULE();
unsigned start = cursor();
SpecifierListAST *attributes = 0;
- SpecifierListAST **attribute_ptr = &attributes;
- while (LA() == T___ATTRIBUTE__) {
- parseAttributeSpecifier(*attribute_ptr);
- attribute_ptr = &(*attribute_ptr)->next;
- }
+ parseOptionalAttributeSpecifierSequence(attributes);
PtrOperatorListAST *ptr_operators = 0, **ptr_operators_tail = &ptr_operators;
while (parsePtrOperator(*ptr_operators_tail))
@@ -1577,12 +1568,7 @@ bool Parser::parseDeclarator(DeclaratorAST *&node, SpecifierListAST *decl_specif
consumeToken(); // skip T_RPAREN
}
- SpecifierListAST **spec_ptr = &node->post_attribute_list;
- while (LA() == T___ATTRIBUTE__) {
- parseAttributeSpecifier(*spec_ptr);
- spec_ptr = &(*spec_ptr)->next;
- }
-
+ parseOptionalAttributeSpecifierSequence(node->post_attribute_list);
return true;
}
@@ -1985,11 +1971,8 @@ bool Parser::parseClassSpecifier(SpecifierListAST *&node)
unsigned classkey_token = consumeToken();
- SpecifierListAST *attributes = 0, **attr_ptr = &attributes;
- while (LA() == T___ATTRIBUTE__) {
- parseAttributeSpecifier(*attr_ptr);
- attr_ptr = &(*attr_ptr)->next;
- }
+ SpecifierListAST *attributes = 0;
+ parseOptionalAttributeSpecifierSequence(attributes);
if (LA(1) == T_IDENTIFIER && LA(2) == T_IDENTIFIER) {
const Identifier *id = tok(2).identifier;
@@ -2464,12 +2447,8 @@ bool Parser::parseElaboratedTypeSpecifier(SpecifierListAST *&node)
if (lookAtClassKey() || LA() == T_ENUM || LA() == T_TYPENAME) {
unsigned classkey_token = consumeToken();
- SpecifierListAST *attributes = 0, **attr_ptr = &attributes;
- while (LA() == T___ATTRIBUTE__) {
- parseAttributeSpecifier(*attr_ptr);
- attr_ptr = &(*attr_ptr)->next;
- }
-
+ SpecifierListAST *attributes = 0;
+ parseOptionalAttributeSpecifierSequence(attributes);
NameAST *name = 0;
if (parseName(name)) {
ElaboratedTypeSpecifierAST *ast = new (_pool) ElaboratedTypeSpecifierAST;
@@ -3780,39 +3759,83 @@ bool Parser::lookAtClassKey() const
}
}
-bool Parser::parseAttributeSpecifier(SpecifierListAST *&node)
+bool Parser::parseOptionalAttributeSpecifierSequence(SpecifierListAST *&attribute_list)
+{
+ bool didRead = false;
+ while (parseAttributeSpecifier(attribute_list))
+ didRead = true;
+ return didRead;
+}
+
+bool Parser::parseAttributeSpecifier(SpecifierListAST *&attribute_list)
+{
+ SpecifierListAST **attr_ptr = &attribute_list;
+ switch (LA()) {
+ case T_ALIGNAS: {
+ AlignmentSpecifierAST *ast = new (_pool) AlignmentSpecifierAST;
+ ast->align_token = consumeToken();
+ match(T_LPAREN, &ast->lparen_token);
+
+ const unsigned saved = cursor();
+ if (!parseTypeId(ast->typeIdExprOrAlignmentExpr) ||
+ (LA() != T_RPAREN &&
+ (LA(1) != T_DOT_DOT_DOT || LA(2) != T_RPAREN))) {
+ rewind(saved);
+ parseExpression(ast->typeIdExprOrAlignmentExpr);
+ }
+
+ if (LA() == T_DOT_DOT_DOT)
+ ast->ellipses_token = consumeToken();
+ match(T_RPAREN, &ast->rparen_token);
+ attribute_list = new (_pool) SpecifierListAST(ast);
+ return true;
+ }
+ //### TODO: C++11-style attributes
+// case T_LBRACKET:
+ case T___ATTRIBUTE__:
+ while (LA() == T___ATTRIBUTE__) {
+ parseGnuAttributeSpecifier(*attr_ptr);
+ attr_ptr = &(*attr_ptr)->next;
+ }
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool Parser::parseGnuAttributeSpecifier(SpecifierListAST *&node)
{
DEBUG_THIS_RULE();
if (LA() != T___ATTRIBUTE__)
return false;
- AttributeSpecifierAST *ast = new (_pool) AttributeSpecifierAST;
+ GnuAttributeSpecifierAST *ast = new (_pool) GnuAttributeSpecifierAST;
ast->attribute_token = consumeToken();
match(T_LPAREN, &ast->first_lparen_token);
match(T_LPAREN, &ast->second_lparen_token);
- parseAttributeList(ast->attribute_list);
+ parseGnuAttributeList(ast->attribute_list);
match(T_RPAREN, &ast->first_rparen_token);
match(T_RPAREN, &ast->second_rparen_token);
node = new (_pool) SpecifierListAST(ast);
return true;
}
-bool Parser::parseAttributeList(AttributeListAST *&node)
+bool Parser::parseGnuAttributeList(GnuAttributeListAST *&node)
{
DEBUG_THIS_RULE();
- AttributeListAST **iter = &node;
+ GnuAttributeListAST **iter = &node;
while (LA() == T_CONST || LA() == T_IDENTIFIER) {
- *iter = new (_pool) AttributeListAST;
+ *iter = new (_pool) GnuAttributeListAST;
if (LA() == T_CONST) {
- AttributeAST *attr = new (_pool) AttributeAST;
+ GnuAttributeAST *attr = new (_pool) GnuAttributeAST;
attr->identifier_token = consumeToken();
(*iter)->value = attr;
iter = &(*iter)->next;
} else if (LA() == T_IDENTIFIER) {
- AttributeAST *attr = new (_pool) AttributeAST;
+ GnuAttributeAST *attr = new (_pool) GnuAttributeAST;
attr->identifier_token = consumeToken();
if (LA() == T_LPAREN) {
attr->lparen_token = consumeToken();
@@ -3837,7 +3860,7 @@ bool Parser::parseBuiltinTypeSpecifier(SpecifierListAST *&node)
{
DEBUG_THIS_RULE();
if (LA() == T___ATTRIBUTE__) {
- return parseAttributeSpecifier(node);
+ return parseGnuAttributeSpecifier(node);
} else if (LA() == T___TYPEOF__) {
TypeofSpecifierAST *ast = new (_pool) TypeofSpecifierAST;
ast->typeof_token = consumeToken();
@@ -3893,8 +3916,7 @@ bool Parser::parseSimpleDeclaration(DeclarationAST *&node, ClassSpecifierAST *de
spec->specifier_token = consumeToken();
*decl_specifier_seq_ptr = new (_pool) SpecifierListAST(spec);
decl_specifier_seq_ptr = &(*decl_specifier_seq_ptr)->next;
- } else if (LA() == T___ATTRIBUTE__) {
- parseAttributeSpecifier(*decl_specifier_seq_ptr);
+ } else if (parseAttributeSpecifier(*decl_specifier_seq_ptr)) {
decl_specifier_seq_ptr = &(*decl_specifier_seq_ptr)->next;
} else if (! named_type_specifier && ! has_complex_type_specifier && lookAtBuiltinTypeSpecifier()) {
parseBuiltinTypeSpecifier(*decl_specifier_seq_ptr);
@@ -5609,7 +5631,7 @@ bool Parser::parseObjCInterface(DeclarationAST *&node,
DEBUG_THIS_RULE();
if (! attributes && LA() == T___ATTRIBUTE__) {
SpecifierListAST **attr = &attributes;
- while (parseAttributeSpecifier(*attr))
+ while (parseGnuAttributeSpecifier(*attr))
attr = &(*attr)->next;
}
@@ -5698,7 +5720,7 @@ bool Parser::parseObjCProtocol(DeclarationAST *&node,
DEBUG_THIS_RULE();
if (! attributes && LA() == T___ATTRIBUTE__) {
SpecifierListAST **attr = &attributes;
- while (parseAttributeSpecifier(*attr))
+ while (parseGnuAttributeSpecifier(*attr))
attr = &(*attr)->next;
}
@@ -6200,7 +6222,7 @@ bool Parser::parseObjCMethodPrototype(ObjCMethodPrototypeAST *&node)
}
SpecifierListAST **attr = &ast->attribute_list;
- while (parseAttributeSpecifier(*attr))
+ while (parseGnuAttributeSpecifier(*attr))
attr = &(*attr)->next;
node = ast;
@@ -6309,7 +6331,7 @@ bool Parser::parseObjCKeywordDeclaration(ObjCSelectorArgumentAST *&argument, Obj
parseObjCTypeName(node->type_name);
SpecifierListAST **attr = &node->attribute_list;
- while (parseAttributeSpecifier(*attr))
+ while (parseGnuAttributeSpecifier(*attr))
attr = &(*attr)->next;
SimpleNameAST *param_name = new (_pool) SimpleNameAST;
@@ -6509,7 +6531,7 @@ bool Parser::parseLambdaDeclarator(LambdaDeclaratorAST *&node)
match(T_RPAREN, &ast->rparen_token);
SpecifierListAST **attr = &ast->attributes;
- while (parseAttributeSpecifier(*attr))
+ while (parseGnuAttributeSpecifier(*attr))
attr = &(*attr)->next;
if (LA() == T_MUTABLE)
@@ -6533,7 +6555,7 @@ bool Parser::parseTrailingReturnType(TrailingReturnTypeAST *&node)
ast->arrow_token = consumeToken();
SpecifierListAST **attr = &ast->attributes;
- while (parseAttributeSpecifier(*attr))
+ while (parseGnuAttributeSpecifier(*attr))
attr = &(*attr)->next;
parseTrailingTypeSpecifierSeq(ast->type_specifier_list);
diff --git a/src/libs/3rdparty/cplusplus/Parser.h b/src/libs/3rdparty/cplusplus/Parser.h
index 10f8f6c542..05a600e04f 100644
--- a/src/libs/3rdparty/cplusplus/Parser.h
+++ b/src/libs/3rdparty/cplusplus/Parser.h
@@ -164,8 +164,10 @@ public:
bool parseTypeParameter(DeclarationAST *&node);
bool parseBuiltinTypeSpecifier(SpecifierListAST *&node);
- bool parseAttributeSpecifier(SpecifierListAST *&node);
- bool parseAttributeList(AttributeListAST *&node);
+ bool parseOptionalAttributeSpecifierSequence(SpecifierListAST *&attribute_list);
+ bool parseAttributeSpecifier(SpecifierListAST *&attribute_list);
+ bool parseGnuAttributeSpecifier(SpecifierListAST *&node);
+ bool parseGnuAttributeList(GnuAttributeListAST *&node);
bool parseDeclSpecifierSeq(SpecifierListAST *&node,
bool noStorageSpecifiers = false,
diff --git a/src/libs/cplusplus/FindUsages.cpp b/src/libs/cplusplus/FindUsages.cpp
index 813acc3ebc..0b776e30f4 100644
--- a/src/libs/cplusplus/FindUsages.cpp
+++ b/src/libs/cplusplus/FindUsages.cpp
@@ -348,14 +348,14 @@ void FindUsages::objCSelectorArgument(ObjCSelectorArgumentAST *ast)
// unsigned colon_token = ast->colon_token;
}
-bool FindUsages::visit(AttributeAST *ast)
+bool FindUsages::visit(GnuAttributeAST *ast)
{
(void) ast;
Q_ASSERT(!"unreachable");
return false;
}
-void FindUsages::attribute(AttributeAST *ast)
+void FindUsages::attribute(GnuAttributeAST *ast)
{
if (! ast)
return;
@@ -1971,12 +1971,12 @@ bool FindUsages::visit(SimpleSpecifierAST *ast)
return false;
}
-bool FindUsages::visit(AttributeSpecifierAST *ast)
+bool FindUsages::visit(GnuAttributeSpecifierAST *ast)
{
// unsigned attribute_token = ast->attribute_token;
// unsigned first_lparen_token = ast->first_lparen_token;
// unsigned second_lparen_token = ast->second_lparen_token;
- for (AttributeListAST *it = ast->attribute_list; it; it = it->next) {
+ for (GnuAttributeListAST *it = ast->attribute_list; it; it = it->next) {
this->attribute(it->value);
}
// unsigned first_rparen_token = ast->first_rparen_token;
diff --git a/src/libs/cplusplus/FindUsages.h b/src/libs/cplusplus/FindUsages.h
index 2d63c2a859..c09652da2c 100644
--- a/src/libs/cplusplus/FindUsages.h
+++ b/src/libs/cplusplus/FindUsages.h
@@ -95,7 +95,7 @@ protected:
void postfixDeclarator(PostfixDeclaratorAST *ast);
void objCSelectorArgument(ObjCSelectorArgumentAST *ast);
- void attribute(AttributeAST *ast);
+ void attribute(GnuAttributeAST *ast);
void declarator(DeclaratorAST *ast, Scope *symbol = 0);
void qtPropertyDeclarationItem(QtPropertyDeclarationItemAST *ast);
void qtInterfaceName(QtInterfaceNameAST *ast);
@@ -127,7 +127,7 @@ protected:
// AST
virtual bool visit(ObjCSelectorArgumentAST *ast);
- virtual bool visit(AttributeAST *ast);
+ virtual bool visit(GnuAttributeAST *ast);
virtual bool visit(DeclaratorAST *ast);
virtual bool visit(QtPropertyDeclarationItemAST *ast);
virtual bool visit(QtInterfaceNameAST *ast);
@@ -258,7 +258,7 @@ protected:
// SpecifierAST
virtual bool visit(SimpleSpecifierAST *ast);
- virtual bool visit(AttributeSpecifierAST *ast);
+ virtual bool visit(GnuAttributeSpecifierAST *ast);
virtual bool visit(TypeofSpecifierAST *ast);
virtual bool visit(DecltypeSpecifierAST *ast);
virtual bool visit(ClassSpecifierAST *ast);
diff --git a/tests/auto/cplusplus/ast/tst_ast.cpp b/tests/auto/cplusplus/ast/tst_ast.cpp
index 05712ce5f3..1cd04ce471 100644
--- a/tests/auto/cplusplus/ast/tst_ast.cpp
+++ b/tests/auto/cplusplus/ast/tst_ast.cpp
@@ -207,12 +207,12 @@ void tst_AST::gcc_attributes_2()
QVERIFY(ns->attribute_list);
QVERIFY(!ns->attribute_list->next);
QVERIFY(ns->attribute_list->value);
- AttributeSpecifierAST *attrSpec = ns->attribute_list->value->asAttributeSpecifier();
+ GnuAttributeSpecifierAST *attrSpec = ns->attribute_list->value->asGnuAttributeSpecifier();
QVERIFY(attrSpec);
QVERIFY(attrSpec->attribute_list);
QVERIFY(!attrSpec->attribute_list->next);
QVERIFY(attrSpec->attribute_list->value);
- AttributeAST *attr = attrSpec->attribute_list->value->asAttribute();
+ GnuAttributeAST *attr = attrSpec->attribute_list->value->asGnuAttribute();
QVERIFY(attr);
QCOMPARE(unit->spell(attr->identifier_token), "__visibility__");
QVERIFY(attr->expression_list);
@@ -1371,13 +1371,13 @@ void tst_AST::objc_method_attributes_1()
QVERIFY(foo->attribute_list);
QVERIFY(foo->attribute_list->value);
QVERIFY(! (foo->attribute_list->next));
- AttributeSpecifierAST *deprecatedSpec = foo->attribute_list->value->asAttributeSpecifier();
+ GnuAttributeSpecifierAST *deprecatedSpec = foo->attribute_list->value->asGnuAttributeSpecifier();
QVERIFY(deprecatedSpec);
QCOMPARE(unit->tokenKind(deprecatedSpec->attribute_token), (int) T___ATTRIBUTE__);
QVERIFY(deprecatedSpec->attribute_list);
QVERIFY(deprecatedSpec->attribute_list->value);
QVERIFY(! (deprecatedSpec->attribute_list->next));
- AttributeAST *deprecatedAttr = deprecatedSpec->attribute_list->value->asAttribute();
+ GnuAttributeAST *deprecatedAttr = deprecatedSpec->attribute_list->value->asGnuAttribute();
QVERIFY(deprecatedAttr);
QVERIFY(! deprecatedAttr->expression_list);
QCOMPARE(unit->spell(deprecatedAttr->identifier_token), "deprecated");
@@ -1399,13 +1399,13 @@ void tst_AST::objc_method_attributes_1()
QVERIFY(bar->attribute_list);
QVERIFY(bar->attribute_list->value);
QVERIFY(! (bar->attribute_list->next));
- AttributeSpecifierAST *unavailableSpec = bar->attribute_list->value->asAttributeSpecifier();
+ GnuAttributeSpecifierAST *unavailableSpec = bar->attribute_list->value->asGnuAttributeSpecifier();
QVERIFY(unavailableSpec);
QCOMPARE(unit->tokenKind(unavailableSpec->attribute_token), (int) T___ATTRIBUTE__);
QVERIFY(unavailableSpec->attribute_list);
QVERIFY(unavailableSpec->attribute_list->value);
QVERIFY(! (unavailableSpec->attribute_list->next));
- AttributeAST *unavailableAttr = unavailableSpec->attribute_list->value->asAttribute();
+ GnuAttributeAST *unavailableAttr = unavailableSpec->attribute_list->value->asGnuAttribute();
QVERIFY(unavailableAttr);
QVERIFY(! unavailableAttr->expression_list);
QCOMPARE(unit->spell(unavailableAttr->identifier_token), "unavailable");
diff --git a/tests/auto/cplusplus/cxx11/data/alignofAlignas.1.cpp b/tests/auto/cplusplus/cxx11/data/alignofAlignas.1.cpp
index 5ba43661ed..05768769f6 100644
--- a/tests/auto/cplusplus/cxx11/data/alignofAlignas.1.cpp
+++ b/tests/auto/cplusplus/cxx11/data/alignofAlignas.1.cpp
@@ -1,2 +1,8 @@
int i = alignof(int);
int t = alignof(C::foo) * 7 + alignof(Foo *);
+
+struct alignas(f()) Foo {};
+struct alignas(42) Foo {};
+struct alignas(double) Bar {};
+alignas(Foo) alignas(Bar) Foo *buffer;
+struct alignas(Mooze...) Gnarf {};
diff --git a/tests/auto/cplusplus/findusages/tst_findusages.cpp b/tests/auto/cplusplus/findusages/tst_findusages.cpp
index 2235034c31..97162be99a 100644
--- a/tests/auto/cplusplus/findusages/tst_findusages.cpp
+++ b/tests/auto/cplusplus/findusages/tst_findusages.cpp
@@ -115,6 +115,8 @@ private Q_SLOTS:
void usingInDifferentNamespace_QTCREATORBUG7978();
void unicodeIdentifier();
+
+ void inAlignas();
};
void tst_FindUsages::dump(const QList<Usage> &usages) const
@@ -984,5 +986,36 @@ void tst_FindUsages::unicodeIdentifier()
QCOMPARE(usages.at(1).len, 7);
}
+void tst_FindUsages::inAlignas()
+{
+ const QByteArray src = "\n"
+ "struct One {};\n"
+ "struct alignas(One) Two {};\n"
+ ;
+
+ Document::Ptr doc = Document::create("inAlignas");
+ doc->setUtf8Source(src);
+ doc->parse();
+ doc->check();
+
+ QVERIFY(doc->diagnosticMessages().isEmpty());
+ QCOMPARE(doc->globalSymbolCount(), 2U);
+
+ Snapshot snapshot;
+ snapshot.insert(doc);
+
+ Class *c = doc->globalSymbolAt(0)->asClass();
+ QVERIFY(c);
+ QCOMPARE(c->name()->identifier()->chars(), "One");
+
+ FindUsages find(src, doc, snapshot);
+ find(c);
+ QCOMPARE(find.usages().size(), 2);
+ QCOMPARE(find.usages()[0].line, 1);
+ QCOMPARE(find.usages()[0].col, 7);
+ QCOMPARE(find.usages()[1].line, 2);
+ QCOMPARE(find.usages()[1].col, 15);
+}
+
QTEST_APPLESS_MAIN(tst_FindUsages)
#include "tst_findusages.moc"
diff --git a/tests/tools/cplusplus-ast2png/dumpers.inc b/tests/tools/cplusplus-ast2png/dumpers.inc
index 5e901c386c..5e5bb1a10b 100644
--- a/tests/tools/cplusplus-ast2png/dumpers.inc
+++ b/tests/tools/cplusplus-ast2png/dumpers.inc
@@ -50,7 +50,21 @@ virtual bool visit(SimpleSpecifierAST *ast)
return false;
}
-virtual bool visit(AttributeSpecifierAST *ast)
+virtual bool visit(AlignmentSpecifierAST *ast)
+{
+ if (ast->align_token)
+ terminal(ast->align_token, ast);
+ if (ast->lparen_token)
+ terminal(ast->lparen_token, ast);
+ nonterminal(ast->typeIdExprOrAlignmentExpr);
+ if (ast->ellipses_token)
+ terminal(ast->ellipses_token, ast);
+ if (ast->rparen_token)
+ terminal(ast->rparen_token, ast);
+ return false;
+}
+
+virtual bool visit(GnuAttributeSpecifierAST *ast)
{
if (ast->attribute_token)
terminal(ast->attribute_token, ast);
@@ -58,7 +72,7 @@ virtual bool visit(AttributeSpecifierAST *ast)
terminal(ast->first_lparen_token, ast);
if (ast->second_lparen_token)
terminal(ast->second_lparen_token, ast);
- for (AttributeListAST *iter = ast->attribute_list; iter; iter = iter->next)
+ for (GnuAttributeListAST *iter = ast->attribute_list; iter; iter = iter->next)
nonterminal(iter->value);
if (ast->first_rparen_token)
terminal(ast->first_rparen_token, ast);
@@ -67,7 +81,7 @@ virtual bool visit(AttributeSpecifierAST *ast)
return false;
}
-virtual bool visit(AttributeAST *ast)
+virtual bool visit(GnuAttributeAST *ast)
{
if (ast->identifier_token)
terminal(ast->identifier_token, ast);