re PR middle-end/46388 (ICE in int_mode_for_mode, at stor-layout.c:493)
authorJakub Jelinek <jakub@redhat.com>
Thu, 11 Nov 2010 15:48:39 +0000 (16:48 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 11 Nov 2010 15:48:39 +0000 (16:48 +0100)
PR middle-end/46388
* expr.c (expand_assignment): If to_rtx is a VOIDmode MEM, use
BLKmode mode for it.
(expand_expr_real_1): Similarly for op0.

* gcc.c-torture/compile/pr46388.c: New test.

From-SVN: r166603

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

index 1d686e9..1888e2f 100644 (file)
@@ -1,3 +1,10 @@
+2010-11-11  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/46388
+       * expr.c (expand_assignment): If to_rtx is a VOIDmode MEM, use
+       BLKmode mode for it.
+       (expand_expr_real_1): Similarly for op0.
+
 2010-11-11  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * doc/sourcebuild.texi (LTO Testing, dg-suppress-ld-options):
index cb73f01..d2aefd5 100644 (file)
@@ -4260,11 +4260,16 @@ expand_assignment (tree to, tree from, bool nontemporal)
       to_rtx = expand_normal (tem);
 
       /* If the bitfield is volatile, we want to access it in the
-        field's mode, not the computed mode.  */
-      if (volatilep
-         && GET_CODE (to_rtx) == MEM
-         && flag_strict_volatile_bitfields > 0)
-       to_rtx = adjust_address (to_rtx, mode1, 0);
+        field's mode, not the computed mode.
+        If a MEM has VOIDmode (external with incomplete type),
+        use BLKmode for it instead.  */
+      if (MEM_P (to_rtx))
+       {
+         if (volatilep && flag_strict_volatile_bitfields > 0)
+           to_rtx = adjust_address (to_rtx, mode1, 0);
+         else if (GET_MODE (to_rtx) == VOIDmode)
+           to_rtx = adjust_address (to_rtx, BLKmode, 0);
+       }
  
       if (offset != 0)
        {
@@ -9013,11 +9018,16 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
 
 
        /* If the bitfield is volatile, we want to access it in the
-          field's mode, not the computed mode.  */
-       if (volatilep
-           && GET_CODE (op0) == MEM
-           && flag_strict_volatile_bitfields > 0)
-         op0 = adjust_address (op0, mode1, 0);
+          field's mode, not the computed mode.
+          If a MEM has VOIDmode (external with incomplete type),
+          use BLKmode for it instead.  */
+       if (MEM_P (op0))
+         {
+           if (volatilep && flag_strict_volatile_bitfields > 0)
+             op0 = adjust_address (op0, mode1, 0);
+           else if (GET_MODE (op0) == VOIDmode)
+             op0 = adjust_address (op0, BLKmode, 0);
+         }
 
        mode2
          = CONSTANT_P (op0) ? TYPE_MODE (TREE_TYPE (tem)) : GET_MODE (op0);
index 26b24d3..7828567 100644 (file)
@@ -1,3 +1,8 @@
+2010-11-11  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/46388
+       * gcc.c-torture/compile/pr46388.c: New test.
+
 2010-11-11  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * lib/lto.exp (lto-get-options-main): Support optional target
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr46388.c b/gcc/testsuite/gcc.c-torture/compile/pr46388.c
new file mode 100644 (file)
index 0000000..74f60bb
--- /dev/null
@@ -0,0 +1,14 @@
+/* PR middle-end/46388 */
+
+struct S;
+struct T
+{
+  struct S *t;
+};
+extern struct S s, u;
+
+void
+foo (void)
+{
+  ((struct T *) &u)->t = &s;
+}