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 8458f0760f0..47fa031d0a6 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 @@ -5057,4 +5057,41 @@ public class AST2TemplateTests extends AST2BaseTest { assertSame(ft, inst.getTemplateDefinition()); assertSame(M, inst.getOwner()); } + + // template struct A { + // friend void f(A, T){} + // }; + // template void g(T t) { + // A at; + // f(at, t); + // } + // int main() { + // class X {} x; + // g(x); + // } + public void testUnnamedTypesAsTemplateArgument_316317a() throws Exception { + final String code= getAboveComment(); + parseAndCheckBindings(code); + } + + // template class X { }; + // template void f(T t) { } + // struct {} unnamed_obj; + // void f() { + // struct A { }; + // enum { e1 }; + // typedef struct {} B; + // B b; + // X x1; // OK + // X x2; // OK + // X x3; // OK + // f(e1); // OK + // f(unnamed_obj); // OK + // f(b); // OK + // } + public void testUnnamedTypesAsTemplateArgument_316317b() throws Exception { + final String code= getAboveComment(); + parseAndCheckBindings(code); + } + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java index 32142367b06..4d6ac8493e7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHQueries.java @@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ILinkage; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexName; @@ -129,15 +130,22 @@ public class CHQueries { for (IIndexName name : refs) { IBinding binding= index.findBinding(name); if (CallHierarchyUI.isRelevantForCallHierarchy(binding)) { - ICElement[] defs= null; - if (binding instanceof ICPPMethod) { - defs = findOverriders(index, (ICPPMethod) binding); - } - if (defs == null) { - defs= IndexUI.findRepresentative(index, binding); - } - if (defs != null && defs.length > 0) { - result.add(defs, name); + for(;;) { + ICElement[] defs= null; + if (binding instanceof ICPPMethod) { + defs = findOverriders(index, (ICPPMethod) binding); + } + if (defs == null) { + defs= IndexUI.findRepresentative(index, binding); + } + if (defs != null && defs.length > 0) { + result.add(defs, name); + } else if (binding instanceof ICPPSpecialization) { + binding= ((ICPPSpecialization) binding).getSpecializedBinding(); + if (binding != null) + continue; + } + break; } } }