diff options
Diffstat (limited to 'gcc/cp/constexpr.c')
-rw-r--r-- | gcc/cp/constexpr.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 7d96d57..c946744 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -5582,20 +5582,17 @@ cxx_eval_increment_expression (const constexpr_ctx *ctx, tree t, /* Storing the modified value. */ tree store = build2_loc (cp_expr_loc_or_loc (t, input_location), MODIFY_EXPR, type, op, mod); - cxx_eval_constant_expression (ctx, store, - true, non_constant_p, overflow_p); + mod = cxx_eval_constant_expression (ctx, store, lval, + non_constant_p, overflow_p); ggc_free (store); + if (*non_constant_p) + return t; /* And the value of the expression. */ if (code == PREINCREMENT_EXPR || code == PREDECREMENT_EXPR) - { - /* Prefix ops are lvalues. */ - if (lval) - return op; - else - /* But we optimize when the caller wants an rvalue. */ - return mod; - } + /* Prefix ops are lvalues, but the caller might want an rvalue; + lval has already been taken into account in the store above. */ + return mod; else /* Postfix ops are rvalues. */ return val; |