+2001-12-04 Alexandre Oliva <aoliva@redhat.com>
+
+ * stmt.c (expand_expr_stmt): Keep last_expr_value non-NULL iff
+ we're interested in the result. Use it to tell whether to
+ ignore results of enclosed expressions.
+ (expand_start_stmt_expr): Added new argument, and initialize
+ last_expr_value accordingly.
+ * tree.h (expand_start_stmt_expr): Adjusted declaration.
+ * c-common.c (c_expand_expr): Adjust call.
+ * expr.c (expand_expr) [EXPR_WFL]: Pass const0_rtx down if
+ ignoring the result.
+
2001-12-04 Jakub Jelinek <jakub@redhat.com>
* flow.c (ior_reg_cond): Return NULL if ! add and rtx wasn't optimized.
out-of-scope after the first EXPR_STMT from within the
STMT_EXPR. */
push_temp_slots ();
- rtl_expr = expand_start_stmt_expr ();
+ rtl_expr = expand_start_stmt_expr (target != const0_rtx);
expand_stmt (STMT_EXPR_STMT (exp));
expand_end_stmt_expr (rtl_expr);
result = expand_expr (rtl_expr, target, tmode, modifier);
if (EXPR_WFL_EMIT_LINE_NOTE (exp))
emit_line_note (input_filename, lineno);
/* Possibly avoid switching back and forth here. */
- to_return = expand_expr (EXPR_WFL_NODE (exp), target, tmode, modifier);
+ to_return = expand_expr (EXPR_WFL_NODE (exp),
+ target || ! ignore ? target : const0_rtx,
+ tmode, modifier);
input_filename = saved_input_filename;
lineno = saved_lineno;
return to_return;
expand_expr_stmt (exp)
tree exp;
{
+ bool want_value = last_expr_value != NULL_RTX;
+
/* If -W, warn about statements with no side effects,
except for an explicit cast to void (e.g. for assert()), and
except inside a ({...}) where they may be useful. */
last_expr_value to get reset. Therefore, we set last_expr_value
and last_expr_type *after* calling expand_expr. */
last_expr_value = expand_expr (exp,
- (expr_stmts_for_value
+ (want_value && expr_stmts_for_value
? NULL_RTX : const0_rtx),
VOIDmode, 0);
last_expr_type = TREE_TYPE (exp);
if (TYPE_MODE (TREE_TYPE (exp)) == VOIDmode)
;
else if (TYPE_MODE (TREE_TYPE (exp)) != BLKmode)
- copy_to_reg (last_expr_value);
+ last_expr_value = copy_to_reg (last_expr_value);
else
{
rtx lab = gen_label_rtx ();
above. */
free_temp_slots ();
+ if (! want_value && last_expr_value)
+ {
+ protect_from_queue (last_expr_value, 0);
+ last_expr_value = NULL_RTX;
+ }
+ else if (want_value && ! last_expr_value)
+ last_expr_value = const0_rtx;
+
emit_queue ();
}
The caller must save that value and pass it to expand_end_stmt_expr. */
tree
-expand_start_stmt_expr ()
+expand_start_stmt_expr (want_value)
+ int want_value;
{
tree t;
start_sequence_for_rtl_expr (t);
NO_DEFER_POP;
expr_stmts_for_value++;
+ last_expr_value = want_value ? const0_rtx : NULL_RTX;
return t;
}
extern int in_control_zone_p PARAMS ((void));
extern void expand_fixups PARAMS ((rtx));
-extern tree expand_start_stmt_expr PARAMS ((void));
+extern tree expand_start_stmt_expr PARAMS ((int));
extern tree expand_end_stmt_expr PARAMS ((tree));
extern void expand_expr_stmt PARAMS ((tree));
extern int warn_if_unused_value PARAMS ((tree));