summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2012-12-05 21:21:46 (EST)
committer Sergey Prigogin2012-12-07 15:00:20 (EST)
commit6697364dcef7368c64fe375a08f32cd0b51a8666 (patch)
tree36870da69c1daf0f420947b648fcfbdac827ce08
parented818d803d0fbb89244f82315a8f8f82baeaa2bc (diff)
downloadorg.eclipse.cdt-6697364dcef7368c64fe375a08f32cd0b51a8666.zip
org.eclipse.cdt-6697364dcef7368c64fe375a08f32cd0b51a8666.tar.gz
org.eclipse.cdt-6697364dcef7368c64fe375a08f32cd0b51a8666.tar.bz2
Bug 388398 - SFINAE for default template arguments
Change-Id: Id4af11365046a57f997de0ee3715cf5ccef9d630 Reviewed-on: https://git.eclipse.org/r/9056 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java12
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java11
2 files changed, 22 insertions, 1 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 e7f3777..372773a 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
@@ -6883,4 +6883,16 @@ public class AST2TemplateTests extends AST2BaseTest {
assertEquals("bool", ASTTypeUtil.getType(td.getType()));
ah.assertProblem("B<int*>::type", "type");
}
+
+ // struct S {
+ // typedef int a_type;
+ // };
+ // template <typename T, typename = typename T::a_type> int foo(T);
+ // template <typename T, typename = typename T::b_type> void foo(T);
+ // int main() {
+ // foo(S());
+ // }
+ public void testSFINAEInDefaultArgument() throws Exception {
+ parseAndCheckBindings();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java
index 4813905..4233824 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java
@@ -36,6 +36,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
import org.eclipse.cdt.core.dom.ast.IPointerType;
import org.eclipse.cdt.core.dom.ast.IQualifierType;
+import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.IValue;
@@ -636,7 +637,15 @@ public class TemplateArgumentDeduction {
if (deducedArg != null) {
deducedArg= CPPTemplates.instantiateArgument(deducedArg, tpMap, -1, null, point);
if (deducedArg != null) {
- tpMap.put(tpar, deducedArg);
+ if (deducedArg instanceof CPPTemplateTypeArgument) {
+ CPPTemplateTypeArgument deducedTypeArg = (CPPTemplateTypeArgument) deducedArg;
+ if (!(deducedTypeArg.getTypeValue() instanceof ISemanticProblem)) {
+ tpMap.put(tpar, deducedArg);
+ }
+ } else {
+ // TODO: Check for problems in non-type or template template parameters?
+ tpMap.put(tpar, deducedArg);
+ }
}
}
}