Commit 280f1ffa by Eric Botcazou Committed by Eric Botcazou

c-common.c (pointer_int_sum): Do the negation in sizetype.

	* c-common.c (pointer_int_sum): Do the negation in sizetype.

From-SVN: r126108
parent e444a887
2007-06-29 Eric Botcazou <ebotcazou@adacore.com>
* c-common.c (pointer_int_sum): Do the negation in sizetype.
2007-06-28 DJ Delorie <dj@redhat.com> 2007-06-28 DJ Delorie <dj@redhat.com>
* config/m32c/m32c.h (OVERRIDE_OPTIONS): Omit unneeded semicolon. * config/m32c/m32c.h (OVERRIDE_OPTIONS): Omit unneeded semicolon.
......
...@@ -2627,7 +2627,6 @@ pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop) ...@@ -2627,7 +2627,6 @@ pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop)
tree size_exp, ret; tree size_exp, ret;
/* The result is a pointer of the same type that is being added. */ /* The result is a pointer of the same type that is being added. */
tree result_type = TREE_TYPE (ptrop); tree result_type = TREE_TYPE (ptrop);
if (TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE) if (TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE)
...@@ -2661,7 +2660,6 @@ pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop) ...@@ -2661,7 +2660,6 @@ pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop)
contains a constant term, apply distributive law contains a constant term, apply distributive law
and multiply that constant term separately. and multiply that constant term separately.
This helps produce common subexpressions. */ This helps produce common subexpressions. */
if ((TREE_CODE (intop) == PLUS_EXPR || TREE_CODE (intop) == MINUS_EXPR) if ((TREE_CODE (intop) == PLUS_EXPR || TREE_CODE (intop) == MINUS_EXPR)
&& !TREE_CONSTANT (intop) && !TREE_CONSTANT (intop)
&& TREE_CONSTANT (TREE_OPERAND (intop, 1)) && TREE_CONSTANT (TREE_OPERAND (intop, 1))
...@@ -2690,7 +2688,6 @@ pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop) ...@@ -2690,7 +2688,6 @@ pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop)
/* Convert the integer argument to a type the same size as sizetype /* Convert the integer argument to a type the same size as sizetype
so the multiply won't overflow spuriously. */ so the multiply won't overflow spuriously. */
if (TYPE_PRECISION (TREE_TYPE (intop)) != TYPE_PRECISION (sizetype) if (TYPE_PRECISION (TREE_TYPE (intop)) != TYPE_PRECISION (sizetype)
|| TYPE_UNSIGNED (TREE_TYPE (intop)) != TYPE_UNSIGNED (sizetype)) || TYPE_UNSIGNED (TREE_TYPE (intop)) != TYPE_UNSIGNED (sizetype))
intop = convert (c_common_type_for_size (TYPE_PRECISION (sizetype), intop = convert (c_common_type_for_size (TYPE_PRECISION (sizetype),
...@@ -2698,17 +2695,15 @@ pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop) ...@@ -2698,17 +2695,15 @@ pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop)
/* Replace the integer argument with a suitable product by the object size. /* Replace the integer argument with a suitable product by the object size.
Do this multiplication as signed, then convert to the appropriate Do this multiplication as signed, then convert to the appropriate
pointer type (actually unsigned integral). */ type for the pointer operation. */
intop = convert (sizetype,
intop = build_binary_op (MULT_EXPR, intop, build_binary_op (MULT_EXPR, intop,
convert (TREE_TYPE (intop), size_exp), 1); convert (TREE_TYPE (intop), size_exp), 1));
/* Create the sum or difference. */
if (resultcode == MINUS_EXPR) if (resultcode == MINUS_EXPR)
intop = fold_build1 (NEGATE_EXPR, TREE_TYPE (intop), intop); intop = fold_build1 (NEGATE_EXPR, sizetype, intop);
intop = convert (sizetype, intop);
/* Create the sum or difference. */
ret = fold_build2 (POINTER_PLUS_EXPR, result_type, ptrop, intop); ret = fold_build2 (POINTER_PLUS_EXPR, result_type, ptrop, intop);
fold_undefer_and_ignore_overflow_warnings (); fold_undefer_and_ignore_overflow_warnings ();
......
2007-06-29 Eric Botcazou <ebotcazou@adacore.com>
* gcc.dg/pointer-arith-9.c: New test.
2007-06-29 Tobias Burnus <burnus@net-b.de> 2007-06-29 Tobias Burnus <burnus@net-b.de>
PR fortran/32483 PR fortran/32483
/* { dg-do compile } */
/* { dg-options "" } */
void *foo(void)
{
return (void *)0 - 1;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment