From 469b2e8b588a83b4b45b00bd6fc7427a6ffa6248 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Sun, 25 Nov 2012 13:46:13 -0800 Subject: [PATCH] Bug 395026 - Name resolution problem with an alias template. --- .../parser/tests/ast2/AST2TemplateTests.java | 45 +++++++++++++++++++ .../parser/cpp/semantics/CPPTemplates.java | 4 ++ 2 files changed, 49 insertions(+) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index 4534aa6063a..f0dea6d3d14 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -6684,4 +6684,49 @@ public class AST2TemplateTests extends AST2BaseTest { assertTrue(AliasInt.getScope() instanceof ICPPTemplateScope); } + + // template + // struct A { + // template + // struct rebind { + // typedef A other; + // }; + // }; + // + // template + // struct B { + // typedef typename T::template rebind::other type1; + // }; + // + // template + // struct C { + // template + // using rebind2 = typename B::type1; + // }; + // + // template + // struct D : C { + // typedef int type0; + // + // template + // struct rebind { + // typedef typename C::template rebind2 other2; + // }; + // }; + // + // template + // struct E { + // typedef typename D::template rebind::other2 type2; + // typedef D type3; + // typedef typename type3::type0 type; + // }; + // + // void f(int x); + // + // void test(E>::type v) { + // f(v); + // } + public void testAliasTemplate_395026() throws Exception { + parseAndCheckBindings(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java index 42967469cc7..465d3a0e4ef 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java @@ -827,6 +827,10 @@ public class CPPTemplates { } else if (decl instanceof ITypedef) { IType type= instantiateType(((ITypedef) decl).getType(), tpMap, -1, getSpecializationContext(owner), point); spec = new CPPTypedefSpecialization(decl, owner, tpMap, type); + } else if (decl instanceof ICPPAliasTemplate) { + ICPPAliasTemplate aliasTemplate = (ICPPAliasTemplate) decl; + IType type= instantiateType(aliasTemplate.getType(), tpMap, -1, getSpecializationContext(owner), point); + spec = new CPPAliasTemplateInstance(decl.getNameCharArray(), type, aliasTemplate); } else if (decl instanceof IEnumeration || decl instanceof IEnumerator) { // TODO(sprigogin): Deal with a case when an enumerator value depends on a template parameter. spec = decl;