+2015-10-28 Jason Merrill <jason@redhat.com>
+
+ * c-common.c (pointer_int_sum): Fold the MULT_EXPR.
+
2015-10-27 Thomas Schwinge <thomas@codesourcery.com>
James Norris <jnorris@codesourcery.com>
Cesar Philippidis <cesar@codesourcery.com>
for the pointer operation and disregard an overflow that occurred only
because of the sign-extension change in the latter conversion. */
{
- tree t = build_binary_op (loc,
- MULT_EXPR, intop,
- convert (TREE_TYPE (intop), size_exp), 1);
+ tree t = fold_build2_loc (loc, MULT_EXPR, TREE_TYPE (intop), intop,
+ convert (TREE_TYPE (intop), size_exp));
intop = convert (sizetype, t);
if (TREE_OVERFLOW_P (intop) && !TREE_OVERFLOW (t))
intop = wide_int_to_tree (TREE_TYPE (intop), intop);
return (char *)i + (__UINTPTR_TYPE__)p;
}
-/* { dg-final { scan-tree-dump "p +" "original" } } */
+/* Check that we use a POINTER_PLUS_EXPR, not something like
+ return (char *) ((sizetype) p + (sizetype) i); */
+/* { dg-final { scan-tree-dump-not "sizetype.*sizetype" "original" } } */
+
+/* And also that we don't swap the operands. */
+/* { dg-final { scan-tree-dump-not "return p +" "original" } } */