On Dec 14, 2018, Jason Merrill <ja...@redhat.com> wrote: > Yes, like that, thanks. It might be a bit of an optimization to skip > this when t == TREE_TYPE (parm). OK either way.
Thanks, I've put the suggested optimization in. Here's what I'm about to install. [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. --- gcc/cp/pt.c | 3 +++ gcc/testsuite/g++.dg/cpp0x/pr87012.C | 11 +++++++++++ 2 files changed, 14 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/pr87012.C diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 79eef12112fb..e99de71ea9e2 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -8019,6 +8019,9 @@ convert_template_argument (tree parm, if (invalid_nontype_parm_type_p (t, complain)) return error_mark_node; + if (t != TREE_TYPE (parm)) + t = canonicalize_type_argument (t, complain); + if (!type_dependent_expression_p (orig_arg) && !uses_template_parms (t)) /* We used to call digest_init here. However, digest_init diff --git a/gcc/testsuite/g++.dg/cpp0x/pr87012.C b/gcc/testsuite/g++.dg/cpp0x/pr87012.C new file mode 100644 index 000000000000..fd3eea47c390 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/pr87012.C @@ -0,0 +1,11 @@ +// { 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> { }; -- Alexandre Oliva, freedom fighter https://FSFLA.org/blogs/lxo Be the change, be Free! FSF Latin America board member GNU Toolchain Engineer Free Software Evangelist Hay que enGNUrecerse, pero sin perder la terGNUra jamás-GNUChe