summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Ridge2012-12-05 21:21:46 (EST)
committerSergey Prigogin2012-12-06 14:47:51 (EST)
commit84c076ae460f0cb442d7c6105a1aa9828188789d (patch)
tree6520a10839ee196e14b762581e8656ca4f486936
parent370c25c50b1fd1bc57415ef5a023e903f11b0e19 (diff)
downloadorg.eclipse.cdt-84c076ae460f0cb442d7c6105a1aa9828188789d.zip
org.eclipse.cdt-84c076ae460f0cb442d7c6105a1aa9828188789d.tar.gz
org.eclipse.cdt-84c076ae460f0cb442d7c6105a1aa9828188789d.tar.bz2
Bug 388398 - SFINAE for default template arguments refs/changes/56/9056/4
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);
+ }
}
}
}