Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java15
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java7
2 files changed, 20 insertions, 2 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
index 3f42935de6f..381c576ce28 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2Tests.java
@@ -29,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.EScopeKind;
import org.eclipse.cdt.core.dom.ast.ExpansionOverlapsBoundaryException;
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression;
+import org.eclipse.cdt.core.dom.ast.IASTAttributeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.IASTCaseStatement;
import org.eclipse.cdt.core.dom.ast.IASTCastExpression;
@@ -7783,4 +7784,18 @@ public class AST2Tests extends AST2TestBase {
assertNotNull(expr);
assertFalse(expr.getExpressionType() instanceof IProblemType);
}
+
+ // typedef struct __attribute__ ((__packed__)) {
+ // unsigned char a;
+ // unsigned char b;
+ // } example2_s;
+ public void testStructAttribute_467346() throws Exception {
+ BindingAssertionHelper helper = getAssertionHelper(C);
+ IASTDeclaration[] decls = helper.getTranslationUnit().getDeclarations();
+ assertEquals(1, decls.length);
+ assertInstance(decls[0], IASTSimpleDeclaration.class);
+ IASTDeclSpecifier declSpec = ((IASTSimpleDeclaration) decls[0]).getDeclSpecifier();
+ IASTAttributeSpecifier[] attributes = declSpec.getAttributeSpecifiers();
+ assertEquals(1, attributes.length);
+ }
}
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 78e0b3ebf80..88e1f9afc7a 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
@@ -1311,7 +1311,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
}
// if __attribute__ or __declspec occurs after struct/union/class and before the identifier
- __attribute_decl_seq(supportAttributeSpecifiers, supportDeclspecSpecifiers);
+ List<IASTAttributeSpecifier> attributes = __attribute_decl_seq(supportAttributeSpecifiers,
+ supportDeclspecSpecifiers);
// class name
IASTName name = null;
@@ -1320,7 +1321,8 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
}
// if __attribute__ or __declspec occurs after struct/union/class identifier and before the { or ;
- __attribute_decl_seq(supportAttributeSpecifiers, supportDeclspecSpecifiers);
+ attributes = CollectionUtils.merge(attributes,
+ __attribute_decl_seq(supportAttributeSpecifiers, supportDeclspecSpecifiers));
if (LT(1) != IToken.tLBRACE) {
IToken errorPoint = LA(1);
@@ -1333,6 +1335,7 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
}
ICASTCompositeTypeSpecifier result = getNodeFactory().newCompositeTypeSpecifier(classKind, name);
declarationListInBraces(result, offset, DeclarationOptions.C_MEMBER);
+ addAttributeSpecifiers(attributes, result);
return result;
}

Back to the top