decl.c (make_packable_type): If the new type has been given BLKmode, try again to...
authorEric Botcazou <ebotcazou@adacore.com>
Sat, 8 Sep 2007 10:02:28 +0000 (10:02 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sat, 8 Sep 2007 10:02:28 +0000 (10:02 +0000)
* decl.c (make_packable_type): If the new type has been given BLKmode,
try again to get an integral mode for it.

From-SVN: r128266

gcc/ada/ChangeLog
gcc/ada/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/unaligned_rep_clause.adb [new file with mode: 0644]

index b9e57dad69434aa1ed15eb77c7f201fe3722f596..e23d6b813c797b4c949c7091fbd8bfcc538b3cc0 100644 (file)
@@ -1,3 +1,8 @@
+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-07  Eric Botcazou  <ebotcazou@adacore.com>
 
        Re-apply accidentally reverted change:
index c293cea068eef2a93b0657684120b64d6d4688e5..7a01327c8652236db68ada20418d9e8619e3bfc9 100644 (file)
@@ -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;
 }
 \f
index 71d7f211a96497e2dcbfc9a7302699939f89989c..dd0a5285570879caed5d14ed275c1bc5170173bb 100644 (file)
@@ -1,3 +1,7 @@
+2007-09-08  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/unaligned_rep_clause.adb: New testcase.
+
 2007-09-08  Dorit Nuzman  <dorit@il.ibm.com>
 
        PR tree-optimization/33301
diff --git a/gcc/testsuite/gnat.dg/unaligned_rep_clause.adb b/gcc/testsuite/gnat.dg/unaligned_rep_clause.adb
new file mode 100644 (file)
index 0000000..b25c62e
--- /dev/null
@@ -0,0 +1,35 @@
+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;