+2017-05-22 Jakub Jelinek <jakub@redhat.com>
+
+ * c-fold.c (c_fully_fold_internal): Save the c_fully_fold_internal
+ result for SAVE_EXPR operand and set SAVE_EXPR_FOLDED_P even if
+ it returned invariant. Call tree_invariant_p unconditionally
+ afterwards to decide whether to return expr or op0.
+
2017-05-22 Nathan Sidwell <nathan@acm.org>
* c-decl.c (c_parse_final_cleanups): Drop TDI_tu handling.
case SAVE_EXPR:
/* Make sure to fold the contents of a SAVE_EXPR exactly once. */
+ op0 = TREE_OPERAND (expr, 0);
if (!SAVE_EXPR_FOLDED_P (expr))
{
- op0 = TREE_OPERAND (expr, 0);
op0 = c_fully_fold_internal (op0, in_init, maybe_const_operands,
maybe_const_itself, for_int_const);
- /* Don't wrap the folded tree in a SAVE_EXPR if we don't
- have to. */
- if (tree_invariant_p (op0))
- ret = op0;
- else
- {
- TREE_OPERAND (expr, 0) = op0;
- SAVE_EXPR_FOLDED_P (expr) = true;
- }
+ TREE_OPERAND (expr, 0) = op0;
+ SAVE_EXPR_FOLDED_P (expr) = true;
}
+ /* Return the SAVE_EXPR operand if it is invariant. */
+ if (tree_invariant_p (op0))
+ ret = op0;
goto out;
default: