From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2122) id CB708395B06A; Fri, 13 May 2022 17:13:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CB708395B06A MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jason Merrill To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-10733] c++: argument pack with expansion [PR86355] X-Act-Checkin: gcc X-Git-Author: Jason Merrill X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: f22517aa5cf02683cd870fae84e23caacc66c4c9 X-Git-Newrev: aa030fca4b7257656aa6bfe879d79a332b3c39ea Message-Id: <20220513171349.CB708395B06A@sourceware.org> Date: Fri, 13 May 2022 17:13:49 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 May 2022 17:13:49 -0000 https://gcc.gnu.org/g:aa030fca4b7257656aa6bfe879d79a332b3c39ea commit r10-10733-gaa030fca4b7257656aa6bfe879d79a332b3c39ea Author: Jason Merrill Date: Wed May 26 17:38:42 2021 -0400 c++: argument pack with expansion [PR86355] This testcase revealed that we were using PACK_EXPANSION_EXTRA_ARGS a lot more than necessary; use_pack_expansion_extra_args_p meant to use it in the case of corresponding arguments in different argument packs differing in whether they are pack expansions, but it was mistakenly also returning true for the case of a single argument pack containing both expansion and non-expansion elements. Surprisingly, just disabling that didn't lead to any regressions in the testsuite; it seems other changes have prevented us getting to this point for code that used to exercise it. So this patch limits the check to arguments in the same position in the packs, and asserts that we never actually see a mismatch. PR c++/86355 gcc/cp/ChangeLog: * pt.c (use_pack_expansion_extra_args_p): Don't compare args from the same argument pack. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/alias-decl-variadic2.C: New test. Diff: --- gcc/cp/pt.c | 7 +++++-- gcc/testsuite/g++.dg/cpp0x/alias-decl-variadic2.C | 13 +++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index fb214e8f8c9..1746ddfa47c 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -12318,9 +12318,9 @@ use_pack_expansion_extra_args_p (tree parm_packs, return false; } - bool has_expansion_arg = false; for (int i = 0 ; i < arg_pack_len; ++i) { + bool has_expansion_arg = false; bool has_non_expansion_arg = false; for (tree parm_pack = parm_packs; parm_pack; @@ -12340,7 +12340,10 @@ use_pack_expansion_extra_args_p (tree parm_packs, } if (has_expansion_arg && has_non_expansion_arg) - return true; + { + gcc_checking_assert (false); + return true; + } } return false; } diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-variadic2.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-variadic2.C new file mode 100644 index 00000000000..4299c7e88dc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-variadic2.C @@ -0,0 +1,13 @@ +// PR c++/86355 +// { dg-do compile { target c++11 } } + +template struct integral_constant { + static const int value = 1; +}; +template using mp_all = integral_constant; +template using check2 = mp_all>>; +check2<> x; + +template struct assert_same; +template struct assert_same { }; +assert_same> a;