aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@multimania.com>2002-03-21 09:39:18 +0000
committerRichard Henderson <rth@gcc.gnu.org>2002-03-21 01:39:18 -0800
commit312687cfa88b0e5ee2600e0349bf285b826521b9 (patch)
treedb9e6c3c3b0671407dbf927358b92c97787e9d8d /gcc/c-common.c
parent48f90839b0860bf9f286f0f13972c4401caf9395 (diff)
downloadgcc-312687cfa88b0e5ee2600e0349bf285b826521b9.zip
gcc-312687cfa88b0e5ee2600e0349bf285b826521b9.tar.gz
gcc-312687cfa88b0e5ee2600e0349bf285b826521b9.tar.bz2
re PR c/5354 (function call with two statement expressions yields incorrect result)
PR c/5354 * c-common.c (c_expand_expr): Preserve result of a statement expression if needed. Co-Authored-By: Richard Henderson <rth@redhat.com> From-SVN: r51121
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 91f2a20..2892059 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -3574,6 +3574,7 @@ c_expand_expr (exp, target, tmode, modifier)
{
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.
@@ -3600,12 +3601,24 @@ c_expand_expr (exp, target, tmode, modifier)
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;
}