This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] [PR87012] canonicalize ref type for tmpl arg
- From: Jason Merrill <jason at redhat dot com>
- To: Alexandre Oliva <aoliva at redhat dot com>
- Cc: gcc-patches List <gcc-patches at gcc dot gnu dot org>, Nathan Sidwell <nathan at acm dot org>
- Date: Fri, 14 Dec 2018 09:30:42 -0500
- Subject: Re: [PATCH] [PR87012] canonicalize ref type for tmpl arg
- References: <or7ehck60p.fsf@lxoliva.fsfla.org> <2bcaf9b3-e544-4146-fe5f-cd39a5f23e6f@redhat.com> <orr2ekevmw.fsf@lxoliva.fsfla.org>
On Thu, Dec 13, 2018 at 8:37 PM Alexandre Oliva <aoliva@redhat.com> wrote:
> On Dec 5, 2018, Jason Merrill <jason@redhat.com> wrote:
>
> > I would expect that this same issue would come up with other types; I
> > think we want to fix this sooner, when we are figuring out what type
> > we want to convert the argument to.
>
> You mean like this?
>
> [PR87012] canonicalize ref type for tmpl arg
>
> When binding an object to a template parameter of reference type, we
> take the address of the object and dereference that address. The type
> of the address may still carry (template) typedefs, but
> verify_unstripped_args_1 rejects such typedefs other than in the top
> level of template arguments.
>
> Canonicalizing the type we want to convert to right after any
> substitutions or deductions avoids that issue.
>
> Regstrapped on x86_64- and i686-linux-gnu. Ok to install?
>
>
> for gcc/cp/ChangeLog
>
> PR c++/87012
> * pt.c (convert_template_argument): Canonicalize type after
> tsubst/deduce.
>
> for gcc/testsuite/ChangeLog
>
> PR c++/87012
> * g++.dg/cpp0x/pr87012.C: New.
> ---
> gcc/cp/pt.c | 2 ++
> gcc/testsuite/g++.dg/cpp0x/pr87012.C | 11 +++++++++++
> 2 files changed, 13 insertions(+)
> create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr87012.C
>
> diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
> index 72ae7173d92c..0d388c67459a 100644
> --- a/gcc/cp/pt.c
> +++ b/gcc/cp/pt.c
> @@ -8018,6 +8018,8 @@ convert_template_argument (tree parm,
> if (invalid_nontype_parm_type_p (t, complain))
> return error_mark_node;
>
> + t = canonicalize_type_argument (t, complain);
Yes, like that, thanks. It might be a bit of an optimization to skip
this when t == TREE_TYPE (parm). OK either way.
Jason