From: Jason Merrill Date: Wed, 21 Dec 2016 19:38:29 +0000 (-0500) Subject: Fixes for P0127R2 implementation. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a93634ba09c4b33d95233e48d9c452a529555d05;p=gcc.git Fixes for P0127R2 implementation. * pt.c (convert_template_argument): Pass args to do_auto_deduction. (mark_template_parm): Handle deducibility from type of non-type argument here. (for_each_template_parm_r): Not here. From-SVN: r243867 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 20677fd79f3..4c68b1e4e3e 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,10 @@ 2016-12-21 Jason Merrill + * pt.c (convert_template_argument): Pass args to do_auto_deduction. + (mark_template_parm): Handle deducibility from type of non-type + argument here. + (for_each_template_parm_r): Not here. + * ptree.c (cxx_print_type): Print args of BOUND_TEMPLATE_TEMPLATE_PARM. (cxx_print_decl): Print DECL_TEMPLATE_PARMS. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 91178eae80b..9d9c35e47e6 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -4467,6 +4467,15 @@ mark_template_parm (tree t, void* data) tpd->arg_uses_template_parms[tpd->current_arg] = 1; } + /* In C++17 the type of a non-type argument is a deduced context. */ + if (cxx_dialect >= cxx1z + && TREE_CODE (t) == TEMPLATE_PARM_INDEX) + for_each_template_parm (TREE_TYPE (t), + &mark_template_parm, + data, + NULL, + /*include_nondeduced_p=*/false); + /* Return zero so that for_each_template_parm will continue the traversal of the tree; we want to mark *every* template parm. */ return 0; @@ -7328,14 +7337,16 @@ convert_template_argument (tree parm, } else { - tree t = tsubst (TREE_TYPE (parm), args, complain, in_decl); + tree t = TREE_TYPE (parm); if (tree a = type_uses_auto (t)) { - t = do_auto_deduction (t, arg, a, complain, adc_unspecified); + t = do_auto_deduction (t, arg, a, complain, adc_unify, args); if (t == error_mark_node) return error_mark_node; } + else + t = tsubst (t, args, complain, in_decl); if (invalid_nontype_parm_type_p (t, complain)) return error_mark_node; @@ -8956,12 +8967,6 @@ for_each_template_parm_r (tree *tp, int *walk_subtrees, void *d) return t; else if (!fn) return t; - - /* In C++17 we can deduce a type argument from the type of a non-type - argument. */ - if (cxx_dialect >= cxx1z - && TREE_CODE (t) == TEMPLATE_PARM_INDEX) - WALK_SUBTREE (TREE_TYPE (t)); break; case TEMPLATE_DECL: