Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2017-05-08 06:09:01 +0000
committerNathan Ridge2017-05-13 03:28:11 +0000
commit9b809b0ad7aec5ed58495571c7caa0bbc115903c (patch)
treece122f44cf8d511cc762a335c988fa117d0fb5be
parent9c0d9fec08758435dd7622da729f540fe00ba12a (diff)
downloadorg.eclipse.cdt-9b809b0ad7aec5ed58495571c7caa0bbc115903c.tar.gz
org.eclipse.cdt-9b809b0ad7aec5ed58495571c7caa0bbc115903c.tar.xz
org.eclipse.cdt-9b809b0ad7aec5ed58495571c7caa0bbc115903c.zip
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
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java21
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java2
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<typename T> struct A {
@@ -10112,6 +10111,24 @@ public class AST2TemplateTests extends AST2TestBase {
parseAndCheckBindings();
}
+ // class C {};
+ //
+ // void aux(C);
+ //
+ // template<typename T>
+ // 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 <typename, typename>
// 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);
}

Back to the top