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 2008a13a293..63044426531 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 @@ -7561,6 +7561,31 @@ public class AST2TemplateTests extends AST2TestBase { parseAndCheckBindings(); } + // template + // struct is_convertible {}; + // + // class function { + // public: + // template::type::value> + // function(_Functor); + // }; + // + // class A {}; + // + // struct B { + // B(const char* s); + // }; + // + // template void waldo(const B& b); + // template void waldo(function f); + // + // void test() { + // waldo(""); // problem on waldo + // } + public void testSfinaeInIdExpression_459940() throws Exception { + parseAndCheckBindings(); + } + // template // struct M { // template diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java index a364c4c22be..ac72bf97e20 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java @@ -85,7 +85,12 @@ import org.eclipse.core.runtime.CoreException; */ public class Value implements IValue { public static final int MAX_RECURSION_DEPTH = 25; + // Value.UNKNOWN indicates general inability to determine a value. It doesn't have to be an error, + // it could be that evaluation ran into a performance limit, or that we can't model this kind of + // value (such as a pointer to a function). public static final Value UNKNOWN= new Value("".toCharArray(), null); //$NON-NLS-1$ + // Value.ERROR indicates that an error, such as a substitution failure, occurred during evaluation. + public static final Value ERROR= new Value("".toCharArray(), null); //$NON-NLS-1$ public static final Value NOT_INITIALIZED= new Value("<__>".toCharArray(), null); //$NON-NLS-1$ private static final IType INT_TYPE= new CPPBasicType(ICPPBasicType.Kind.eInt, 0); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java index 877fa763b01..3d69847c864 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java @@ -34,7 +34,7 @@ import org.eclipse.core.runtime.CoreException; */ public class EvalFixed extends CPPEvaluation { public static final ICPPEvaluation INCOMPLETE = - new EvalFixed(ProblemType.UNKNOWN_FOR_EXPRESSION, PRVALUE, Value.UNKNOWN); + new EvalFixed(ProblemType.UNKNOWN_FOR_EXPRESSION, PRVALUE, Value.ERROR); private final IType fType; private final IValue fValue; @@ -170,6 +170,10 @@ public class EvalFixed extends CPPEvaluation { IValue value = CPPTemplates.instantiateValue(fValue, tpMap, packOffset, within, maxdepth, point); if (type == fType && value == fValue) return this; + // If an error occurred while instantiating the value (such as a substitution failure), + // propagate that error. + if (value == Value.ERROR) + return EvalFixed.INCOMPLETE; return new EvalFixed(type, fValueCategory, value); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java index 77c442ec60f..e89cdf1da66 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java @@ -342,7 +342,7 @@ public class EvalID extends CPPDependentEvaluation { } if (fieldOwner instanceof IProblemBinding || nameOwner instanceof IProblemBinding) - return this; + return EvalFixed.INCOMPLETE; if (templateArgs == fTemplateArgs && fieldOwner == fFieldOwner && nameOwner == fNameOwner) return this;