diff options
Diffstat (limited to 'gcc/c-typeck.c')
-rw-r--r-- | gcc/c-typeck.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c index c086724b442..02d97b43f96 100644 --- a/gcc/c-typeck.c +++ b/gcc/c-typeck.c @@ -2926,8 +2926,13 @@ build_unary_op (enum tree_code code, tree xarg, int flag) when we have proper support for integer constant expressions. */ val = get_base_address (arg); if (val && TREE_CODE (val) == INDIRECT_REF - && integer_zerop (TREE_OPERAND (val, 0))) - return fold_convert (argtype, fold_offsetof (arg)); + && TREE_CONSTANT (TREE_OPERAND (val, 0))) + { + tree op0 = fold_convert (argtype, fold_offsetof (arg)), op1; + + op1 = fold_convert (argtype, TREE_OPERAND (val, 0)); + return fold_build2 (PLUS_EXPR, argtype, op0, op1); + } val = build1 (ADDR_EXPR, argtype, arg); |