re PR middle-end/44337 (ICE: in expand_assignment, at expr.c:4276)
authorJakub Jelinek <jakub@redhat.com>
Mon, 31 May 2010 15:42:10 +0000 (17:42 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 31 May 2010 15:42:10 +0000 (17:42 +0200)
PR middle-end/44337
* expr.c (expand_assignment): Don't store anything for out-of-bounds
array accesses with non-MEM.

* gcc.dg/pr44337.c: New test.

From-SVN: r160076

gcc/ChangeLog
gcc/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr44337.c [new file with mode: 0644]

index 30fe267e3bb8fb330298e65e9880728c3746d0f0..809ccb8640ead868cacc36585ee78b1feeb254ff 100644 (file)
@@ -1,5 +1,9 @@
 2010-05-31  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/44337
+       * expr.c (expand_assignment): Don't store anything for out-of-bounds
+       array accesses with non-MEM.
+
        PR tree-optimization/44182
        * tree-inline.c (copy_edges_for_bb): Don't split bb if a stmt that
        newly needs to end a bb is followed by debug stmts, instead return
index 82c037172095dc5b71ef9b409ceb0f44854fb412..6b2feb685a47250f9e7f801a7a7088fed736af38 100644 (file)
@@ -4268,8 +4268,19 @@ expand_assignment (tree to, tree from, bool nontemporal)
                                                                   offset));
        }
 
+      /* No action is needed if the target is not a memory and the field
+        lies completely outside that target.  This can occur if the source
+        code contains an out-of-bounds access to a small array.  */
+      if (!MEM_P (to_rtx)
+         && GET_MODE (to_rtx) != BLKmode
+         && (unsigned HOST_WIDE_INT) bitpos
+            >= GET_MODE_BITSIZE (GET_MODE (to_rtx)))
+       {
+         expand_normal (from);
+         result = NULL;
+       }
       /* Handle expand_expr of a complex value returning a CONCAT.  */
-      if (GET_CODE (to_rtx) == CONCAT)
+      else if (GET_CODE (to_rtx) == CONCAT)
        {
          if (COMPLEX_MODE_P (TYPE_MODE (TREE_TYPE (from))))
            {
index 4dc9a4158a391654b486767a38219a3c429ec8f2..abeee7e7f9bf75bee558013d1080640c3eed9e7f 100644 (file)
@@ -1,5 +1,8 @@
 2010-05-31  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/44337
+       * gcc.dg/pr44337.c: New test.
+
        PR tree-optimization/44182
        * g++.dg/debug/pr44182.C: New test.
 
diff --git a/gcc/testsuite/gcc.dg/pr44337.c b/gcc/testsuite/gcc.dg/pr44337.c
new file mode 100644 (file)
index 0000000..57e0549
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR middle-end/44337 */
+/* { dg-do compile } */
+/* { dg-options "-O -fno-tree-dce -fno-tree-dse -w" } */
+
+void
+foo (void)
+{
+  _Complex float v[1];
+  v[1] = 0;
+}