aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2020-05-13 13:22:02 -0700
committerGiuliano Belinassi <giuliano.belinassi@usp.br>2020-08-17 13:03:16 -0300
commit4edce257577704ffba19dc2863bb93d33238359d (patch)
treead2c9020e63b34ecc53c65a2b1d283824e7fa485 /gcc
parent91a27e7bdc44347160c73f59037422395b3e0d62 (diff)
downloadgcc-4edce257577704ffba19dc2863bb93d33238359d.zip
gcc-4edce257577704ffba19dc2863bb93d33238359d.tar.gz
gcc-4edce257577704ffba19dc2863bb93d33238359d.tar.bz2
c++: Template arg comparison
When fixing up the template specialization hasher I was confused by the control flow through template_args_equal. This reorders the category checking, so it is clearer as to what kind of node can reach which point. * pt.c (template_args_equal): Reorder category checking for clarity.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/pt.c17
2 files changed, 11 insertions, 9 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a63f04e..2e53514 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2020-05-13 Nathan Sidwell <nathan@acm.org>
+ * pt.c (template_args_equal): Reorder category checking for
+ clarity.
+
* pt.c (perform_typedefs_access_check): Cache expensively
calculated object references.
(check_auto_in_tmpl_args): Just assert we do not get unexpected
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 52ed462..a36f603 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -9084,22 +9084,22 @@ template_args_equal (tree ot, tree nt, bool partial_order /* = false */)
if (class_nttp_const_wrapper_p (ot))
ot = TREE_OPERAND (ot, 0);
- if (TREE_CODE (nt) == TREE_VEC)
+ if (TREE_CODE (nt) == TREE_VEC || TREE_CODE (nt) == TREE_VEC)
/* For member templates */
- return TREE_CODE (ot) == TREE_VEC && comp_template_args (ot, nt);
- else if (PACK_EXPANSION_P (ot))
- return (PACK_EXPANSION_P (nt)
+ return TREE_CODE (ot) == TREE_CODE (nt) && comp_template_args (ot, nt);
+ else if (PACK_EXPANSION_P (ot) || PACK_EXPANSION_P (nt))
+ return (PACK_EXPANSION_P (ot) && PACK_EXPANSION_P (nt)
&& template_args_equal (PACK_EXPANSION_PATTERN (ot),
PACK_EXPANSION_PATTERN (nt))
&& template_args_equal (PACK_EXPANSION_EXTRA_ARGS (ot),
PACK_EXPANSION_EXTRA_ARGS (nt)));
else if (ARGUMENT_PACK_P (ot) || ARGUMENT_PACK_P (nt))
return cp_tree_equal (ot, nt);
- else if (ot && TREE_CODE (ot) == ARGUMENT_PACK_SELECT)
+ else if (TREE_CODE (ot) == ARGUMENT_PACK_SELECT)
gcc_unreachable ();
- else if (TYPE_P (nt))
+ else if (TYPE_P (nt) || TYPE_P (nt))
{
- if (!TYPE_P (ot))
+ if (!(TYPE_P (nt) && TYPE_P (ot)))
return false;
/* Don't treat an alias template specialization with dependent
arguments as equivalent to its underlying type when used as a
@@ -9117,8 +9117,6 @@ template_args_equal (tree ot, tree nt, bool partial_order /* = false */)
else
return same_type_p (ot, nt);
}
- else if (TREE_CODE (ot) == TREE_VEC || TYPE_P (ot))
- return 0;
else
{
/* Try to treat a template non-type argument that has been converted
@@ -9128,6 +9126,7 @@ template_args_equal (tree ot, tree nt, bool partial_order /* = false */)
|| code1 == NON_LVALUE_EXPR;
code1 = TREE_CODE (ot))
ot = TREE_OPERAND (ot, 0);
+
for (enum tree_code code2 = TREE_CODE (nt);
CONVERT_EXPR_CODE_P (code2)
|| code2 == NON_LVALUE_EXPR;