summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2018-05-04 01:29:59 -0400
committerNathan Ridge2018-05-10 22:47:34 -0400
commitd8d04e27317a25d52d0a27f51794f674b8962f60 (patch)
tree1f5553420e2588e6a51b7fb69dc22e7888668c51
parent3ad16b909ce95580136743f59c539fa5f41f27ea (diff)
downloadorg.eclipse.cdt-d8d04e27317a25d52d0a27f51794f674b8962f60.tar.gz
org.eclipse.cdt-d8d04e27317a25d52d0a27f51794f674b8962f60.tar.xz
org.eclipse.cdt-d8d04e27317a25d52d0a27f51794f674b8962f60.zip
Bug 534332 - Allow C decl-specifiers to store attributes
The parser already accepted this, but the attributes were not stored in the AST. Change-Id: I7118eaff9dd150f15885f0aabb8a3b5e707394b0
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclSpecifier.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclSpecifier.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBaseDeclSpecifier.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java2
5 files changed, 8 insertions, 7 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclSpecifier.java
index 6980d6d89b..4124fb6b5e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTDeclSpecifier.java
@@ -17,7 +17,7 @@ package org.eclipse.cdt.core.dom.ast;
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
-public interface IASTDeclSpecifier extends IASTNode {
+public interface IASTDeclSpecifier extends IASTAttributeOwner {
/**
* No storage class specified.
*/
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclSpecifier.java
index 0f94581b1b..407aebe235 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPASTDeclSpecifier.java
@@ -12,7 +12,6 @@
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast.cpp;
-import org.eclipse.cdt.core.dom.ast.IASTAttributeOwner;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
/**
@@ -21,7 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/
-public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier, IASTAttributeOwner {
+public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier {
// A declaration in C++ can be a friend declaration
/**
* Is this a friend declaration?
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBaseDeclSpecifier.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBaseDeclSpecifier.java
index 62ce1aef62..43df78ffaa 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBaseDeclSpecifier.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTBaseDeclSpecifier.java
@@ -14,14 +14,14 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.IASTAlignmentSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier;
-import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
+import org.eclipse.cdt.internal.core.dom.parser.ASTAttributeOwner;
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
/**
* @author jcamelon
*/
-public abstract class CASTBaseDeclSpecifier extends ASTNode
+public abstract class CASTBaseDeclSpecifier extends ASTAttributeOwner
implements ICASTDeclSpecifier, IASTAmbiguityParent {
protected int storageClass;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
index 515c6ee5d6..7d5aeac2c0 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java
@@ -922,6 +922,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
ICASTDeclSpecifier result= null;
ICASTDeclSpecifier altResult= null;
IASTAlignmentSpecifier[] alignmentSpecifiers = IASTAlignmentSpecifier.EMPTY_ALIGNMENT_SPECIFIER_ARRAY;
+ List<IASTAttributeSpecifier> attributes = null;
try {
IASTName identifier= null;
IASTExpression typeofExpression= null;
@@ -1151,7 +1152,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
case IGCCToken.t__attribute__: // if __attribute__ is after the declSpec
if (!supportAttributeSpecifiers)
throwBacktrack(LA(1));
- __attribute_decl_seq(true, false);
+ attributes = CollectionUtils.merge(attributes, __attribute_decl_seq(true, false));
break;
case IGCCToken.t__declspec: // __declspec precedes the identifier
if (identifier != null || !supportDeclspecSpecifiers)
@@ -1212,6 +1213,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
result= buildSimpleDeclSpec(storageClass, simpleType, options, isLong, typeofExpression, offset, endOffset);
}
result.setAlignmentSpecifiers(ArrayUtil.trim(alignmentSpecifiers));
+ addAttributeSpecifiers(attributes, result);
} catch (BacktrackException e) {
if (returnToken != null) {
backup(returnToken);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
index cbb9a201db..a4614670d4 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java
@@ -3065,7 +3065,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
declarator= addInitializer(lie, DeclarationOptions.PARAMETER);
}
- addAttributeSpecifiers(attributes, (ICPPASTDeclSpecifier) declSpec);
+ addAttributeSpecifiers(attributes, declSpec);
final ICPPASTParameterDeclaration parm = getNodeFactory().newParameterDeclaration(declSpec, declarator);
final int endOffset = figureEndOffset(declSpec, declarator);