]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
stmt.c (expand_expr_stmt): Keep last_expr_value non-NULL iff we're interested in...
authorAlexandre Oliva <aoliva@redhat.com>
Tue, 4 Dec 2001 10:30:04 +0000 (10:30 +0000)
committerAlexandre Oliva <aoliva@gcc.gnu.org>
Tue, 4 Dec 2001 10:30:04 +0000 (10:30 +0000)
* 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.

From-SVN: r47607

gcc/ChangeLog
gcc/c-common.c
gcc/expr.c
gcc/stmt.c
gcc/tree.h

index fff9d986497039a2fae28a7989c33b2c1656174c..a27871443186f74cf81703e77647cc582b214f8f 100644 (file)
@@ -1,3 +1,15 @@
+2001-12-04  Alexandre Oliva  <aoliva@redhat.com>
+
+       * 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.
+
 2001-12-04  Jakub Jelinek  <jakub@redhat.com>
 
        * flow.c (ior_reg_cond): Return NULL if ! add and rtx wasn't optimized.
index a7d005b04ed4203656eafdbafd242addbb4709ca..41aaeb6057d0c7e5f447e4c2f69b55058906bb83 100644 (file)
@@ -3409,7 +3409,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 (target != const0_rtx);
        expand_stmt (STMT_EXPR_STMT (exp));
        expand_end_stmt_expr (rtl_expr);
        result = expand_expr (rtl_expr, target, tmode, modifier);
index 659ff032db4f2f48ed3b8194fd22f32ca7a9fdc5..1a4681e5b0050ceb7d7572f45d7c7d1220fdc1bc 100644 (file)
@@ -6528,7 +6528,9 @@ expand_expr (exp, target, tmode, modifier)
        if (EXPR_WFL_EMIT_LINE_NOTE (exp))
          emit_line_note (input_filename, lineno);
        /* Possibly avoid switching back and forth here.  */
-       to_return = expand_expr (EXPR_WFL_NODE (exp), target, tmode, modifier);
+       to_return = expand_expr (EXPR_WFL_NODE (exp),
+                                target || ! ignore ? target : const0_rtx,
+                                tmode, modifier);
        input_filename = saved_input_filename;
        lineno = saved_lineno;
        return to_return;
index 2b176bb9e9a58b90d2d59b85a774481a51186fc5..bfac270dd524229452c32d66d0caa6098c7bb8dd 100644 (file)
@@ -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;
 }
 
index 859a564b360e4fefe3cc20afc94455a42d7be1a0..9492b01e294095b8c59cc28d3d5775d53126cbc9 100644 (file)
@@ -2706,7 +2706,7 @@ extern int type_num_arguments                   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 int warn_if_unused_value                        PARAMS ((tree));