summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-05-26 16:24:07 (EDT)
committer Sergey Prigogin2013-05-26 18:40:25 (EDT)
commit2d97fb20b72e858e30ef6239ea215085cb868824 (patch)
tree45317c8665ff1960c5d8f52374a578eec50308c5
parent255cd71f24199f74c3c0c060c5720070ff010bcb (diff)
downloadorg.eclipse.cdt-2d97fb20b72e858e30ef6239ea215085cb868824.zip
org.eclipse.cdt-2d97fb20b72e858e30ef6239ea215085cb868824.tar.gz
org.eclipse.cdt-2d97fb20b72e858e30ef6239ea215085cb868824.tar.bz2
Bug 409078 - Type resolution failure involving templates and inheritancerefs/changes/62/13162/3
Change-Id: I2764c7a6a1121bd35cd8c025388949948eed6e0e Reviewed-on: https://git.eclipse.org/r/13162 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java21
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/AbstractCPPClassSpecializationScope.java6
2 files changed, 26 insertions, 1 deletions
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 163aeeb..e41264c 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 <typename T>
+ // struct id {
+ // typedef T type;
+ // };
+ //
+ // template <typename T>
+ // struct B {
+ // struct base : id<id<T>> {};
+ //
+ // typedef typename base::type base2;
+ //
+ // struct result : base2 {};
+ // };
+ //
+ // typedef B<int>::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 ff98ac8..070c5a6 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);