aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@acm.org>2020-05-13 13:22:02 -0700
committerNathan Sidwell <nathan@acm.org>2020-05-13 13:22:02 -0700
commit7040894c4441fd3f9a39b0dd2d7b640e8e85808a (patch)
treef91f9fd4b7b3fd779844bf07ee84b7436bc4504c /gcc
parent2bb30de62f59caa9af1ec01aa1029795f4748842 (diff)
downloadgcc-7040894c4441fd3f9a39b0dd2d7b640e8e85808a.zip
gcc-7040894c4441fd3f9a39b0dd2d7b640e8e85808a.tar.gz
gcc-7040894c4441fd3f9a39b0dd2d7b640e8e85808a.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;