From 9b809b0ad7aec5ed58495571c7caa0bbc115903c Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Mon, 8 May 2017 02:09:01 -0400 Subject: [PATCH] Bug 516291 - If a function call has dependent arguments, resolve the function name as a CPPDeferredFunction even if there is only one viable candidate This ensures that, when instantiating the function call, we get into EvalFunctionSet.resolveFunction(), and check that the function is actually callable with the instantiated argument types, and error out if it isn't (which is important for SFINAE purposes). Change-Id: Ia01755bc1a830fded1f61658f4beef875cc0b029 --- .../parser/tests/ast2/AST2TemplateTests.java | 21 +++++++++++++++++-- .../parser/cpp/semantics/CPPSemantics.java | 2 -- 2 files changed, 19 insertions(+), 4 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 f8147702a18..c0a010b010b 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 @@ -3916,8 +3916,7 @@ public class AST2TemplateTests extends AST2TestBase { bh.assertNonProblem("f(b)", 1, ICPPUnknownBinding.class, IFunction.class); bh.assertNonProblem("h(b)", 1, ICPPUnknownBinding.class, IFunction.class); bh.assertNonProblem("m(b)", 1, ICPPUnknownBinding.class, IFunction.class); - IFunction g= bh.assertNonProblem("g(b)", 1); - assertFalse(g instanceof ICPPUnknownBinding); + bh.assertNonProblem("g(b)", 1, ICPPUnknownBinding.class, IFunction.class); } // template struct A { @@ -10112,6 +10111,24 @@ public class AST2TemplateTests extends AST2TestBase { parseAndCheckBindings(); } + // class C {}; + // + // void aux(C); + // + // template + // decltype(aux(T())) foo(T); + // + // int foo(...); + // + // void waldo(int); + // + // int main() { + // waldo(foo(0)); // Error here + // } + public void testSFINAEInDecltype_516291() throws Exception { + parseAndCheckBindings(); + } + // template // struct is_same { // static constexpr bool value = false; 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 157fe372339..ece87713b22 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 @@ -2616,8 +2616,6 @@ public class CPPSemantics { // Check for dependent arguments fns= tmp; if (CPPTemplates.containsDependentType(argTypes)) { - if (viableCount == 1) - return fns[0]; setTargetedFunctionsToUnknown(argTypes); return CPPDeferredFunction.createForCandidates(fns); }