Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHannes Vogt2018-12-02 15:43:18 -0500
committerHannes Vogt2018-12-08 05:15:40 -0500
commit2fc42590fb8e9169941ce822ef7123e8b4f63690 (patch)
tree11efbf3bb66286648840b078c916ed1b59b72c6f /core/org.eclipse.cdt.core.tests
parent12207e79dba630db61194df723e199d86c2728b1 (diff)
downloadorg.eclipse.cdt-2fc42590fb8e9169941ce822ef7123e8b4f63690.tar.gz
org.eclipse.cdt-2fc42590fb8e9169941ce822ef7123e8b4f63690.tar.xz
org.eclipse.cdt-2fc42590fb8e9169941ce822ef7123e8b4f63690.zip
Bug 541717 - Partial ordering and DR1395
- As of [temp.func.order] p5 only parameters for which there are explicit arguments should be considered. - Implement [temp.deduct.partial] p11 (resolution of DR1395). Change-Id: I56262229a6fe4717c22aac814aa9ea42eb37a10d Signed-off-by: Hannes Vogt <hannes@havogt.de>
Diffstat (limited to 'core/org.eclipse.cdt.core.tests')
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java64
1 files changed, 62 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 e73f0ec9d8b..7872bd93ab5 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
@@ -4816,8 +4816,16 @@ public class AST2TemplateTests extends AST2CPPTestBase {
// int main() {
// foo(0);
// }
- public void testFunctionTemplateOrdering_388805() throws Exception {
- parseAndCheckBindings();
+ public void testFunctionTemplateOrdering_DR1395_388805() throws Exception {
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+
+ ICPPFunctionTemplate f1 = bh.assertNonProblem("foo(A)", 3);
+ ICPPFunctionTemplate f2 = bh.assertNonProblem("foo(A, B...)", 3);
+
+ ICPPTemplateInstance t;
+ t = bh.assertNonProblem("foo(0)", 3);
+ assertSame(f1, t.getTemplateDefinition());
}
// template <typename T>
@@ -11200,4 +11208,56 @@ public class AST2TemplateTests extends AST2CPPTestBase {
public void testDisambiguateFunctionWithDefaultArgumentDeclaration_541474() throws Exception {
parseAndCheckBindings();
}
+
+ // template<typename T>
+ // void info(T a) {
+ // }
+ // template<typename... Args>
+ // void info(int a, Args... args) {
+ // // this is more specialized
+ // }
+ // int main( ) {
+ // info(1);
+ // }
+ public void testDisambiguateFunctionUnusedPack_541474() throws Exception {
+ parseAndCheckBindings();
+ }
+
+ // template<typename A, typename B = int>
+ // void foo(A, B=0); // this overload is taken
+ //
+ // template<typename A, typename... B>
+ // void foo(A, B...);
+ //
+ // int main() {
+ // foo(0);
+ // }
+ public void testDisambiguateFunctionUnusedPackVsDefault_541474() throws Exception {
+ String code = getAboveComment();
+ BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP);
+
+ ICPPFunctionTemplate f1 = bh.assertNonProblem("foo(A, B=0)", 3);
+ ICPPFunctionTemplate f2 = bh.assertNonProblem("foo(A, B...)", 3);
+
+ ICPPTemplateInstance t;
+ t = bh.assertNonProblem("foo(0)", 3);
+ assertSame(f1, t.getTemplateDefinition());
+ }
+
+ // template<typename A, typename B = int, typename... C>
+ // void foo(A, B=0, C...);
+ //
+ // template<typename A, typename... B>
+ // void foo(A, B...);
+ //
+ // int main() {
+ // foo(0);
+ // }
+ public void testDisambiguateFunctionUnusedPackVsDefault2_541474() throws Exception {
+ BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP);
+ // clang (7.0.0) and gcc (7.3.1) disagree, clang thinks this is ambiguous
+ // which seems correct according to [temp.deduct.partial] p11
+ bh.assertProblem("foo(0)", 3);
+ }
+
}

Back to the top