From: Jason Merrill <jason@redhat.com>
To: Patrick Palka <ppalka@redhat.com>, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] c++: alias template of non-template class [PR112633]
Date: Wed, 22 Nov 2023 13:13:07 -0500 [thread overview]
Message-ID: <42641f46-f54f-45c7-9df1-c739137ada46@redhat.com> (raw)
In-Reply-To: <20231122172657.542419-1-ppalka@redhat.com>
On 11/22/23 12:26, Patrick Palka wrote:
> Bootstrapped and regtested on x86-64-pc-linux-gnu, does this look OK for
> trunk/13?
OK.
> -- >8 --
>
> The entering_scope adjustment in tsubst_aggr_type assumes if an alias is
> dependent, then so is the aliased type (and therefore it has template info)
> but that's not true for the dependent alias template specialization ty1<T>
> below which aliases the non-template class A.
>
> PR c++/112633
>
> gcc/cp/ChangeLog:
>
> * pt.cc (tsubst_aggr_type): Handle empty TYPE_TEMPLATE_INFO
> in the entering_scope adjustment.
>
> gcc/testsuite/ChangeLog:
>
> * g++.dg/cpp0x/alias-decl-75.C: New test.
> ---
> gcc/cp/pt.cc | 1 +
> gcc/testsuite/g++.dg/cpp0x/alias-decl-75.C | 13 +++++++++++++
> 2 files changed, 14 insertions(+)
> create mode 100644 gcc/testsuite/g++.dg/cpp0x/alias-decl-75.C
>
> diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
> index ed681afb5d4..68ce4a87372 100644
> --- a/gcc/cp/pt.cc
> +++ b/gcc/cp/pt.cc
> @@ -13976,6 +13976,7 @@ tsubst_aggr_type (tree t,
> if (entering_scope
> && CLASS_TYPE_P (t)
> && dependent_type_p (t)
> + && TYPE_TEMPLATE_INFO (t)
> && TYPE_CANONICAL (t) == TREE_TYPE (TYPE_TI_TEMPLATE (t)))
> t = TYPE_CANONICAL (t);
>
> diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-75.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-75.C
> new file mode 100644
> index 00000000000..1a73a99856e
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-75.C
> @@ -0,0 +1,13 @@
> +// PR c++/112633
> +// { dg-do compile { target c++11 } }
> +
> +struct A { using type = void; };
> +
> +template<class>
> +using ty1 = A;
> +
> +template<class T>
> +using ty2 = typename ty1<T>::type;
> +
> +template<class T>
> +ty2<T> f();
prev parent reply other threads:[~2023-11-22 18:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-22 17:26 Patrick Palka
2023-11-22 18:13 ` Jason Merrill [this message]
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=42641f46-f54f-45c7-9df1-c739137ada46@redhat.com \
--to=jason@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=ppalka@redhat.com \
/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: link
Be 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).