Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorNathan Ridge2018-11-08 19:54:31 -0500
committerNathan Ridge2018-11-15 21:47:11 -0500
commitb6c1a085d1dfa1579dfc23e160eb97fd4d620be3 (patch)
tree74128edb3724680b8caf1b31b8700d92c6c3cda3 /core
parentef2b34f148e7f6be1e91273754dd9a2f869cf49e (diff)
downloadorg.eclipse.cdt-b6c1a085d1dfa1579dfc23e160eb97fd4d620be3.tar.gz
org.eclipse.cdt-b6c1a085d1dfa1579dfc23e160eb97fd4d620be3.tar.xz
org.eclipse.cdt-b6c1a085d1dfa1579dfc23e160eb97fd4d620be3.zip
Bug 540909 - underlying_type of typedef to enum
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java17
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TypeTraits.java5
2 files changed, 21 insertions, 1 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 65c9ce2333..f7527052e5 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 <typename T>
+ // struct underlying_type {
+ // typedef __underlying_type(T) type;
+ // };
+ //
+ // enum class FooBar { Foo, Bar };
+ // using Alias = FooBar;
+ //
+ // void bar(underlying_type<Alias>::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 470999d33f..37fd0d20d5 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;

Back to the top