re PR tree-optimization/23402 (error: statement makes a memory store, but has no...
authorAndrew Pinski <pinskia@physics.uc.edu>
Wed, 17 Aug 2005 01:55:05 +0000 (01:55 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Wed, 17 Aug 2005 01:55:05 +0000 (18:55 -0700)
2005-08-16  Andrew Pinski  <pinskia@physics.uc.edu>

        PR tree-opt/23402
        * gcc.c-torture/compile/zero-strct-3.c: New test.
        * gcc.c-torture/compile/zero-strct-4.c: New test.

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

        PR tree-opt/23402
        * gimplify.c (zero_sized_type): New function.
        (gimplify_modify_expr_rhs): If we have a zero sized type,
        replace the statement with an empty statement.

From-SVN: r103191

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/zero-strct-3.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/compile/zero-strct-4.c [new file with mode: 0644]

index a1f447375cbfa620342484303636f7ac1174b2ac..4b77bfd1c3c202c4ca9d4be9079f8ef48dca3ce0 100644 (file)
@@ -1,3 +1,10 @@
+2005-08-16  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR tree-opt/23402
+       * gimplify.c (zero_sized_type): New function.
+       (gimplify_modify_expr_rhs): If we have a zero sized type,
+       replace the statement with an empty statement.
+
 2005-08-16  H.J. Lu  <hongjiu.lu@intel.com>
 
        * config/i386/crtfastmath.c (set_fast_math): Add "=m" for
index 41ca3b3bbb2adf45e558fb4742da7378eab4a610..a4ff3d23a2cd11f9d187e4d3cdf4b243b25c3382 100644 (file)
@@ -2533,6 +2533,17 @@ zero_sized_field_decl (tree fdecl)
   return false;
 }
 
+/* Return true if TYPE is zero sized.  */
+   
+static bool
+zero_sized_type (tree type)
+{
+  if (AGGREGATE_TYPE_P (type) && TYPE_SIZE (type)
+      && integer_zerop (TYPE_SIZE (type)))
+    return true;
+  return false;
+}
+
 /* A subroutine of gimplify_init_constructor.  Generate individual
    MODIFY_EXPRs for a CONSTRUCTOR.  OBJECT is the LHS against which the
    assignments should happen.  ELTS is the CONSTRUCTOR_ELTS of the
@@ -2949,6 +2960,12 @@ 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))
index 96be244e0c204091aa0428c0034d230fadc54294..b7e41c6487d4865db5fc9d7ca096f059a2eac90b 100644 (file)
@@ -1,3 +1,9 @@
+2005-08-16  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       PR tree-opt/23402
+       * gcc.c-torture/compile/zero-strct-3.c: New test.
+       * gcc.c-torture/compile/zero-strct-4.c: New test.
+
 2005-08-16  Steven Bosscher  <stevenb@suse.de>
 
        PR target/23376
diff --git a/gcc/testsuite/gcc.c-torture/compile/zero-strct-3.c b/gcc/testsuite/gcc.c-torture/compile/zero-strct-3.c
new file mode 100644 (file)
index 0000000..31bc328
--- /dev/null
@@ -0,0 +1,12 @@
+typedef struct {} spinlock_t;
+struct sk_buff_head {
+  int i;
+  spinlock_t lock;
+};
+struct sk_buff_head audit_skb_queue;
+void audit_init(void)
+{
+  struct sk_buff_head *list = &audit_skb_queue;
+  spinlock_t a = {};
+  audit_skb_queue.lock = a;
+}
diff --git a/gcc/testsuite/gcc.c-torture/compile/zero-strct-4.c b/gcc/testsuite/gcc.c-torture/compile/zero-strct-4.c
new file mode 100644 (file)
index 0000000..4a5889f
--- /dev/null
@@ -0,0 +1,14 @@
+typedef struct {} raw_spinlock_t;
+typedef struct {
+  raw_spinlock_t raw_lock;
+} spinlock_t;
+struct sk_buff_head {
+  int i;
+  spinlock_t lock;
+};
+struct sk_buff_head audit_skb_queue;
+void audit_init(void)
+{
+  struct sk_buff_head *list = &audit_skb_queue;
+  audit_skb_queue.lock = (spinlock_t) { .raw_lock = { } };
+}