aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2010-04-13 15:47:38 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2010-04-13 15:47:38 +0000
commit9e9ef331eb145aeff45079d4967c520ae4ff86a8 (patch)
tree04470a1e966906835dc05e1a512d55c9904ce185 /gcc/c-common.c
parent9db94baaef1eb984eb5ed91700b1091342831161 (diff)
downloadgcc-9e9ef331eb145aeff45079d4967c520ae4ff86a8.zip
gcc-9e9ef331eb145aeff45079d4967c520ae4ff86a8.tar.gz
gcc-9e9ef331eb145aeff45079d4967c520ae4ff86a8.tar.bz2
re PR middle-end/32628 (bogus integer overflow warning)
PR middle-end/32628 * c-common.c (pointer_int_sum): Disregard overflow that occured only because of sign-extension change when converting to sizetype here... * fold-const.c (fold_convert_const_int_from_int): ...and not here. * fold-const.c (fold_binary_op_with_conditional_arg): Do not restrict the folding to constants. Remove redundant final conversion. (fold_binary) <associate>: Do not associate if the re-association of constants alone overflows. (fold_binary) <FLOOR_MOD_EXPR>: Move transformation into BIT_AND_EXPR to the end of the list. (multiple_of_p) <COND_EXPR>: New case. From-SVN: r158274
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 5772b83..0669ba0 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -3806,12 +3806,18 @@ pointer_int_sum (location_t loc, enum tree_code resultcode,
TYPE_UNSIGNED (sizetype)), intop);
/* Replace the integer argument with a suitable product by the object size.
- Do this multiplication as signed, then convert to the appropriate
- type for the pointer operation. */
- intop = convert (sizetype,
- build_binary_op (loc,
- MULT_EXPR, intop,
- convert (TREE_TYPE (intop), size_exp), 1));
+ Do this multiplication as signed, then convert to the appropriate type
+ for the pointer operation and disregard an overflow that occured 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);
+ intop = convert (sizetype, t);
+ if (TREE_OVERFLOW_P (intop) && !TREE_OVERFLOW (t))
+ intop = build_int_cst_wide (TREE_TYPE (intop), TREE_INT_CST_LOW (intop),
+ TREE_INT_CST_HIGH (intop));
+ }
/* Create the sum or difference. */
if (resultcode == MINUS_EXPR)