diff mbox

[Ada] Fix internal alignment issue

Message ID 1510481.GFra1aRlpr@polaris
State New
Headers show

Commit Message

Eric Botcazou June 1, 2015, 8:02 a.m. UTC
This fixes an old alignment issue with the _Parent field created by gigi for 
extension of tagged types: when the record type has a representation clause, 
the field is not correctly aligned, which leads to further issues downhill.

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


2015-06-01  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Type>: If the
	record has a parent field and a representation clause, make sure that
	it is properly aligned.
diff mbox

Patch

Index: gcc-interface/decl.c
===================================================================
--- gcc-interface/decl.c	(revision 223912)
+++ gcc-interface/decl.c	(working copy)
@@ -3019,6 +3019,12 @@  gnat_to_gnu_entity (Entity_Id gnat_entit
 	    else
 	      gnu_parent = gnat_to_gnu_type (gnat_parent);
 
+	    /* The parent field needs strict alignment so, if it is to
+	       be created with a component clause below, then we need
+	       to apply the same adjustment as in gnat_to_gnu_field.  */
+	    if (has_rep && TYPE_ALIGN (gnu_type) < TYPE_ALIGN (gnu_parent))
+	      TYPE_ALIGN (gnu_type) = TYPE_ALIGN (gnu_parent);
+
 	    /* Finally we fix up both kinds of twisted COMPONENT_REF we have
 	       initially built.  The discriminants must reference the fields
 	       of the parent subtype and not those of its base type for the