]> gcc.gnu.org Git - gcc.git/commitdiff
c-common.h (STMT_EXPR_NO_SCOPE): New macro.
authorMark Mitchell <mark@codesourcery.com>
Wed, 17 Apr 2002 01:47:36 +0000 (01:47 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 17 Apr 2002 01:47:36 +0000 (01:47 +0000)
* 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

13 files changed:
gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/trans.c
gcc/c-common.c
gcc/c-common.h
gcc/cp/ChangeLog
gcc/cp/init.c
gcc/cp/semantics.c
gcc/f/ChangeLog
gcc/f/com.c
gcc/stmt.c
gcc/tree-inline.c
gcc/tree.h

index 8f5e5761caa1590751e78a810b4dc33be43433c0..f846e68d530dacde2b0b12e0384390a52c2a38a9 100644 (file)
        * config/alpha/gnu.h: New file for it.
        * config/gnu.h (TARGET_MEM_FUNCTIONS): #undef before #define.
 
+2002-04-16  Mark Mitchell  <mark@codesourcery.com>
+
+       * 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  <rth@redhat.com>
 
        * config/alpha/linux.h, config/arm/linux-elf.h, config/i370/linux.h,
index 23ad1a99fbb35d835e372c5b968c5f75af2242ac..ebea5078dd169820494d99c04e6f3765a74c7597 100644 (file)
@@ -1,3 +1,8 @@
+2002-04-16  Mark Mitchell  <mark@codesourcery.com>
+
+       * trans.c (tree_transform): Add has_scope argument to
+       expand_start_stmt_expr.
+
 2002-04-04  Neil Booth  <neil@daikokuya.demon.co.uk>
 
        * gigi.h (truthvalue_conversion): Rename.
index 38ae69c99daf080746ad2863369e66f23fd2cf09..63aafe4a62eb72dd7ed02fcc6f6015a44abbaf21 100644 (file)
@@ -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));
index 79dab3f7b0ad5ade382932db61f52c24637ede2a..1e7a0656c5532de3e1003177eb1b1270c13b1d3b 100644 (file)
@@ -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;
       }
index 462e5bd7933870e8c0e734035d933ece3e265e87..f0b92ed48ddb5a00113675aa57280c78a0957f60 100644 (file)
@@ -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)
index d19ea37435baf9faf7d302d74d2952b8226189d7..4f41e4f58a3409df8aa2f1e890d400ced1650faa 100644 (file)
@@ -1,3 +1,10 @@
+2002-04-16  Mark Mitchell  <mark@codesourcery.com>
+
+       * 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  <mark@codesourcery.com>
 
        * decl.c (register_dtor_fn): Pass the address of dso_handle, not
index 2143af4b6656e6fd37649ff60e5455e9c322c4c7..49ecf7cc4b334a33ba9bac99ea3eb38f140b04aa 100644 (file)
@@ -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);
   
index f53ac28a85e6e4c09b15c7caaee57cf8a9dc9ed2..0f53f6b1ece069c559c9e99cec0854d5f180ce7b 100644 (file)
@@ -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.  */
index 0e42bcc50c8b156b6d636372fe0cc85425a97777..f8eedebab791127755eeb48baf62c8703ac82440 100644 (file)
@@ -1,3 +1,8 @@
+Tue Apr 16 14:55:47 2002  Mark Mitchell  <mark@codesourcery.com>
+
+       * 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  <mark@codesourcery.com>
 
        * g77.texi: Remove Chill reference.
index f99c209c73879b78bac9118ed0289f88192b527c..d0257855b10fc936c15d911f485379c21622d9d1 100644 (file)
@@ -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 ();
 
index 32a1541cb057973c2658ad4bdb9915fff6628e31..fe0e718faa66ba7387605db190e10b940b334c6c 100644 (file)
@@ -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;
index b255ee043381d93d4040c38775371573535ed71f..759b55e141813c12d9efe61820fa23b708ba737b 100644 (file)
@@ -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.  */
index d0646b8042ab2f470bba78328666dbe53129ab50..f96d127168f103d76869cd2dac958e58e42bd9b0 100644 (file)
@@ -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));
This page took 0.098176 seconds and 5 git commands to generate.