expr.c (store_expr): Fix order of store_by_pieces arguments.
authorJakub Jelinek <jakub@gcc.gnu.org>
Sat, 25 Aug 2007 07:28:43 +0000 (09:28 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Sat, 25 Aug 2007 07:28:43 +0000 (09:28 +0200)
* expr.c (store_expr): Fix order of store_by_pieces arguments.

* gcc.dg/array-init-2.c: New test.

From-SVN: r127795

gcc/ChangeLog
gcc/expr.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/array-init-2.c [new file with mode: 0644]

index cd929650abc1416c242a0e740f9e60df164a0165..fefb4b6052de0c4531f2cb32cedac61d2c6a32c4 100644 (file)
@@ -1,3 +1,7 @@
+2007-08-25  Jakub Jelinek  <jakub@redhat.com>
+
+       * expr.c (store_expr): Fix order of store_by_pieces arguments.
+
 2007-08-24  Sandra Loosemore  <sandra@codesourcery.com>
             Nigel Stephens <nigel@mips.com>
 
@@ -8,7 +12,7 @@
        * expr.c (SET_BY_PIECES_P): Define.
        (can_store_by_pieces, store_by_pieces): Add MEMSETP argument; use
        it to decide whether to use SET_BY_PIECES_P or STORE_BY_PIECES_P.
-       (store_expr):  Pass MEMSETP argument to can_store_by_pieces and
+       (store_expr): Pass MEMSETP argument to can_store_by_pieces and
        store_by_pieces.
        * expr.h (SET_RATIO): Define.
        (can_store_by_pieces, store_by_pieces): Update prototypes.
index 244604000a9e0d51d05d39d05a66658f517ffe50..21128958e73822c6e8430b897a940692006aaab0 100644 (file)
@@ -4519,9 +4519,8 @@ store_expr (tree exp, rtx target, int call_param_p, bool nontemporal)
       dest_mem = store_by_pieces (dest_mem,
                                  str_copy_len, builtin_strncpy_read_str,
                                  (void *) TREE_STRING_POINTER (exp),
-                                 MEM_ALIGN (target),
-                                 exp_len > str_copy_len ? 1 : 0,
-                                 false);
+                                 MEM_ALIGN (target), false,
+                                 exp_len > str_copy_len ? 1 : 0);
       if (exp_len > str_copy_len)
        clear_storage (dest_mem, GEN_INT (exp_len - str_copy_len),
                       BLOCK_OP_NORMAL);
index 11f33388bca4f1b9ddde7bc91bcdf055645a2407..7547f4b4892e6641562158e9b54c59190514f2eb 100644 (file)
@@ -1,3 +1,7 @@
+2007-08-25  Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.dg/array-init-2.c: New test.
+
 2007-08-24  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/33178
diff --git a/gcc/testsuite/gcc.dg/array-init-2.c b/gcc/testsuite/gcc.dg/array-init-2.c
new file mode 100644 (file)
index 0000000..9c42581
--- /dev/null
@@ -0,0 +1,51 @@
+/* Test array initializion by store_by_pieces.  */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+struct A { char c[10]; };
+extern void abort (void);
+
+void
+__attribute__((noinline))
+check (struct A * a, int b)
+{
+  const char *p;
+  switch (b)
+    {
+    case 0:
+      p = "abcdefghi";
+      break;
+    case 1:
+      p = "j\0\0\0\0\0\0\0\0";
+      break;
+    case 2:
+      p = "kl\0\0\0\0\0\0\0";
+      break;
+    case 3:
+      p = "mnop\0\0\0\0\0";
+      break;
+    case 4:
+      p = "qrstuvwx\0";
+      break;
+    default:
+      abort ();
+    }
+  if (__builtin_memcmp (a->c, p, 10) != 0)
+    abort ();
+}
+
+int
+main (void)
+{
+  struct A a = { "abcdefghi" };
+  check (&a, 0);
+  struct A b = { "j" };
+  check (&b, 1);
+  struct A c = { "kl" };
+  check (&c, 2);
+  struct A d = { "mnop" };
+  check (&d, 3);
+  struct A e = { "qrstuvwx" };
+  check (&e, 4);
+  return 0;
+}