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 unaligned representation clause


When Gigi is building the type of a record with a representation clause,
it attempts to make it possible to pack the components of the record as
much as possible by making "packable" types for them, i.e. types that
are suitable for bitwise manipulation by the back-end.

The problem here is that the back-end does not allow Gigi to make such a
type for a component whose type is a record type which itself contains
a composite type, thus leading to an ICE during RTL expansion.

The fix is to try harder in Gigi to make the type at stake.

Tested on i586-suse-linux, applied to mainline.


2007-09-08  Eric Botcazou  <ebotcazou@adacore.com>

	* decl.c (make_packable_type): If the new type has been given BLKmode,
	try again to get an integral mode for it.


2007-09-08  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/unaligned_rep_clause.adb: New testcase.


-- 
Eric Botcazou
Index: decl.c
===================================================================
--- decl.c	(revision 128261)
+++ decl.c	(working copy)
@@ -5218,6 +5218,13 @@ make_packable_type (tree type)
 
   finish_record_type (new_type, nreverse (field_list), 1, true);
   copy_alias_set (new_type, type);
+
+  /* Try harder to get a packable type if necessary, for example
+     in case the record itself contains a BLKmode field.  */
+  if (TYPE_MODE (new_type) == BLKmode)
+    TYPE_MODE (new_type)
+      = mode_for_size_tree (TYPE_SIZE (new_type), MODE_INT, 1);
+
   return TYPE_MODE (new_type) == BLKmode ? type : new_type;
 }
 
procedure Unaligned_Rep_Clause is

   type One_Bit_Record is
      record
         B : Boolean;
      end record;
   Pragma Pack(One_Bit_Record);

   subtype Version_Number_Type is String (1 .. 3);

   type Inter is
      record
         Version : Version_Number_Type;
      end record;

   type Msg_Type is
      record
         Status  : One_Bit_Record;
         Version : Inter;
      end record;

   for Msg_Type use
      record
         Status  at 0 range 0 .. 0;
         Version at 0 range 1 .. 24;
      end record;
   for Msg_Type'Size use 25;

   Data : Msg_Type;
   Pragma Warnings (Off, Data);
   Version : Inter;

begin
   Version := Data.Version;
end;

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