From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2122) id 3FBF13858002; Mon, 28 Mar 2022 19:12:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3FBF13858002 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 r11-9703] c++: CTAD and member alias template [PR102123] X-Act-Checkin: gcc X-Git-Author: Jason Merrill X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: 10dcd13ff7a9f0fbbae8749929e8808792c76395 X-Git-Newrev: e952290874d6b99946dc02e125c0fb0e9b13a1e3 Message-Id: <20220328191252.3FBF13858002@sourceware.org> Date: Mon, 28 Mar 2022 19:12:52 +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: Mon, 28 Mar 2022 19:12:52 -0000 https://gcc.gnu.org/g:e952290874d6b99946dc02e125c0fb0e9b13a1e3 commit r11-9703-ge952290874d6b99946dc02e125c0fb0e9b13a1e3 Author: Jason Merrill 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::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 becomes context::template memtmpl. */ + 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 typename Template, typename... Args> +struct _dummy_forwarder { + using type = Template; +}; + +template typename Template, typename... Args> +using dummy_forwarder = typename _dummy_forwarder::type; + +template +struct Test { + template using _dummy = U; + + using Element = dummy_forwarder<_dummy, T>; + + Element _elem; + + constexpr Test(const Element elem) : _elem(elem) { } +}; + +template +Test(T) -> Test; + +void test() { + const auto t = Test(1); +}