public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Jason Merrill <jason@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-9988] c++: pack init-capture of unresolved overload [PR102629] Date: Thu, 12 May 2022 20:14:55 +0000 (GMT) [thread overview] Message-ID: <20220512201455.27176395201C@sourceware.org> (raw) https://gcc.gnu.org/g:f0484f60e6409ef6e837e4712d212a5d827767ba commit r11-9988-gf0484f60e6409ef6e837e4712d212a5d827767ba Author: Jason Merrill <jason@redhat.com> Date: Tue Apr 26 00:19:40 2022 -0400 c++: pack init-capture of unresolved overload [PR102629] Here we were failing to diagnose that the initializer for the capture pack is an unresolved overload. It turns out that the reason we didn't recognize the deduction failure in do_auto_deduction was that the individual 'auto' in the expansion of the capture pack was still marked as a parameter pack, so we were deducing it to an empty pack instead of failing. PR c++/102629 gcc/cp/ChangeLog: * pt.c (gen_elem_of_pack_expansion_instantiation): Clear TEMPLATE_TYPE_PARAMETER_PACK on auto. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/lambda-pack-init7.C: New test. Diff: --- gcc/cp/pt.c | 8 +++++++- gcc/testsuite/g++.dg/cpp2a/lambda-pack-init7.C | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index c98acbec481..a8fa2347c8a 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -12642,7 +12642,13 @@ gen_elem_of_pack_expansion_instantiation (tree pattern, t = tsubst_expr (pattern, args, complain, in_decl, /*integral_constant_expression_p=*/false); else - t = tsubst (pattern, args, complain, in_decl); + { + t = tsubst (pattern, args, complain, in_decl); + if (is_auto (t) && !ith_elem_is_expansion) + /* When expanding the fake auto... pack expansion from add_capture, we + need to mark that the expansion is no longer a pack. */ + TEMPLATE_TYPE_PARAMETER_PACK (t) = false; + } /* If the Ith argument pack element is a pack expansion, then the Ith element resulting from the substituting is going to diff --git a/gcc/testsuite/g++.dg/cpp2a/lambda-pack-init7.C b/gcc/testsuite/g++.dg/cpp2a/lambda-pack-init7.C new file mode 100644 index 00000000000..f3c3899e97a --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/lambda-pack-init7.C @@ -0,0 +1,18 @@ +// PR c++/102629 +// { dg-do compile { target c++20 } } + +template <class T> T&& forward(T&); +template <class T> T&& forward(T&&); + +struct S {}; + +template <typename... Args> +void foo(Args&&... args) { + [...args = forward<Args> /*(args)*/] { // { dg-error "" } + [](auto...) { } (forward<Args>(args)...); + }; +} + +void bar( ) { + foo(S{}); +}
reply other threads:[~2022-05-12 20:14 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220512201455.27176395201C@sourceware.org \ --to=jason@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).