OSDN Git Service

PR middle-end/35432
authoraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 6 Aug 2008 10:25:22 +0000 (10:25 +0000)
committeraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 6 Aug 2008 10:25:22 +0000 (10:25 +0000)
        * gimplify.c (gimplify_modify_expr): Do not optimize zero-sized types
        if want_value.
 testsuite/
        * gcc.c-torture/compile/pr35432.c: New file.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@138793 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr35432.c [new file with mode: 0644]

index 3facfdb..b38ccbb 100644 (file)
@@ -1,3 +1,9 @@
+2008-08-06  Aldy Hernandez  <aldyh@redhat.com>
+
+       PR middle-end/35432
+       * gimplify.c (gimplify_modify_expr): Do not optimize zero-sized types
+       if want_value.
+
 2008-08-06  Jan Hubicka  <jh@suse.cz>
 
        * predict.c (maybe_hot_frequency_p): When profile is absent, all
index e7fc167..555a5b6 100644 (file)
@@ -4217,7 +4217,7 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
      side as statements and throw away the assignment.  Do this after
      gimplify_modify_expr_rhs so we handle TARGET_EXPRs of addressable
      types properly.  */
-  if (zero_sized_type (TREE_TYPE (*from_p)))
+  if (zero_sized_type (TREE_TYPE (*from_p)) && !want_value)
     {
       gimplify_stmt (from_p, pre_p);
       gimplify_stmt (to_p, pre_p);
index 7a1b82c..1e035f3 100644 (file)
@@ -1,3 +1,7 @@
+2008-08-06  Aldy Hernandez  <aldyh@redhat.com>
+       PR middle-end/35432
+       * gcc.c-torture/compile/pr35432.c: New file.
+
 2008-08-06  Arnaud Charlet  <charlet@adacore.com>
 
        * gnat.dg/iface_test.ad[s,b]: New test.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr35432.c b/gcc/testsuite/gcc.c-torture/compile/pr35432.c
new file mode 100644 (file)
index 0000000..6a0c921
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR middle-end/35432 */
+
+struct A
+{
+  char c[0];
+};
+
+void foo(struct A a)
+{
+  (a = a).c;
+}