re PR c++/31337 (ICE with statement expression)
authorJason Merrill <jason@redhat.com>
Mon, 27 Aug 2007 20:02:22 +0000 (16:02 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 27 Aug 2007 20:02:22 +0000 (16:02 -0400)
        PR c++/31337
        * gimplify.c (gimplify_modify_expr): Discard the assignment of
        zero-sized types after calling gimplify_modify_expr_rhs.
        * testsuite/g++.dg/ext/stmtexpr11.C: New.

From-SVN: r127838

gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ext/stmtexpr11.C [new file with mode: 0644]

index c58ff7533d37da3399b1756851304aeebdc814dd..995a7d4eaee705596f9ee7563492aa9853599736 100644 (file)
@@ -1,3 +1,9 @@
+2007-08-27  Jason Merrill  <jason@redhat.com>
+
+       PR c++/31337
+       * gimplify.c (gimplify_modify_expr): Discard the assignment of 
+       zero-sized types after calling gimplify_modify_expr_rhs.
+
 2007-08-27  Sandra Loosemore  <sandra@codesourcery.com>
 
        * regclass.c (init_reg_autoinc): Fix typo.
index cea79919965934f6bc015b32517bcae98d36b0db..aed8ab769496883b7ea995b0ecdae8fd672cdcb3 100644 (file)
@@ -3654,8 +3654,16 @@ gimplify_modify_expr (tree *expr_p, tree *pre_p, tree *post_p, bool want_value)
              || TREE_CODE (*expr_p) == GIMPLE_MODIFY_STMT
              || TREE_CODE (*expr_p) == INIT_EXPR);
 
-  /* For zero sized types only gimplify the left hand side and right hand side
-     as statements and throw away the assignment.  */
+  /* 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,
+                                 want_value);
+  if (ret != GS_UNHANDLED)
+    return ret;
+
+  /* For zero sized types only gimplify the left hand side and right hand
+     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)))
     {
       gimplify_stmt (from_p);
@@ -3666,12 +3674,6 @@ gimplify_modify_expr (tree *expr_p, tree *pre_p, tree *post_p, bool want_value)
       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,
-                                 want_value);
-  if (ret != GS_UNHANDLED)
-    return ret;
-
   /* If the value being copied is of variable width, compute the length
      of the copy into a WITH_SIZE_EXPR.   Note that we need to do this
      before gimplifying any of the operands so that we can resolve any
index 7dafb76b11a3fdbe748e3771aa992d4e415890b7..3795be363daa61eaecea253314f7ce5d911777f8 100644 (file)
@@ -1,3 +1,8 @@
+2007-08-27  Jason Merrill  <jason@redhat.com>
+
+       PR c++/31337
+       * g++.dg/ext/stmtexpr11.C: New.
+
 2007-08-27  Kazu Hirata  <kazu@codesourcery.com>
 
        * lib/target-supports.exp (check_profiling_available):
diff --git a/gcc/testsuite/g++.dg/ext/stmtexpr11.C b/gcc/testsuite/g++.dg/ext/stmtexpr11.C
new file mode 100644 (file)
index 0000000..8b5c5f8
--- /dev/null
@@ -0,0 +1,15 @@
+// PR c++/31337
+// { dg-options "" }
+
+struct A
+{
+  int i[0];
+  A();
+  A(const A&);
+  ~A();
+};
+
+void foo()
+{
+  A a = ({ A(); });
+}