aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2002-01-02 02:31:58 +0000
committerAlexandre Oliva <aoliva@gcc.gnu.org>2002-01-02 02:31:58 +0000
commit1574ef130fb3149f09b3a1b36c65873a6e494582 (patch)
tree88f850f8f5e7beb19776302640e41667d82628ef /gcc/c-common.c
parent6180abdb9dfdb541014932a732916a47a8bab8a5 (diff)
downloadgcc-1574ef130fb3149f09b3a1b36c65873a6e494582.zip
gcc-1574ef130fb3149f09b3a1b36c65873a6e494582.tar.gz
gcc-1574ef130fb3149f09b3a1b36c65873a6e494582.tar.bz2
c-common.h (genrtl_expr_stmt_value): Declare.
* c-common.h (genrtl_expr_stmt_value): Declare. * c-semantics.c (genrtl_goto_stmt): Redirect to... (genrtl_goto_stmt_value): ... this new function. Pass new argument down to expand_expr_stmt_value, taking TREE_ADDRESSABLE into account. * c-common.c (c_expand_expr): Mark the last EXPR_STMT of a STMT_EXPR as addressable, i.e., one whose result we want. * expr.c (expand_expr): Don't save expression statement value of labeled_blocks or loop_exprs. * stmt.c (expand_expr_stmt): Redirect to... (expand_expr_stmt_value): ... this new function. Use new argument to tell whether to save expression value. (expand_end_stmt_expr): Reset last_expr_type and last_expr_value if we don't have either. * tree-inline.c (declare_return_variable): Mark its use statement as addressable. * tree.h: Document new use of TREE_ADDRESSABLE. (expand_expr_stmt_value): Declare. From-SVN: r48456
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index d671e3b..39ae17d 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -1,6 +1,6 @@
/* Subroutines shared by all languages that are variants of C.
- Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
- Free Software Foundation, Inc.
+ Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+ 2001, 2002 Free Software Foundation, Inc.
This file is part of GCC.
@@ -3418,6 +3418,27 @@ c_expand_expr (exp, target, tmode, modifier)
STMT_EXPR. */
push_temp_slots ();
rtl_expr = expand_start_stmt_expr ();
+
+ /* If we want the result of this expression, find the last
+ EXPR_STMT in the COMPOUND_STMT and mark it as addressable. */
+ if (target != const0_rtx
+ && TREE_CODE (STMT_EXPR_STMT (exp)) == COMPOUND_STMT
+ && TREE_CODE (COMPOUND_BODY (STMT_EXPR_STMT (exp))) == SCOPE_STMT)
+ {
+ tree expr = COMPOUND_BODY (STMT_EXPR_STMT (exp));
+ tree last = TREE_CHAIN (expr);
+
+ while (TREE_CHAIN (last))
+ {
+ expr = last;
+ last = TREE_CHAIN (last);
+ }
+
+ if (TREE_CODE (last) == SCOPE_STMT
+ && TREE_CODE (expr) == EXPR_STMT)
+ TREE_ADDRESSABLE (expr) = 1;
+ }
+
expand_stmt (STMT_EXPR_STMT (exp));
expand_end_stmt_expr (rtl_expr);
result = expand_expr (rtl_expr, target, tmode, modifier);