+2002-03-21 Eric Botcazou <ebotcazou@multimania.com>
+ Richard Henderson <rth@redhat.com>
+
+ PR c/5354
+ * c-common.c (c_expand_expr): Preserve result of a statement
+ expression if needed.
+
2002-03-21 Jakub Jelinek <jakub@redhat.com>
PR bootstrap/4195
{
tree rtl_expr;
rtx result;
+ bool preserve_result = false;
/* Since expand_expr_stmt calls free_temp_slots after every
expression statement, we must call push_temp_slots here.
if (TREE_CODE (last) == SCOPE_STMT
&& TREE_CODE (expr) == EXPR_STMT)
- TREE_ADDRESSABLE (expr) = 1;
+ {
+ TREE_ADDRESSABLE (expr) = 1;
+ preserve_result = true;
+ }
}
expand_stmt (STMT_EXPR_STMT (exp));
expand_end_stmt_expr (rtl_expr);
+
result = expand_expr (rtl_expr, target, tmode, modifier);
+ if (preserve_result && GET_CODE (result) == MEM)
+ {
+ if (GET_MODE (result) != BLKmode)
+ result = copy_to_reg (result);
+ else
+ preserve_temp_slots (result);
+ }
+
pop_temp_slots ();
return result;
}
--- /dev/null
+/* PR c/5354 */
+/* Verify that GCC preserves relevant stack slots. */
+
+extern void abort(void);
+extern void exit(int);
+
+struct large { int x, y[9]; };
+
+int main()
+{
+ int fixed;
+
+ fixed = ({ int temp1 = 2; temp1; }) - ({ int temp2 = 1; temp2; });
+ if (fixed != 1)
+ abort();
+
+ fixed = ({ struct large temp3; temp3.x = 2; temp3; }).x
+ - ({ struct large temp4; temp4.x = 1; temp4; }).x;
+ if (fixed != 1)
+ abort();
+
+ exit(0);
+}