Commit de62200f by Alexandre Oliva Committed by Alexandre Oliva

[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.


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.

From-SVN: r267251
parent bceca9b3
2018-12-19 Alexandre Oliva <aoliva@redhat.com> 2018-12-19 Alexandre Oliva <aoliva@redhat.com>
PR c++/87012
* pt.c (convert_template_argument): Canonicalize type after
tsubst/deduce.
PR c++/88146 PR c++/88146
* method.c (do_build_copy_constructor): Guard cvquals init and * method.c (do_build_copy_constructor): Guard cvquals init and
loop over fields to run for non-inherited ctors only. loop over fields to run for non-inherited ctors only.
......
...@@ -8019,6 +8019,9 @@ convert_template_argument (tree parm, ...@@ -8019,6 +8019,9 @@ convert_template_argument (tree parm,
if (invalid_nontype_parm_type_p (t, complain)) if (invalid_nontype_parm_type_p (t, complain))
return error_mark_node; return error_mark_node;
if (t != TREE_TYPE (parm))
t = canonicalize_type_argument (t, complain);
if (!type_dependent_expression_p (orig_arg) if (!type_dependent_expression_p (orig_arg)
&& !uses_template_parms (t)) && !uses_template_parms (t))
/* We used to call digest_init here. However, digest_init /* We used to call digest_init here. However, digest_init
......
2018-12-19 Alexandre Oliva <aoliva@redhat.com> 2018-12-19 Alexandre Oliva <aoliva@redhat.com>
PR c++/87012
* g++.dg/cpp0x/pr87012.C: New.
PR c++/88146 PR c++/88146
* g++.dg/cpp0x/inh-ctor32.C: New. * g++.dg/cpp0x/inh-ctor32.C: New.
......
// { dg-do compile { target c++11 } }
template<class T>
using ref = T&;
int x;
template<template<class> class T, T<int>>
struct X { };
struct Y : X<ref, x> { };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment