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 r12-6872] c++: alias template and typename [PR103057] Date: Wed, 26 Jan 2022 04:23:13 +0000 (GMT) [thread overview] Message-ID: <20220126042313.F0B2238515D7@sourceware.org> (raw) https://gcc.gnu.org/g:f3e6ef7d873885ffaa0db7f4185364bbd7a70505 commit r12-6872-gf3e6ef7d873885ffaa0db7f4185364bbd7a70505 Author: Jason Merrill <jason@redhat.com> Date: Tue Jan 25 15:12:16 2022 -0500 c++: alias template and typename [PR103057] Usually we handle DR1558 substitution near the top of tsubst, but in this case while substituting TYPENAME_TYPE we were passing an alias specialization to tsubst_aggr_type, which ignored its aliasness. PR c++/103057 gcc/cp/ChangeLog: * pt.cc (tsubst_aggr_type): Call tsubst for alias template specialization. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/alias-decl-void1.C: New test. Diff: --- gcc/cp/pt.cc | 8 ++++++++ gcc/testsuite/g++.dg/cpp0x/alias-decl-void1.C | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 8f50b9c4d3c..6fbda676527 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -13585,6 +13585,14 @@ tsubst_aggr_type (tree t, if (t == NULL_TREE) return NULL_TREE; + /* If T is an alias template specialization, we want to substitute that + rather than strip it, especially if it's dependent_alias_template_spec_p. + It should be OK not to handle entering_scope in this case, since + DECL_CONTEXT will never be an alias template specialization. We only get + here with an alias when tsubst calls us for TYPENAME_TYPE. */ + if (alias_template_specialization_p (t, nt_transparent)) + return tsubst (t, args, complain, in_decl); + switch (TREE_CODE (t)) { case RECORD_TYPE: diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-void1.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-void1.C new file mode 100644 index 00000000000..accc1a45abc --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-void1.C @@ -0,0 +1,18 @@ +// PR c++/103057 +// { dg-do compile { target c++11 } } + +template <class T> struct A { }; +template <class T> struct B { using type = A<T>; }; +template <class T> struct C { + using type = typename T::foo; // { dg-error "int" } +}; +template <class T> using L = B<void>; + +template <class T> +typename L<typename C<T>::type>::type +f(T) { }; + +int main() +{ + f(42); // { dg-error "no match" } +}
reply other threads:[~2022-01-26 4:23 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=20220126042313.F0B2238515D7@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).