aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2020-11-03 05:11:42 -0800
committerNathan Sidwell <nathan@acm.org>2020-11-03 05:16:31 -0800
commit444655b6f02605ae936426a14ba527795795587b (patch)
treebf5cf729d143791165173465696e84df089dda42 /gcc
parentfbc3f847438f2297c31d9eaaec5e662192acb779 (diff)
downloadgcc-444655b6f02605ae936426a14ba527795795587b.zip
gcc-444655b6f02605ae936426a14ba527795795587b.tar.gz
gcc-444655b6f02605ae936426a14ba527795795587b.tar.bz2
c++: cp_tree_equal cleanups
A couple of small fixes. I noticed bind_template_template_parms was not marking the parm a template parm (this broke some module handling). Debugging CALL_EXPR comparisons led me to refactor cp_tree_equal's CALL_EXPR code (and my recent fix to debug printing of same). Finally TREE_VECS are best compared by comp_template_args. I recall that last piece being a left over from fixes during gcc-10. I've been using it on the modules branch since then. gcc/cp/ * tree.c (bind_template_template_parm): Mark the parm as a template parm. (cp_tree_equal): Refactor CALL_EXPR. Use comp_template_args for TREE_VECs.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/tree.c48
1 files changed, 26 insertions, 22 deletions
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 9bc37ac..3087c4a 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -2700,6 +2700,7 @@ bind_template_template_parm (tree t, tree newargs)
t2 = cxx_make_type (BOUND_TEMPLATE_TEMPLATE_PARM);
decl = build_decl (input_location,
TYPE_DECL, DECL_NAME (decl), NULL_TREE);
+ SET_DECL_TEMPLATE_PARM_P (decl);
/* These nodes have to be created to reflect new TYPE_DECL and template
arguments. */
@@ -3671,20 +3672,28 @@ cp_tree_equal (tree t1, tree t2)
case CALL_EXPR:
{
- tree arg1, arg2;
- call_expr_arg_iterator iter1, iter2;
- if (KOENIG_LOOKUP_P (t1) != KOENIG_LOOKUP_P (t2)
- || !called_fns_equal (CALL_EXPR_FN (t1), CALL_EXPR_FN (t2)))
+ if (KOENIG_LOOKUP_P (t1) != KOENIG_LOOKUP_P (t2))
return false;
- for (arg1 = first_call_expr_arg (t1, &iter1),
- arg2 = first_call_expr_arg (t2, &iter2);
- arg1 && arg2;
- arg1 = next_call_expr_arg (&iter1),
- arg2 = next_call_expr_arg (&iter2))
- if (!cp_tree_equal (arg1, arg2))
- return false;
- if (arg1 || arg2)
+
+ if (!called_fns_equal (CALL_EXPR_FN (t1), CALL_EXPR_FN (t2)))
+ return false;
+
+ call_expr_arg_iterator iter1, iter2;
+ init_call_expr_arg_iterator (t1, &iter1);
+ init_call_expr_arg_iterator (t2, &iter2);
+ if (iter1.n != iter2.n)
return false;
+
+ while (more_call_expr_args_p (&iter1))
+ {
+ tree arg1 = next_call_expr_arg (&iter1);
+ tree arg2 = next_call_expr_arg (&iter2);
+
+ gcc_checking_assert (arg1 && arg2);
+ if (!cp_tree_equal (arg1, arg2))
+ return false;
+ }
+
return true;
}
@@ -3779,16 +3788,11 @@ cp_tree_equal (tree t1, tree t2)
CHECK_CONSTR_ARGS (t2)));
case TREE_VEC:
- {
- unsigned ix;
- if (TREE_VEC_LENGTH (t1) != TREE_VEC_LENGTH (t2))
- return false;
- for (ix = TREE_VEC_LENGTH (t1); ix--;)
- if (!cp_tree_equal (TREE_VEC_ELT (t1, ix),
- TREE_VEC_ELT (t2, ix)))
- return false;
- return true;
- }
+ /* These are template args. Really we should be getting the
+ caller to do this as it knows it to be true. */
+ if (!comp_template_args (t1, t2, NULL, NULL, false))
+ return false;
+ return true;
case SIZEOF_EXPR:
case ALIGNOF_EXPR: