gimplify.c (eval_save_expr): New.
authorRichard Henderson <rth@redhat.com>
Tue, 21 Dec 2004 19:27:08 +0000 (11:27 -0800)
committerRichard Henderson <rth@gcc.gnu.org>
Tue, 21 Dec 2004 19:27:08 +0000 (11:27 -0800)
        * gimplify.c (eval_save_expr): New.
        (gimplify_one_sizepos): Use it.
        * stor-layout.c (layout_type): Unshare TYPE_MIN/MAX_VALUE.

From-SVN: r92468

gcc/ChangeLog
gcc/gimplify.c
gcc/stor-layout.c

index 262600c02e2b2f31bad8c224f25b984e8408e445..b9fbcfb0073229c1f18923765c7f203682183009 100644 (file)
@@ -1,3 +1,9 @@
+2004-12-21  Richard Henderson  <rth@redhat.com>
+
+       * gimplify.c (eval_save_expr): New.
+       (gimplify_one_sizepos): Use it.
+       * stor-layout.c (layout_type): Unshare TYPE_MIN/MAX_VALUE.
+
 2004-12-21  Nathan Sidwell  <nathan@codesourcery.com>
 
        * system.c (IN_RANGE): Use plain unsigned, not unsigned
index 34b22cc678175b70d83980868993afc1e20ab03a..c92d9a5e4bce91ed47a084c05ff9707b1f5a9247 100644 (file)
@@ -4217,7 +4217,25 @@ gimplify_type_sizes (tree type, tree *list_p)
   gimplify_one_sizepos (&TYPE_SIZE_UNIT (type), list_p);
 }
 
-/* Subroutine of the above to gimplify one size or position, *EXPR_P.
+/* A subroutine of gimplify_one_sizepos, called via walk_tree.  Evaluate
+   the expression if it's a SAVE_EXPR and add it to the statement list 
+   in DATA.  */
+
+static tree
+eval_save_expr (tree *tp, int *walk_subtrees, void *data)
+{
+  if (TREE_CODE (*tp) == SAVE_EXPR)
+    {
+      *walk_subtrees = 0;
+      gimplify_and_add (*tp, (tree *) data);
+    }
+  else if (TYPE_P (*tp) || DECL_P (*tp))
+    *walk_subtrees = 0;
+  return NULL;
+}
+
+/* A subroutine of gimplify_type_sizes to make sure that *EXPR_P,
+   a size or position, has had all of its SAVE_EXPRs evaluated.
    We add any required statements to STMT_P.  */
 
 void
@@ -4233,7 +4251,7 @@ gimplify_one_sizepos (tree *expr_p, tree *stmt_p)
       || CONTAINS_PLACEHOLDER_P (*expr_p))
     return;
 
-  gimplify_expr (expr_p, stmt_p, NULL, is_gimple_val, fb_rvalue);
+  walk_tree (expr_p, eval_save_expr, stmt_p, NULL);
 }
 \f
 #ifdef ENABLE_CHECKING
index 7069ad9b2eca0c6825eeae160fedc01411cac04f..13fdb3cf14cbafb422614961f45c5802804556c1 100644 (file)
@@ -1644,8 +1644,8 @@ layout_type (tree type)
        if (index && TYPE_MAX_VALUE (index) && TYPE_MIN_VALUE (index)
            && TYPE_SIZE (element))
          {
-           tree ub = TYPE_MAX_VALUE (index);
-           tree lb = TYPE_MIN_VALUE (index);
+           tree ub = unshare_expr (TYPE_MAX_VALUE (index));
+           tree lb = unshare_expr (TYPE_MIN_VALUE (index));
            tree length;
            tree element_size;