aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2016-12-21 14:38:29 -0500
committerJason Merrill <jason@gcc.gnu.org>2016-12-21 14:38:29 -0500
commita93634ba09c4b33d95233e48d9c452a529555d05 (patch)
tree0e94afcfe589438ff71b0d77f01d1da6042b0432 /gcc
parent35f4cbd4489519983a4f64da846be8352f611879 (diff)
downloadgcc-a93634ba09c4b33d95233e48d9c452a529555d05.zip
gcc-a93634ba09c4b33d95233e48d9c452a529555d05.tar.gz
gcc-a93634ba09c4b33d95233e48d9c452a529555d05.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/pt.c21
2 files changed, 18 insertions, 8 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 20677fd..4c68b1e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,10 @@
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.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 91178ea..9d9c35e 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: