]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* gcc-interface/trans.c (gnat_to_gnu) <N_Assignment_Statement>: Do not
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 25 Apr 2010 09:22:35 +0000 (09:22 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 25 Apr 2010 09:22:35 +0000 (09:22 +0000)
use memmove if the array type is bit-packed.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158701 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/gcc-interface/trans.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/pack15.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/pack15.ads [new file with mode: 0644]

index 76aa31591c1355ee1319b401a31a59253d2db021..51f769cbd8db4a6b2a2d65fcfafe271167f2b081 100644 (file)
@@ -1,3 +1,8 @@
+2010-04-25  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/trans.c (gnat_to_gnu) <N_Assignment_Statement>: Do not
+       use memmove if the array type is bit-packed.
+
 2010-04-18  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interface/misc.c (gnat_init): Remove second argument in call to
index 71c9e862aba6aa17395c7438836ecb1329acd855..84fa13878707a480b923672c336c2aec44053e3b 100644 (file)
@@ -4797,10 +4797,12 @@ gnat_to_gnu (Node_Id gnat_node)
          gnu_result
            = build_binary_op (MODIFY_EXPR, NULL_TREE, gnu_lhs, gnu_rhs);
 
-         /* If the type being assigned is an array type and the two sides
-            are not completely disjoint, play safe and use memmove.  */
+         /* If the type being assigned is an array type and the two sides are
+            not completely disjoint, play safe and use memmove.  But don't do
+            it for a bit-packed array as it might not be byte-aligned.  */
          if (TREE_CODE (gnu_result) == MODIFY_EXPR
              && Is_Array_Type (Etype (Name (gnat_node)))
+             && !Is_Bit_Packed_Array (Etype (Name (gnat_node)))
              && !(Forwards_OK (gnat_node) && Backwards_OK (gnat_node)))
            {
              tree to, from, size, to_ptr, from_ptr, t;
index dd9da1aa4ec67854c4f32dbce93c868ad62eaaa7..6afd75b1c433c4ca13bb11af75218c07e3dd32ca 100644 (file)
@@ -1,3 +1,7 @@
+2010-04-25  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/pack15.ad[sb]: New test.
+
 2010-04-25  Paolo Bonzini  <bonzini@gnu.org>
 
        * gcc.target/arm/mla-1.c: New test.
diff --git a/gcc/testsuite/gnat.dg/pack15.adb b/gcc/testsuite/gnat.dg/pack15.adb
new file mode 100644 (file)
index 0000000..019b2da
--- /dev/null
@@ -0,0 +1,10 @@
+-- { dg-do compile }
+
+package body Pack15 is
+
+  procedure Transfer is
+  begin
+    O.Status_Flags := Status_Flags;
+  end;
+
+end Pack15;
diff --git a/gcc/testsuite/gnat.dg/pack15.ads b/gcc/testsuite/gnat.dg/pack15.ads
new file mode 100644 (file)
index 0000000..94be462
--- /dev/null
@@ -0,0 +1,22 @@
+package Pack15 is
+
+  type Flags is array (1..2) of Boolean;
+  for Flags'Component_Size use 1;
+
+  type Messages is record
+    Status_Flags : Flags;
+  end record;
+
+  for Messages use record
+    Status_Flags at 0 range 1 .. 2;
+  end record;
+
+  O : Messages;
+
+  Buffer : Integer;
+  Status_Flags : Flags;
+  for Status_Flags'Address use Buffer'Address;
+
+  procedure Transfer;
+
+end Pack15;