re PR middle-end/23463 (va-arg-22.c execution fails)
authorAndrew Pinski <pinskia@physics.uc.edu>
Sat, 27 Aug 2005 21:37:53 +0000 (21:37 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Sat, 27 Aug 2005 21:37:53 +0000 (14:37 -0700)
2005-08-27  Andrew Pinski  <pinskia@physics.uc.edu>

        PR middle-end/23463
        * gimplify.c (gimplify_modify_expr_rhs): Remove check for zero sized
        types.
        (gimplify_modify_expr): Check for zero sized types and gimplify the
        rhs and lhs as statements.

2005-08-27  Andrew Pinski  <pinskia@physics.uc.edu>

        PR middle-end/23463
        * gcc.c-torture/execute/zero-struct-1.c: New test.

From-SVN: r103571

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/zero-struct-1.c [new file with mode: 0644]

index 68cdb6658b03e43371375993d2679841b733a21c..424e2caac76998ce1d25fcd8c3194960a4d3d523 100644 (file)
@@ -1,3 +1,11 @@
+2005-08-27  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR middle-end/23463
+       * gimplify.c (gimplify_modify_expr_rhs): Remove check for zero sized
+       types.
+       (gimplify_modify_expr): Check for zero sized types and gimplify the
+       rhs and lhs as statements.
+
 2005-08-27  John David Anglin  <dave.anflin@nrc-cnrc.gc.ca>
 
        PR libgcj/23508
index 9b34970647f1306e6d2f258191483f87d23a0126..7d76d66c507d0b24c3a31f83b3e497fa0e3c26d8 100644 (file)
@@ -2965,12 +2965,6 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p, tree *to_p, tree *pre_p,
                          tree *post_p, bool want_value)
 {
   enum gimplify_status ret = GS_OK;
-  tree type = TREE_TYPE (*from_p);
-  if (zero_sized_type (type))
-    {
-      *expr_p = NULL_TREE;
-      return GS_ALL_DONE;
-    }
 
   while (ret != GS_UNHANDLED)
     switch (TREE_CODE (*from_p))
@@ -3164,6 +3158,18 @@ gimplify_modify_expr (tree *expr_p, tree *pre_p, tree *post_p, bool want_value)
   /* The distinction between MODIFY_EXPR and INIT_EXPR is no longer useful.  */
   if (TREE_CODE (*expr_p) == INIT_EXPR)
     TREE_SET_CODE (*expr_p, MODIFY_EXPR);
+  
+  /* For zero sized types only gimplify the left hand side and right hand side
+     as statements and throw away the assignment.  */
+  if (zero_sized_type (TREE_TYPE (*from_p)))
+    {
+      gimplify_stmt (from_p);
+      gimplify_stmt (to_p);
+      append_to_statement_list (*from_p, pre_p);
+      append_to_statement_list (*to_p, pre_p);
+      *expr_p = NULL_TREE;
+      return GS_ALL_DONE;
+    }
 
   /* See if any simplifications can be done based on what the RHS is.  */
   ret = gimplify_modify_expr_rhs (expr_p, from_p, to_p, pre_p, post_p,
index be6077d61638a77a563890613cd89face43d7ecc..5821e1f8bc698f490d650d606d57f1a01fdc9e37 100644 (file)
@@ -1,3 +1,8 @@
+2005-08-27  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR middle-end/23463
+       * gcc.c-torture/execute/zero-struct-1.c: New test.
+
 2005-08-27  Richard Guenther  <rguenther@suse.de>
 
        PR target/23575
diff --git a/gcc/testsuite/gcc.c-torture/execute/zero-struct-1.c b/gcc/testsuite/gcc.c-torture/execute/zero-struct-1.c
new file mode 100644 (file)
index 0000000..d673adf
--- /dev/null
@@ -0,0 +1,23 @@
+struct g{};
+char y[3];
+char *f = &y[0];
+char *ff = &y[0];
+void h(void)
+{
+  struct g t;
+  *((struct g*)(f++)) = *((struct g*)(ff++));
+  *((struct g*)(f++)) = (struct g){};
+  t = *((struct g*)(ff++));
+}
+
+void abort (void);
+
+int main(void)
+{
+  h();
+  if (f != &y[2])
+    abort();
+  if (ff != &y[2])
+    abort();
+  return 0;
+}