From b6c1a085d1dfa1579dfc23e160eb97fd4d620be3 Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Thu, 8 Nov 2018 19:54:31 -0500 Subject: [PATCH] Bug 540909 - underlying_type of typedef to enum Change-Id: Ic4f48c4da79419d5404e132da2944ee2823ca41f --- .../core/parser/tests/ast2/AST2CPPTests.java | 17 +++++++++++++++++ .../dom/parser/cpp/semantics/TypeTraits.java | 5 ++++- 2 files changed, 21 insertions(+), 1 deletion(-) 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 65c9ce2333b..f7527052e51 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 @@ -11346,6 +11346,23 @@ public class AST2CPPTests extends AST2CPPTestBase { assertSameType((ITypedef) helper.assertNonProblem("loong_type"), CPPBasicType.LONG); } + // template + // struct underlying_type { + // typedef __underlying_type(T) type; + // }; + // + // enum class FooBar { Foo, Bar }; + // using Alias = FooBar; + // + // void bar(underlying_type::type); + // + // void test() { + // bar(2); + // } + public void testUnderlyingType_540909() throws Exception { + parseAndCheckBindings(getAboveComment(), CPP, true /* use GNU extensions */); + } + // void ptrFunc(void*); // void intFunc(int); // void foo(int* pi, unsigned i) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeTraits.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeTraits.java index 470999d33f9..37fd0d20d51 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeTraits.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeTraits.java @@ -475,7 +475,10 @@ public class TypeTraits { public static IType underlyingType(IType type) { if (CPPTemplates.isDependentType(type)) { return new CPPUnaryTypeTransformation(Operator.underlying_type, type); - } else if (!(type instanceof ICPPEnumeration)) { + } + + type = SemanticUtil.getSimplifiedType(type); + if (!(type instanceof ICPPEnumeration)) { return ProblemType.ENUMERATION_EXPECTED; } else { ICPPEnumeration enumeration = (ICPPEnumeration) type;