From 3e81f0437c5bc4ff075a9207c0c2430c7140cc88 Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Wed, 11 Nov 2015 02:45:25 -0500 Subject: [PATCH] Bug 475894 - Forward declaration of enum at class scope Change-Id: I51e9bc36350dd403514ce5ec3d48ddb4f456102b Signed-off-by: Nathan Ridge --- .../cdt/core/parser/tests/ast2/AST2CPPTests.java | 12 ++++++++++++ .../internal/core/dom/parser/DeclarationOptions.java | 2 +- .../core/dom/parser/cpp/GNUCPPSourceParser.java | 4 +++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index 3cc0a6c8e5f..30d101cbead 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -9042,6 +9042,18 @@ public class AST2CPPTests extends AST2TestBase { String code= getAboveComment(); parseAndCheckBindings(code); } + + // typedef int Int; + // struct S { + // enum waldo1 : int; + // enum waldo2 : Int; + // }; + // enum S::waldo1 : int { + // someConstant = 1508 + // }; + public void testForwardDeclaringEnumAtClassScope_475894() throws Exception { + parseAndCheckBindings(); + } // struct S { // int m; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java index b48d03820b7..42cc44d0d10 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/DeclarationOptions.java @@ -35,7 +35,7 @@ public class DeclarationOptions { GLOBAL= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | ALLOW_OPAQUE_ENUM | ALLOW_FUNCTION_DEFINITION), FUNCTION_STYLE_ASM= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | NO_INITIALIZER | ALLOW_ABSTRACT | ALLOW_FUNCTION_DEFINITION), C_MEMBER= new DeclarationOptions(ALLOW_BITFIELD | ALLOW_ABSTRACT), - CPP_MEMBER= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | ALLOW_BITFIELD | NO_CTOR_STYLE_INITIALIZER | ALLOW_FUNCTION_DEFINITION), + CPP_MEMBER= new DeclarationOptions(ALLOW_EMPTY_SPECIFIER | ALLOW_BITFIELD | ALLOW_OPAQUE_ENUM | NO_CTOR_STYLE_INITIALIZER | ALLOW_FUNCTION_DEFINITION), LOCAL= new DeclarationOptions(ALLOW_OPAQUE_ENUM), PARAMETER= new DeclarationOptions(ALLOW_ABSTRACT | ALLOW_PARAMETER_PACKS | REQUIRE_SIMPLE_NAME | NO_BRACED_INITIALIZER | NO_CTOR_STYLE_INITIALIZER), TYPEID= new DeclarationOptions(REQUIRE_ABSTRACT | NO_INITIALIZER), 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 7cb113fcf2f..d0cc7208ab5 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 @@ -3447,7 +3447,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { attributes = CollectionUtils.merge(attributes, attributeSpecifierSeq()); if (isScoped || LT(1) == IToken.tIDENTIFIER) { - name= identifier(); + // A qualified-name can appear here if an enumeration declared at class scope is + // being defined out of line. + name= qualifiedName(); endOffset= calculateEndOffset(name); }