2016-12-21 Jason Merrill <jason@redhat.com>
+ * 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.
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;
}
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;
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: