From b2123dc0d8b3c18313c9aae7bddf57af0b4a6bf7 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Wed, 17 Apr 2002 01:47:36 +0000 Subject: [PATCH] c-common.h (STMT_EXPR_NO_SCOPE): New macro. * c-common.h (STMT_EXPR_NO_SCOPE): New macro. * c-common.c (c_expand_expr): Respect STMT_EXPR_NO_SCOPE. * tree.h (expand_start_stmt_expr): Update prototype. * stmt.c (expand_start_stmt_expr): Add has_scope parameter. * tree-inline.c (expand_call_inline): Set STMT_EXPR_NO_SCOPE on the STMT_EXPR created for the inline function. * trans.c (tree_transform): Add has_scope argument to expand_start_stmt_expr. * com.c (ffecom_expr_power_integer): Add has_scope argument to call to expand_start_stmt_expr. * init.c (begin_init_stmts): Remove commented out code. (finish_init_stmts): Set STMT_EXPR_NO_SCOPE. * semantics.c (begin_gobal_stmt_expr): Adjust call to expand_start_stmt_expr. From-SVN: r52395 --- gcc/ChangeLog | 9 +++++++++ gcc/ada/ChangeLog | 5 +++++ gcc/ada/trans.c | 2 +- gcc/c-common.c | 8 +++++++- gcc/c-common.h | 5 +++++ gcc/cp/ChangeLog | 7 +++++++ gcc/cp/init.c | 9 ++++----- gcc/cp/semantics.c | 2 +- gcc/f/ChangeLog | 5 +++++ gcc/f/com.c | 2 +- gcc/stmt.c | 17 ++++++++++++----- gcc/tree-inline.c | 2 ++ gcc/tree.h | 2 +- 13 files changed, 60 insertions(+), 15 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8f5e5761caa..f846e68d530 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -90,6 +90,15 @@ * config/alpha/gnu.h: New file for it. * config/gnu.h (TARGET_MEM_FUNCTIONS): #undef before #define. +2002-04-16 Mark Mitchell + + * c-common.h (STMT_EXPR_NO_SCOPE): New macro. + * c-common.c (c_expand_expr): Respect STMT_EXPR_NO_SCOPE. + * tree.h (expand_start_stmt_expr): Update prototype. + * stmt.c (expand_start_stmt_expr): Add has_scope parameter. + * tree-inline.c (expand_call_inline): Set STMT_EXPR_NO_SCOPE + on the STMT_EXPR created for the inline function. + 2002-04-15 Richard Henderson * config/alpha/linux.h, config/arm/linux-elf.h, config/i370/linux.h, diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 23ad1a99fbb..ebea5078dd1 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2002-04-16 Mark Mitchell + + * trans.c (tree_transform): Add has_scope argument to + expand_start_stmt_expr. + 2002-04-04 Neil Booth * gigi.h (truthvalue_conversion): Rename. diff --git a/gcc/ada/trans.c b/gcc/ada/trans.c index 38ae69c99da..63aafe4a62e 100644 --- a/gcc/ada/trans.c +++ b/gcc/ada/trans.c @@ -1770,7 +1770,7 @@ tree_transform (gnat_node) we need to make sure it gets executed after the LHS. */ gnu_lhs = gnat_to_gnu (Left_Opnd (gnat_node)); clear_last_expr (); - gnu_rhs_side = expand_start_stmt_expr (); + gnu_rhs_side = expand_start_stmt_expr (/*has_scope=*/1); gnu_rhs = gnat_to_gnu (Right_Opnd (gnat_node)); expand_end_stmt_expr (gnu_rhs_side); gnu_result_type = get_unpadded_type (Etype (gnat_node)); diff --git a/gcc/c-common.c b/gcc/c-common.c index 79dab3f7b0a..1e7a0656c55 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -3666,7 +3666,7 @@ c_expand_expr (exp, target, tmode, modifier) 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 (!STMT_EXPR_NO_SCOPE (exp)); /* If we want the result of this expression, find the last EXPR_STMT in the COMPOUND_STMT and mark it as addressable. */ @@ -3703,6 +3703,12 @@ c_expand_expr (exp, target, tmode, modifier) preserve_temp_slots (result); } + /* If the statment-expression does not have a scope, then the + new temporaries we created within it must live beyond the + statement-expression. */ + if (STMT_EXPR_NO_SCOPE (exp)) + preserve_temp_slots (NULL_RTX); + pop_temp_slots (); return result; } diff --git a/gcc/c-common.h b/gcc/c-common.h index 462e5bd7933..f0b92ed48dd 100644 --- a/gcc/c-common.h +++ b/gcc/c-common.h @@ -33,6 +33,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA DECL_PRETTY_FUNCTION_P (in VAR_DECL) NEW_FOR_SCOPE_P (in FOR_STMT) ASM_INPUT_P (in ASM_STMT) + STMT_EXPR_NO_SCOPE (in STMT_EXPR) 1: C_DECLARED_LABEL_FLAG (in LABEL_DECL) STMT_IS_FULL_EXPR_P (in _STMT) 2: STMT_LINENO_FOR_FN_P (in _STMT) @@ -654,6 +655,10 @@ extern tree strip_array_types PARAMS ((tree)); /* STMT_EXPR accessor. */ #define STMT_EXPR_STMT(NODE) TREE_OPERAND (STMT_EXPR_CHECK (NODE), 0) +/* Nonzero if this statement-expression does not have an associated scope. */ +#define STMT_EXPR_NO_SCOPE(NODE) \ + TREE_LANG_FLAG_0 (STMT_EXPR_CHECK (NODE)) + /* LABEL_STMT accessor. This gives access to the label associated with the given label statement. */ #define LABEL_STMT_LABEL(NODE) TREE_OPERAND (LABEL_STMT_CHECK (NODE), 0) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d19ea37435b..4f41e4f58a3 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2002-04-16 Mark Mitchell + + * init.c (begin_init_stmts): Remove commented out code. + (finish_init_stmts): Set STMT_EXPR_NO_SCOPE. + * semantics.c (begin_gobal_stmt_expr): Adjust call to + expand_start_stmt_expr. + 2002-04-15 Mark Mitchell * decl.c (register_dtor_fn): Pass the address of dso_handle, not diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 2143af4b665..49ecf7cc4b3 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -77,10 +77,6 @@ begin_init_stmts (stmt_expr_p, compound_stmt_p) if (building_stmt_tree ()) *compound_stmt_p = begin_compound_stmt (/*has_no_scope=*/1); - /* - else - *compound_stmt_p = genrtl_begin_compound_stmt (has_no_scope=1); - */ } /* Finish out the statement-expression begun by the previous call to @@ -96,7 +92,10 @@ finish_init_stmts (stmt_expr, compound_stmt) finish_compound_stmt (/*has_no_scope=*/1, compound_stmt); if (building_stmt_tree ()) - stmt_expr = finish_stmt_expr (stmt_expr); + { + stmt_expr = finish_stmt_expr (stmt_expr); + STMT_EXPR_NO_SCOPE (stmt_expr) = true; + } else stmt_expr = finish_global_stmt_expr (stmt_expr); diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index f53ac28a85e..0f53f6b1ece 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1186,7 +1186,7 @@ begin_global_stmt_expr () keep_next_level (1); - return (last_tree != NULL_TREE) ? last_tree : expand_start_stmt_expr(); + return last_tree ? last_tree : expand_start_stmt_expr(/*has_scope=*/1); } /* Finish the STMT_EXPR last begun with begin_global_stmt_expr. */ diff --git a/gcc/f/ChangeLog b/gcc/f/ChangeLog index 0e42bcc50c8..f8eedebab79 100644 --- a/gcc/f/ChangeLog +++ b/gcc/f/ChangeLog @@ -1,3 +1,8 @@ +Tue Apr 16 14:55:47 2002 Mark Mitchell + + * com.c (ffecom_expr_power_integer): Add has_scope argument to + call to expand_start_stmt_expr. + Mon Apr 15 10:59:14 2002 Mark Mitchell * g77.texi: Remove Chill reference. diff --git a/gcc/f/com.c b/gcc/f/com.c index f99c209c738..d0257855b10 100644 --- a/gcc/f/com.c +++ b/gcc/f/com.c @@ -5603,7 +5603,7 @@ ffecom_expr_power_integer_ (ffebld expr) basetypeof_l_is_int = build_int_2 ((TREE_CODE (ltype) == INTEGER_TYPE), 0); - se = expand_start_stmt_expr (); + se = expand_start_stmt_expr (/*has_scope=*/1); ffecom_start_compstmt (); diff --git a/gcc/stmt.c b/gcc/stmt.c index 32a1541cb05..fe0e718faa6 100644 --- a/gcc/stmt.c +++ b/gcc/stmt.c @@ -2405,12 +2405,16 @@ clear_last_expr () last_expr_type = 0; } -/* Begin a statement which will return a value. - Return the RTL_EXPR for this statement expr. - The caller must save that value and pass it to expand_end_stmt_expr. */ +/* Begin a statement-expression, i.e., a series of statements which + may return a value. Return the RTL_EXPR for this statement expr. + The caller must save that value and pass it to + expand_end_stmt_expr. If HAS_SCOPE is nonzero, temporaries created + in the statement-expression are deallocated at the end of the + expression. */ tree -expand_start_stmt_expr () +expand_start_stmt_expr (has_scope) + int has_scope; { tree t; @@ -2418,7 +2422,10 @@ expand_start_stmt_expr () so that rtl_expr_chain doesn't become garbage. */ t = make_node (RTL_EXPR); do_pending_stack_adjust (); - start_sequence_for_rtl_expr (t); + if (has_scope) + start_sequence_for_rtl_expr (t); + else + start_sequence (); NO_DEFER_POP; expr_stmts_for_value++; last_expr_value = NULL_RTX; diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index b255ee04338..759b55e1418 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -854,6 +854,8 @@ expand_call_inline (tp, walk_subtrees, data) type of the statement expression is the return type of the function call. */ expr = build1 (STMT_EXPR, TREE_TYPE (TREE_TYPE (fn)), NULL_TREE); + /* There is no scope associated with the statement-expression. */ + STMT_EXPR_NO_SCOPE (expr) = 1; /* Local declarations will be replaced by their equivalents in this map. */ diff --git a/gcc/tree.h b/gcc/tree.h index d0646b8042a..f96d127168f 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -2700,7 +2700,7 @@ extern tree lhd_unsave_expr_now PARAMS ((tree)); 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 void expand_expr_stmt_value PARAMS ((tree, int, int));