diff options
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index cfd382991d3..0bbb439324b 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -2543,7 +2543,7 @@ shorten_compare (tree *op0_ptr, tree *op1_ptr, tree *restype_ptr, tree pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop) { - tree size_exp; + tree size_exp, ret; /* The result is a pointer of the same type that is being added. */ @@ -2570,6 +2570,12 @@ pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop) else size_exp = size_in_bytes (TREE_TYPE (result_type)); + /* We are manipulating pointer values, so we don't need to warn + about relying on undefined signed overflow. We disable the + warning here because we use integer types so fold won't know that + they are really pointers. */ + fold_defer_overflow_warnings (); + /* If what we are about to multiply by the size of the elements contains a constant term, apply distributive law and multiply that constant term separately. @@ -2618,7 +2624,11 @@ pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop) convert (TREE_TYPE (intop), size_exp), 1)); /* Create the sum or difference. */ - return fold_build2 (resultcode, result_type, ptrop, intop); + ret = fold_build2 (resultcode, result_type, ptrop, intop); + + fold_undefer_and_ignore_overflow_warnings (); + + return ret; } /* Return whether EXPR is a declaration whose address can never be |