diff options
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 71a1d3e..3ab1a9a 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -8523,7 +8523,12 @@ build_fold_addr_expr_with_type_loc (location_t loc, tree t, tree ptrtype) } else if (TREE_CODE (t) == MEM_REF && integer_zerop (TREE_OPERAND (t, 1))) - return TREE_OPERAND (t, 0); + { + t = TREE_OPERAND (t, 0); + + if (TREE_TYPE (t) != ptrtype) + t = fold_convert_loc (loc, ptrtype, t); + } else if (TREE_CODE (t) == MEM_REF && TREE_CODE (TREE_OPERAND (t, 0)) == INTEGER_CST) return fold_binary (POINTER_PLUS_EXPR, ptrtype, |