From 2cf4f5acdf66bfe3b05270b08d0dea1257138c56 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Wed, 4 Mar 2009 13:32:32 +0000 Subject: [PATCH] Parent scope of specializations based on index, bug 267013. --- .../index/tests/IndexCPPTemplateResolutionTest.java | 12 ++++++++++++ .../core/dom/parser/cpp/semantics/CPPSemantics.java | 11 ++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java index a311cb41942..de99ebd017e 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java @@ -1576,4 +1576,16 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa public void testDefaultTemplateArgInHeader_264988() throws Exception { ICPPTemplateInstance ti= getBindingFromASTName("XT<>", 4, ICPPTemplateInstance.class); } + + // typedef int TInt; + // template class XT { + // void m(); + // }; + + // template<> void XT::m() { + // TInt t; + // } + public void testParentScopeOfSpecialization_267013() throws Exception { + ITypedef ti= getBindingFromASTName("TInt", 4, ITypedef.class); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index 9b7325c4b02..69b8a392789 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -162,6 +162,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUsingDeclaration; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUsingDirective; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVariable; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPASTInternalScope; +import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPClassSpecializationScope; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope; @@ -962,11 +963,11 @@ public class CPPSemantics { IScope parentScope= scope.getParent(); // the index cannot return the translation unit as parent scope if (unit != null) { - if (parentScope == null && scope instanceof IIndexScope) { - parentScope= unit.getScope(); - } - else if (parentScope instanceof IIndexScope) { - parentScope= unit.mapToASTScope((IIndexScope) parentScope); + if (parentScope == null + && (scope instanceof IIndexScope || scope instanceof ICPPClassSpecializationScope)) { + parentScope = unit.getScope(); + } else if (parentScope instanceof IIndexScope) { + parentScope = unit.mapToASTScope((IIndexScope) parentScope); } } return (ICPPScope) parentScope;