public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Patrick Palka <ppalka@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-6950] c++: CTAD for class tmpl defined inside partial spec [PR104294] Date: Mon, 31 Jan 2022 20:28:21 +0000 (GMT) [thread overview] Message-ID: <20220131202821.E6A0F3857C47@sourceware.org> (raw) https://gcc.gnu.org/g:76dc465aaf1b74bf92143510b6db5671e1c053d6 commit r12-6950-g76dc465aaf1b74bf92143510b6db5671e1c053d6 Author: Patrick Palka <ppalka@redhat.com> Date: Mon Jan 31 15:27:58 2022 -0500 c++: CTAD for class tmpl defined inside partial spec [PR104294] Here during deduction guide generation for the nested class template B<char(int)>::C, the computation of outer_args yields the template arguments relative to the primary template for B (i.e. {char(int)}) but what we really want is those relative to C's enclosing scope, the partial specialization of B (i.e. {char, int}). PR c++/104294 gcc/cp/ChangeLog: * pt.cc (ctor_deduction_guides_for): Correct computation of outer_args. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/class-deduction106.C: New test. Diff: --- gcc/cp/pt.cc | 4 +++- gcc/testsuite/g++.dg/cpp1z/class-deduction106.C | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 84d63f9181c..feee629f1dd 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -29563,7 +29563,9 @@ ctor_deduction_guides_for (tree tmpl, tsubst_flags_t complain) if (DECL_CLASS_SCOPE_P (tmpl) && CLASSTYPE_TEMPLATE_INSTANTIATION (DECL_CONTEXT (tmpl))) { - outer_args = CLASSTYPE_TI_ARGS (DECL_CONTEXT (tmpl)); + outer_args = copy_node (CLASSTYPE_TI_ARGS (type)); + gcc_assert (TMPL_ARGS_DEPTH (outer_args) > 1); + --TREE_VEC_LENGTH (outer_args); type = TREE_TYPE (most_general_template (tmpl)); } diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction106.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction106.C new file mode 100644 index 00000000000..b4c4d262f44 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction106.C @@ -0,0 +1,16 @@ +// PR c++/104294 +// { dg-do compile { target c++17 } } + +template<class> struct B; + +template<class R, class... Args> +struct B<R(Args...)> { + template<class T> struct C { C(T); }; + C(decltype(nullptr)) -> C<void*>; +}; + +using ty1 = decltype(B<char(int)>::C{0}); +using ty1 = B<char(int)>::C<int>; + +using ty2 = decltype(B<char(int)>::C{nullptr}); +using ty2 = B<char(int)>::C<void*>;
reply other threads:[~2022-01-31 20:28 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=20220131202821.E6A0F3857C47@sourceware.org \ --to=ppalka@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).