[clang] [Sema] Restructure and extend the testing of template pack deduction (PR #79881)
https://github.com/spaits closed https://github.com/llvm/llvm-project/pull/79881 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema] Restructure and extend the testing of template pack deduction (PR #79881)
https://github.com/cor3ntin approved this pull request. https://github.com/llvm/llvm-project/pull/79881 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema] Restructure and extend the testing of template pack deduction (PR #79881)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Gábor Spaits (spaits) Changes Previously I worked on #78449 . I added tests in my solution #79371, but I think there should be other scenarios that should be tested and these tests deserve their namespace. In this PR I would like to make these changes. --- Full diff: https://github.com/llvm/llvm-project/pull/79881.diff 1 Files Affected: - (modified) clang/test/SemaTemplate/deduction.cpp (+28-23) ``diff diff --git a/clang/test/SemaTemplate/deduction.cpp b/clang/test/SemaTemplate/deduction.cpp index e18551bf0302226..a209615c364799d 100644 --- a/clang/test/SemaTemplate/deduction.cpp +++ b/clang/test/SemaTemplate/deduction.cpp @@ -414,6 +414,34 @@ namespace deduction_substitution_failure { int bi = B; // expected-note {{during template argument deduction for variable template partial specialization 'B::error>' [with T = char]}} } +namespace deduce_pack_from_argument { + template + void separator(args_tag, T..., int, T...) {} + template + void separator_dependent(args_tag, type_identity_t..., int, type_identity_t...) {} + template + void separator_multiple_parameters(args_tag, args_tag, type_identity_t..., int mid, type_identity_t...) {} + + void test_separator() { +separator(args_tag{}, 4, 8, 42, 16, 25); +separator(args_tag<>{}, 42); +separator_dependent(args_tag{}, 4, 8, 42, 16, 25); +separator_dependent(args_tag<>{}, 42); +separator_multiple_parameters(args_tag{}, args_tag{}, 8, 9, 15, 16, 23); + } + + template void no_separator(args_tag, T..., T...) {} + template + void no_separator_dependent(args_tag, args_tag, type_identity_t..., type_identity_t...) {} + + void test_no_separator() { +no_separator(args_tag{}, 1, 2, 3, 4); +no_separator(args_tag<>{}); +no_separator_dependent(args_tag{}, args_tag{}, 8, 9, 15, 16); +no_separator_dependent(args_tag<>{}, args_tag<>{}); + } +} + namespace deduction_after_explicit_pack { template int *f(T ...t, int , U *u) { return u; @@ -442,29 +470,6 @@ namespace deduction_after_explicit_pack { i(0, 1, 2, 3, 4, 5); // expected-error {{no match}} } - template - void bar(args_tag, type_identity_t..., int mid, type_identity_t...) {} - void call_bar() { -bar(args_tag{}, 4, 8, 1001, 16, 23); - } - - template - void foo(args_tag, args_tag, type_identity_t..., int mid, type_identity_t...) {} - void call_foo() { -foo(args_tag{}, args_tag{}, 4, 8, 9, 15, 16, 23, 1); - } - - template - void foo2(args_tag, args_tag, type_identity_t..., type_identity_t...) {} - void call_foo2() { -foo2(args_tag{}, args_tag{}, 4, 8, 9, 15, 16, 23); - } - - template void baz(args_tag, T..., T...) {} - void call_baz() { -baz(args_tag{}, 1, 2, 3, 4); - } - // GCC alarmingly accepts this by deducing T={int} by matching the second // parameter against the first argument, then passing the first argument // through the first parameter. `` https://github.com/llvm/llvm-project/pull/79881 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [Sema] Restructure and extend the testing of template pack deduction (PR #79881)
https://github.com/spaits created https://github.com/llvm/llvm-project/pull/79881 Previously I worked on #78449 . I added tests in my solution #79371, but I think there should be other scenarios that should be tested and these tests deserve their namespace. In this PR I would like to make these changes. From f017c299d3edbd8ec06da1d5882aebbb0f6dd4c9 Mon Sep 17 00:00:00 2001 From: Gabor Spaits Date: Mon, 29 Jan 2024 08:38:12 +0100 Subject: [PATCH] Restructure tests --- clang/test/SemaTemplate/deduction.cpp | 51 +++ 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/clang/test/SemaTemplate/deduction.cpp b/clang/test/SemaTemplate/deduction.cpp index e18551bf030222..a209615c364799 100644 --- a/clang/test/SemaTemplate/deduction.cpp +++ b/clang/test/SemaTemplate/deduction.cpp @@ -414,6 +414,34 @@ namespace deduction_substitution_failure { int bi = B; // expected-note {{during template argument deduction for variable template partial specialization 'B::error>' [with T = char]}} } +namespace deduce_pack_from_argument { + template + void separator(args_tag, T..., int, T...) {} + template + void separator_dependent(args_tag, type_identity_t..., int, type_identity_t...) {} + template + void separator_multiple_parameters(args_tag, args_tag, type_identity_t..., int mid, type_identity_t...) {} + + void test_separator() { +separator(args_tag{}, 4, 8, 42, 16, 25); +separator(args_tag<>{}, 42); +separator_dependent(args_tag{}, 4, 8, 42, 16, 25); +separator_dependent(args_tag<>{}, 42); +separator_multiple_parameters(args_tag{}, args_tag{}, 8, 9, 15, 16, 23); + } + + template void no_separator(args_tag, T..., T...) {} + template + void no_separator_dependent(args_tag, args_tag, type_identity_t..., type_identity_t...) {} + + void test_no_separator() { +no_separator(args_tag{}, 1, 2, 3, 4); +no_separator(args_tag<>{}); +no_separator_dependent(args_tag{}, args_tag{}, 8, 9, 15, 16); +no_separator_dependent(args_tag<>{}, args_tag<>{}); + } +} + namespace deduction_after_explicit_pack { template int *f(T ...t, int , U *u) { return u; @@ -442,29 +470,6 @@ namespace deduction_after_explicit_pack { i(0, 1, 2, 3, 4, 5); // expected-error {{no match}} } - template - void bar(args_tag, type_identity_t..., int mid, type_identity_t...) {} - void call_bar() { -bar(args_tag{}, 4, 8, 1001, 16, 23); - } - - template - void foo(args_tag, args_tag, type_identity_t..., int mid, type_identity_t...) {} - void call_foo() { -foo(args_tag{}, args_tag{}, 4, 8, 9, 15, 16, 23, 1); - } - - template - void foo2(args_tag, args_tag, type_identity_t..., type_identity_t...) {} - void call_foo2() { -foo2(args_tag{}, args_tag{}, 4, 8, 9, 15, 16, 23); - } - - template void baz(args_tag, T..., T...) {} - void call_baz() { -baz(args_tag{}, 1, 2, 3, 4); - } - // GCC alarmingly accepts this by deducing T={int} by matching the second // parameter against the first argument, then passing the first argument // through the first parameter. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits