diff options
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r-- | gcc/c-common.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c index ccbc479..9bad32d 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -2700,12 +2700,16 @@ pointer_int_sum (enum tree_code resultcode, tree ptrop, tree intop) Do this multiplication as signed, then convert to the appropriate pointer type (actually unsigned integral). */ - intop = convert (result_type, - build_binary_op (MULT_EXPR, intop, - convert (TREE_TYPE (intop), size_exp), 1)); + intop = build_binary_op (MULT_EXPR, intop, + convert (TREE_TYPE (intop), size_exp), 1); + + if (resultcode == MINUS_EXPR) + intop = fold_build1 (NEGATE_EXPR, TREE_TYPE (intop), intop); + + intop = convert (sizetype, intop); /* Create the sum or difference. */ - ret = fold_build2 (resultcode, result_type, ptrop, intop); + ret = fold_build2 (POINTER_PLUS_EXPR, result_type, ptrop, intop); fold_undefer_and_ignore_overflow_warnings (); |