diff mbox

[Ada] Fix internal error on aggregate with small misaligned field

Message ID 2518340.Lv9NPpTPbW@polaris
State New
Headers show

Commit Message

Eric Botcazou March 6, 2013, 5:59 p.m. UTC
This is another regression present on the mainline.  The compiler aborts on an 
aggregate whose type is a record type with a misaligned scalar component and
with a representation clause for this component that gives it a size smaller 
than the default.  We're incorrectly laying out the type.

Tested on x86_64-suse-linux, applied on the mainline.


2013-03-06  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/decl.c (gnat_to_gnu_field): Remove the wrapper around
	a misaligned integral type if a size is specified for the field.


2013-03-06  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/specs/aggr6.ads: New test.
diff mbox

Patch

Index: gcc-interface/decl.c
===================================================================
--- gcc-interface/decl.c	(revision 196487)
+++ gcc-interface/decl.c	(working copy)
@@ -6619,6 +6619,13 @@  gnat_to_gnu_field (Entity_Id gnat_field,
 	       <= 0)
 	gnu_field_type = TREE_TYPE (TYPE_FIELDS (gnu_field_type));
 
+      /* Similarly if the field's type is a misaligned integral type, but
+	 there is no restriction on the size as there is no justification.  */
+      if (!needs_strict_alignment
+	  && TYPE_IS_PADDING_P (gnu_field_type)
+	  && INTEGRAL_TYPE_P (TREE_TYPE (TYPE_FIELDS (gnu_field_type))))
+	gnu_field_type = TREE_TYPE (TYPE_FIELDS (gnu_field_type));
+
       gnu_field_type
 	= make_type_from_size (gnu_field_type, gnu_size,
 			       Has_Biased_Representation (gnat_field));