decl.c (gnat_to_gnu_entity): Add comment for the packed array type case.
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 7 Mar 2008 18:41:01 +0000 (18:41 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Fri, 7 Mar 2008 18:41:01 +0000 (18:41 +0000)
* decl.c (gnat_to_gnu_entity) <E_Modular_Integer_Subtype>: Add
comment for the packed array type case.
* utils.c (build_template): Use a loop to strip padding or
containing records for justified modular types.

From-SVN: r133014

gcc/ada/ChangeLog
gcc/ada/decl.c
gcc/ada/utils.c

index 9d92d7b732f5efde269b549ace2a5b5cfb61a8b6..5632ddfc694ee398f6083ca1a8b4368326962c70 100644 (file)
@@ -1,3 +1,10 @@
+2008-03-07  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * decl.c (gnat_to_gnu_entity) <E_Modular_Integer_Subtype>: Add
+       comment for the packed array type case.
+       * utils.c (build_template): Use a loop to strip padding or
+       containing records for justified modular types.
+
 2008-03-07  Eric Botcazou  <ebotcazou@adacore.com>
 
        * decl.c (gnat_to_gnu_entity): Issue a warning on suspiciously
index 48279391b3079c45540460979aacf69336160683..c1d02ec5d5eea23f56ffceb5eb7a6ed6198439d8 100644 (file)
@@ -1493,6 +1493,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
            = UI_To_gnu (RM_Size (gnat_entity), bitsizetype);
          gnu_type = make_node (RECORD_TYPE);
          TYPE_NAME (gnu_type) = create_concat_name (gnat_entity, "JM");
+
+         /* Propagate the alignment of the modular type to the record.
+            This means that bitpacked arrays have "ceil" alignment for
+            their size, which may seem counter-intuitive but makes it
+            possible to easily overlay them on modular types.  */
          TYPE_ALIGN (gnu_type) = TYPE_ALIGN (gnu_field_type);
          TYPE_USER_ALIGN (gnu_type) = TYPE_USER_ALIGN (gnu_field_type);
          TYPE_PACKED (gnu_type) = 1;
index bdce72a6d4dfa51bdd23883e1412deae6be16313..46ce865bdb4a6e5915e3a75fbd62e0ab9507622d 100644 (file)
@@ -2486,9 +2486,9 @@ build_template (tree template_type, tree array_type, tree expr)
   tree bound_list = NULL_TREE;
   tree field;
 
-  if (TREE_CODE (array_type) == RECORD_TYPE
-      && (TYPE_IS_PADDING_P (array_type)
-         || TYPE_JUSTIFIED_MODULAR_P (array_type)))
+  while (TREE_CODE (array_type) == RECORD_TYPE
+        && (TYPE_IS_PADDING_P (array_type)
+            || TYPE_JUSTIFIED_MODULAR_P (array_type)))
     array_type = TREE_TYPE (TYPE_FIELDS (array_type));
 
   if (TREE_CODE (array_type) == ARRAY_TYPE