]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/35432 (ICE with zero-sized array)
authorAldy Hernandez <aldyh@redhat.com>
Wed, 6 Aug 2008 10:41:39 +0000 (10:41 +0000)
committerAldy Hernandez <aldyh@gcc.gnu.org>
Wed, 6 Aug 2008 10:41:39 +0000 (10:41 +0000)
        PR middle-end/35432
        * gimplify.c (gimplify_modify_expr): Do not optimize zero-sized types
        if want_value.
 testsuite/
        * gcc.c-torture/compile/pr35432.c: New file.

From-SVN: r138796

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

index 0ec48495f51f1faf562e3f3481050ca516e821a8..b78472ea0ec75660390bb58d343df8b5a19a4e2d 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-07-04  Alan Modra  <amodra@bigpond.net.au>
 
        PR target/36634
index fa2035bc39c9377f8e8f02d9c2840d66939bd497..ea43aaf64bf515707998a2de293ce4b52d98bd40 100644 (file)
@@ -3540,7 +3540,7 @@ gimplify_modify_expr (tree *expr_p, tree *pre_p, tree *post_p, bool want_value)
      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);
       gimplify_stmt (to_p);
index b18bb71184a8e6300070a5d92176054c5aa9e397..4491ffee3513e82586bba7c351a8b6a8fcfe2a61 100644 (file)
@@ -1,3 +1,8 @@
+2008-08-06  Aldy Hernandez  <aldyh@redhat.com>
+
+       PR middle-end/35432
+       * gcc.c-torture/compile/pr35432.c: New file.
+
 2008-05-29  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc.dg/nested-func-6.c: 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;
+}