Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2015-02-14 03:42:41 +0000
committerNathan Ridge2015-02-14 03:42:41 +0000
commit5e2c5d849123bb6de19c87a941213b66f26b83a9 (patch)
tree14b673c6b6d41b3ea0205f84d29ffb0da41f95f8
parent04f7079574b88c3927327e0df20e09a80bb90a67 (diff)
downloadorg.eclipse.cdt-5e2c5d849123bb6de19c87a941213b66f26b83a9.tar.gz
org.eclipse.cdt-5e2c5d849123bb6de19c87a941213b66f26b83a9.tar.xz
org.eclipse.cdt-5e2c5d849123bb6de19c87a941213b66f26b83a9.zip
Bug 459940 - Sfinae in id-expression
Change-Id: I6cfaf2af680c3b41571d4714f9a5511ff81af42b Signed-off-by: Nathan Ridge <zeratul976@hotmail.com>
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java25
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalFixed.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/EvalID.java2
4 files changed, 36 insertions, 2 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 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<typename _From>
+ // struct is_convertible {};
+ //
+ // class function {
+ // public:
+ // template<typename _Functor, bool = is_convertible<_Functor>::type::value>
+ // function(_Functor);
+ // };
+ //
+ // class A {};
+ //
+ // struct B {
+ // B(const char* s);
+ // };
+ //
+ // template <class T> void waldo(const B& b);
+ // template <class T> void waldo(function f);
+ //
+ // void test() {
+ // waldo<A>(""); // problem on waldo
+ // }
+ public void testSfinaeInIdExpression_459940() throws Exception {
+ parseAndCheckBindings();
+ }
+
// template <typename>
// struct M {
// template <typename... Args>
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("<unknown>".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("<error>".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;

Back to the top