+2015-02-13 Jason Merrill <jason@redhat.com>
+
+ PR c++/65054
+ * pt.c (template_args_equal): Look through conversions here.
+ * tree.c (cp_tree_equal): Not here.
+
2015-02-13 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/60211
r = cxx_eval_outermost_constant_expr (t, true, true, decl);
#ifdef ENABLE_CHECKING
- /* cp_tree_equal looks through NOPs, so allow them. */
gcc_assert (r == t
|| CONVERT_EXPR_P (t)
|| TREE_CODE (t) == VIEW_CONVERT_EXPR
else if (TREE_CODE (ot) == TREE_VEC || TYPE_P (ot))
return 0;
else
- return cp_tree_equal (ot, nt);
+ {
+ /* Try to treat a template non-type argument that has been converted
+ to the parameter type as equivalent to one that hasn't yet. */
+ for (enum tree_code code1 = TREE_CODE (ot);
+ CONVERT_EXPR_CODE_P (code1)
+ || 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;
+ code2 = TREE_CODE (nt))
+ nt = TREE_OPERAND (nt, 0);
+
+ return cp_tree_equal (ot, nt);
+ }
}
/* Returns 1 iff the OLDARGS and NEWARGS are in fact identical sets of
if (!t1 || !t2)
return false;
- for (code1 = TREE_CODE (t1);
- CONVERT_EXPR_CODE_P (code1)
- || code1 == NON_LVALUE_EXPR;
- code1 = TREE_CODE (t1))
- t1 = TREE_OPERAND (t1, 0);
- for (code2 = TREE_CODE (t2);
- CONVERT_EXPR_CODE_P (code2)
- || code2 == NON_LVALUE_EXPR;
- code2 = TREE_CODE (t2))
- t2 = TREE_OPERAND (t2, 0);
-
- /* They might have become equal now. */
- if (t1 == t2)
- return true;
+ code1 = TREE_CODE (t1);
+ code2 = TREE_CODE (t2);
if (code1 != code2)
return false;
case DYNAMIC_CAST_EXPR:
case IMPLICIT_CONV_EXPR:
case NEW_EXPR:
+ CASE_CONVERT:
+ case NON_LVALUE_EXPR:
+ case VIEW_CONVERT_EXPR:
if (!same_type_p (TREE_TYPE (t1), TREE_TYPE (t2)))
return false;
/* Now compare operands as usual. */
--- /dev/null
+// PR c++/65054
+
+const char *
+foo (void)
+{
+ return ((char *const) "abc" + 1);
+}