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-9703] c++: CTAD and member alias template [PR102123] Date: Mon, 28 Mar 2022 19:12:52 +0000 (GMT) [thread overview] Message-ID: <20220328191252.3FBF13858002@sourceware.org> (raw) https://gcc.gnu.org/g:e952290874d6b99946dc02e125c0fb0e9b13a1e3 commit r11-9703-ge952290874d6b99946dc02e125c0fb0e9b13a1e3 Author: Jason Merrill <jason@redhat.com> Date: Sat Mar 26 23:54:22 2022 -0400 c++: CTAD and member alias template [PR102123] When building a deduction guide from the Test constructor, we need to rewrite the use of _dummy into a dependent reference, i.e. Test<T>::template _dummy. We were using SCOPE_REF for both type and non-type templates; we need to use UNBOUND_CLASS_TEMPLATE for type templates. PR c++/102123 gcc/cp/ChangeLog: * pt.c (tsubst_copy): Use make_unbound_class_template for rewriting a type template reference. gcc/testsuite/ChangeLog: * g++.dg/cpp1z/class-deduction110.C: New test. Diff: --- gcc/cp/pt.c | 3 +++ gcc/testsuite/g++.dg/cpp1z/class-deduction110.C | 28 +++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 1b473f79dd6..1493019bd27 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -16879,6 +16879,9 @@ tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl) /* When rewriting a constructor into a deduction guide, a non-dependent name can become dependent, so memtmpl<args> becomes context::template memtmpl<args>. */ + if (DECL_TYPE_TEMPLATE_P (t)) + return make_unbound_class_template (context, DECL_NAME (t), + NULL_TREE, complain); tree type = tsubst (TREE_TYPE (t), args, complain, in_decl); return build_qualified_name (type, context, DECL_NAME (t), /*template*/true); diff --git a/gcc/testsuite/g++.dg/cpp1z/class-deduction110.C b/gcc/testsuite/g++.dg/cpp1z/class-deduction110.C new file mode 100644 index 00000000000..8eb56478fe9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp1z/class-deduction110.C @@ -0,0 +1,28 @@ +// PR c++/102123 +// { dg-do compile { target c++17 } } + +template<template<typename...> typename Template, typename... Args> +struct _dummy_forwarder { + using type = Template<Args...>; +}; + +template<template<typename...> typename Template, typename... Args> +using dummy_forwarder = typename _dummy_forwarder<Template, Args...>::type; + +template<typename T> +struct Test { + template<typename U> using _dummy = U; + + using Element = dummy_forwarder<_dummy, T>; + + Element _elem; + + constexpr Test(const Element elem) : _elem(elem) { } +}; + +template<typename T> +Test(T) -> Test<T>; + +void test() { + const auto t = Test(1); +}
reply other threads:[~2022-03-28 19:12 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=20220328191252.3FBF13858002@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).