summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2013-12-14 00:54:35 (EST)
committerSergey Prigogin2013-12-16 00:41:35 (EST)
commit7f3095be514c9055f906b74e045810cca226cc46 (patch)
tree47f7127404528d3839e01c6ab31cd1e8eba99689
parentc126fade3dda65e54ec6ca13750218fb023b1410 (diff)
downloadorg.eclipse.cdt-7f3095be514c9055f906b74e045810cca226cc46.zip
org.eclipse.cdt-7f3095be514c9055f906b74e045810cca226cc46.tar.gz
org.eclipse.cdt-7f3095be514c9055f906b74e045810cca226cc46.tar.bz2
Bug 422505 - Name resolution problem with template friend methodrefs/changes/25/19825/2
Change-Id: I1cb70755042572272cb38382795caa98f9d463ff Signed-off-by: Nathan Ridge <zeratul976@hotmail.com> Reviewed-on: https://git.eclipse.org/r/19825 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.java16
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java6
2 files changed, 22 insertions, 0 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 00e6615..a8a9377 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
@@ -8164,4 +8164,20 @@ public class AST2TemplateTests extends AST2TestBase {
public void testSpecializedEnumerator_418770() throws Exception {
parseAndCheckBindings();
}
+
+ // template <typename T>
+ // class A;
+ //
+ // namespace ns {
+ // template <typename T>
+ // int waldo(const A<T>&);
+ // }
+ //
+ // template <typename T>
+ // class A {
+ // friend int ns::waldo<T>(const A<T>&);
+ // };
+ public void testDependentSpecializationOfFunctionTemplateAsFriend_422505() throws Exception {
+ parseAndCheckBindings();
+ }
}
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 f234363..ecd3b3d 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
@@ -2648,6 +2648,12 @@ public class CPPSemantics {
for (ICPPFunction fn : fns) {
if (fn instanceof ICPPFunctionTemplate
&& !(fn instanceof IProblemBinding) && !(fn instanceof ICPPUnknownBinding)) {
+ // If the declared function type is dependent, there is no point trying to use it
+ // to instantiate the template, so return a deferred function instead.
+ // Note that CPPTemplates.instantiateForFunctionCall() behaves similarly.
+ if (CPPTemplates.isDependentType(ft)) {
+ return CPPDeferredFunction.createForCandidates(fns);
+ }
ICPPFunctionTemplate template= (ICPPFunctionTemplate) fn;
ICPPFunction inst= CPPTemplates.instantiateForFunctionDeclaration(template, tmplArgs, ft, data.getLookupPoint());
if (inst != null) {