From dd7dde956f0c260a24b0fc793fb0246b51f24685 Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Sun, 15 Dec 2013 02:03:34 -0500 Subject: [PATCH] Bug 417700 - Semantic Error: Invalid overload of 'endl' for a templated parameter Change-Id: Icd110a386421d9d5cc9502dd8d4cd56328119a77 Signed-off-by: Nathan Ridge Reviewed-on: https://git.eclipse.org/r/19834 Reviewed-by: Sergey Prigogin IP-Clean: Sergey Prigogin Tested-by: Sergey Prigogin --- .../parser/tests/ast2/AST2TemplateTests.java | 20 +++++++++++++++++++ .../parser/cpp/semantics/CPPSemantics.java | 8 +++++++- 2 files changed, 27 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 1859e3cfdfe..423fd5011a8 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 @@ -5375,6 +5375,26 @@ public class AST2TemplateTests extends AST2TestBase { assertSame(method, ((ICPPSpecialization) reference).getSpecializedBinding()); } + // template + // struct ostream { + // template + // ostream& operator<<(T); + // + // ostream& operator<<(ostream&(*)(ostream&)); + // }; + // + // template + // ostream& endl(ostream&); + // + // template + // void test(T t) { + // ostream out; + // out << t << endl; + // } + public void testInstantiationOfEndlInTemplate_417700() throws Exception { + parseAndCheckBindings(); + } + // template bool MySort(const T& a); // bool MySort(const int& a); // template void sort(V __comp); 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 ecd3b3dbc9d..4bb8ffe430b 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 @@ -2987,7 +2987,7 @@ public class CPPSemantics { } } } - if (targetType == null && parent instanceof IASTExpression + if (targetType == null && parent instanceof ICPPASTExpression && parent instanceof IASTImplicitNameOwner) { // Trigger resolution of overloaded operator, which may resolve the // function set. @@ -2995,6 +2995,12 @@ public class CPPSemantics { final IBinding newBinding = name.getPreBinding(); if (!(newBinding instanceof CPPFunctionSet)) return newBinding; + + // If we're in a dependent context, we don't have enough information + // to resolve the function set. + if (((ICPPASTExpression) parent).getEvaluation().isTypeDependent()) { + return CPPDeferredFunction.createForCandidates(functionSet.getBindings()); + } } ICPPFunction function = resolveTargetedFunction(targetType, functionSet, name);