This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Fix ICE on assignment to bit-packed component


This is a regression present on the mainline and 4.5 branch.  The compiler is 
trying to do a memmove to something that isn't aligned on a byte boundary and 
the RTL expander of ADDR_EXPR rightfully chokes.

Tested on i586-suse-linux, applied on the mainline and 4.5 branch.


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-25  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/pack15.ad[sb]: New test.


-- 
Eric Botcazou
Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c	(revision 158675)
+++ gcc-interface/trans.c	(working copy)
@@ -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;
-- { dg-do compile }

package body Pack15 is

  procedure Transfer is
  begin
    O.Status_Flags := Status_Flags;
  end;

end Pack15;
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;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]