From 2d97fb20b72e858e30ef6239ea215085cb868824 Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Sun, 26 May 2013 16:24:07 -0400 Subject: Bug 409078 - Type resolution failure involving templates and inheritance Change-Id: I2764c7a6a1121bd35cd8c025388949948eed6e0e Reviewed-on: https://git.eclipse.org/r/13162 Reviewed-by: Sergey Prigogin IP-Clean: Sergey Prigogin Tested-by: Sergey Prigogin --- .../core/parser/tests/ast2/AST2TemplateTests.java | 21 +++++++++++++++++++++ .../cpp/AbstractCPPClassSpecializationScope.java | 6 +++++- 2 files changed, 26 insertions(+), 1 deletion(-) 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 163aeebf33c..e41264c9df1 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 @@ -6160,6 +6160,27 @@ public class AST2TemplateTests extends AST2TestBase { parseAndCheckBindings(); } + // template + // struct id { + // typedef T type; + // }; + // + // template + // struct B { + // struct base : id> {}; + // + // typedef typename base::type base2; + // + // struct result : base2 {}; + // }; + // + // typedef B::result::type waldo; + public void testSpecializationOfBaseClass_409078() throws Exception { + BindingAssertionHelper bh = getAssertionHelper(); + ITypedef waldo = bh.assertNonProblem("waldo"); + assertSameType(waldo.getType(), CommonTypes.int_); + } + //struct A { // int m(int i) const; // void m() const; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java index ff98ac89ceb..070c5a6224d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java @@ -155,7 +155,11 @@ public class AbstractCPPClassSpecializationScope implements ICPPClassSpecializat } if (origClass instanceof IType) { ICPPBase specBase = base.clone(); - IType specClass= CPPTemplates.instantiateType((IType) origClass, tpmap, -1, specialClass, point); + ICPPClassSpecialization specializationContext = specialClass; + if (specialClass.getOwner() instanceof ICPPClassSpecialization) { + specializationContext = (ICPPClassSpecialization) specialClass.getOwner(); + } + IType specClass= CPPTemplates.instantiateType((IType) origClass, tpmap, -1, specializationContext, point); specClass = SemanticUtil.getUltimateType(specClass, false); if (specClass instanceof IBinding && !(specClass instanceof IProblemBinding)) { specBase.setBaseClass((IBinding) specClass); -- cgit v1.2.3