From 882f8e95a9fbc2eac146d57d078a32a822430faa Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Mon, 8 May 2017 02:59:52 -0400 Subject: [PATCH] Bug 516291 - Improve propagattion of instantiate failures through EvalFunctionCall and EvalComma Change-Id: Ieafe15a88c3838d15aaaf9043199ae2caf1c31db --- .../parser/tests/ast2/AST2TemplateTests.java | 20 ++++++++++++++++++- .../dom/parser/cpp/semantics/EvalComma.java | 4 ++++ .../cpp/semantics/EvalFunctionCall.java | 5 +++++ 3 files changed, 28 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 c0a010b010b..45edc4edc2a 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 @@ -10125,7 +10125,25 @@ public class AST2TemplateTests extends AST2TestBase { // int main() { // waldo(foo(0)); // Error here // } - public void testSFINAEInDecltype_516291() throws Exception { + public void testSFINAEInDecltype_516291a() throws Exception { + parseAndCheckBindings(); + } + + // class C {}; + // + // void aux(C); + // + // template + // decltype(aux(T()), C()) foo(T); + // + // int foo(...); + // + // void waldo(int); + // + // int main() { + // waldo(foo(0)); // Error here + // } + public void testSFINAEInDecltype_516291b() throws Exception { parseAndCheckBindings(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java index 6233706911a..1f924f9c3d3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalComma.java @@ -199,6 +199,10 @@ public class EvalComma extends CPPDependentEvaluation { for (int i = 0; i < fArguments.length; i++) { ICPPEvaluation arg = fArguments[i].instantiate(context, maxDepth); if (arg != fArguments[i]) { + // Propagate instantiation errors for SFINAE purposes. + if (arg == EvalFixed.INCOMPLETE) { + return arg; + } if (args == fArguments) { args = new ICPPEvaluation[fArguments.length]; System.arraycopy(fArguments, 0, args, 0, fArguments.length); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java index d5d57133134..73136a9b3c0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFunctionCall.java @@ -224,6 +224,11 @@ public final class EvalFunctionCall extends CPPDependentEvaluation { // Resolve the function using the parameters of the function call. EvalFunctionSet functionSet = (EvalFunctionSet) args[0]; args[0] = functionSet.resolveFunction(Arrays.copyOfRange(args, 1, args.length), context.getPoint()); + + // Propagate instantiation errors for SFINAE purposes. + if (args[0] == EvalFixed.INCOMPLETE) { + return args[0]; + } } ICPPEvaluation newImplicitThis = fImplicitThis != null ? fImplicitThis.instantiate(context, maxDepth) : null;