summaryrefslogtreecommitdiff
path: root/gcc/stmt.c
diff options
context:
space:
mode:
authoraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>2001-12-04 10:30:04 +0000
committeraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>2001-12-04 10:30:04 +0000
commit5b365acda95d11923460e307b1c0f2ec2fdcb31a (patch)
tree764fcb1b30f9b79f8a0f0dc4fa3f07a61527c096 /gcc/stmt.c
parentdf10b42593a9a2bb76b56c9766647630d03c0c74 (diff)
downloadgcc-5b365acda95d11923460e307b1c0f2ec2fdcb31a.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@47607 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/stmt.c')
-rw-r--r--gcc/stmt.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/gcc/stmt.c b/gcc/stmt.c
index 2b176bb9e9a..bfac270dd52 100644
--- a/gcc/stmt.c
+++ b/gcc/stmt.c
@@ -2149,6 +2149,8 @@ void
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. */
@@ -2175,7 +2177,7 @@ expand_expr_stmt (exp)
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);
@@ -2188,7 +2190,7 @@ expand_expr_stmt (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 ();
@@ -2211,6 +2213,14 @@ expand_expr_stmt (exp)
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 ();
}
@@ -2336,7 +2346,8 @@ clear_last_expr ()
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;
@@ -2347,6 +2358,7 @@ expand_start_stmt_expr ()
start_sequence_for_rtl_expr (t);
NO_DEFER_POP;
expr_stmts_for_value++;
+ last_expr_value = want_value ? const0_rtx : NULL_RTX;
return t;
}