Commit c00d5b12 by Eric Botcazou Committed by Eric Botcazou

decl.c (gnat_to_gnu_entity): During layout in type_annotate_only mode...

	* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Type>: During
	layout in type_annotate_only mode, skip discriminants of derived
	tagged types renaming those of the parent type.
	In type_annotate_only mode, if the type is tagged, do not override a
	size clause but take into account the alignment of the tag.
	(annotate_rep): In type_annotate_only mode, deal with  discriminants
	of derived tagged types renaming those of the parent type.

From-SVN: r231860
parent 80746f5d
2015-12-20 Eric Botcazou <ebotcazou@adacore.com> 2015-12-20 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Type>: During
layout in type_annotate_only mode, skip discriminants of derived
tagged types renaming those of the parent type.
In type_annotate_only mode, if the type is tagged, do not override a
size clause but take into account the alignment of the tag.
(annotate_rep): In type_annotate_only mode, deal with discriminants
of derived tagged types renaming those of the parent type.
2015-12-20 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/utils.c (maybe_pad_type): In type_annotate_only mode, * gcc-interface/utils.c (maybe_pad_type): In type_annotate_only mode,
retrieve the component type if this is an array and do not issue the retrieve the component type if this is an array and do not issue the
warning for concurrent types. warning for concurrent types.
......
...@@ -3181,6 +3181,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -3181,6 +3181,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
&& Present (Corresponding_Discriminant (gnat_field))) && Present (Corresponding_Discriminant (gnat_field)))
continue; continue;
/* However, if we are just annotating types, the Parent_Subtype
doesn't exist so we need skip the discriminant altogether. */
if (type_annotate_only
&& Is_Tagged_Type (gnat_entity)
&& Is_Derived_Type (gnat_entity)
&& Present (Corresponding_Discriminant (gnat_field)))
continue;
gnu_field gnu_field
= gnat_to_gnu_field (gnat_field, gnu_type, packed, definition, = gnat_to_gnu_field (gnat_field, gnu_type, packed, definition,
debug_info_p); debug_info_p);
...@@ -5321,15 +5329,15 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -5321,15 +5329,15 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
/* If we are just annotating types and the type is tagged, the tag /* If we are just annotating types and the type is tagged, the tag
and the parent components are not generated by the front-end so and the parent components are not generated by the front-end so
sizes must be adjusted if there is no representation clause. */ alignment and sizes must be adjusted if there is no rep clause. */
if (type_annotate_only if (type_annotate_only
&& Is_Tagged_Type (gnat_entity) && Is_Tagged_Type (gnat_entity)
&& Unknown_RM_Size (gnat_entity)
&& !VOID_TYPE_P (gnu_type) && !VOID_TYPE_P (gnu_type)
&& (!TYPE_FIELDS (gnu_type) && (!TYPE_FIELDS (gnu_type)
|| integer_zerop (bit_position (TYPE_FIELDS (gnu_type))))) || integer_zerop (bit_position (TYPE_FIELDS (gnu_type)))))
{ {
tree pointer_size = bitsize_int (POINTER_SIZE), offset; tree offset;
Uint uint_size;
if (Is_Derived_Type (gnat_entity)) if (Is_Derived_Type (gnat_entity))
{ {
...@@ -5338,7 +5346,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -5338,7 +5346,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
Set_Alignment (gnat_entity, Alignment (gnat_parent)); Set_Alignment (gnat_entity, Alignment (gnat_parent));
} }
else else
offset = pointer_size; {
unsigned int align
= MAX (TYPE_ALIGN (gnu_type), POINTER_SIZE) / BITS_PER_UNIT;
offset = bitsize_int (POINTER_SIZE);
Set_Alignment (gnat_entity, UI_From_Int (align));
}
if (TYPE_FIELDS (gnu_type)) if (TYPE_FIELDS (gnu_type))
offset offset
...@@ -5346,10 +5359,22 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -5346,10 +5359,22 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
gnu_size = size_binop (PLUS_EXPR, gnu_size, offset); gnu_size = size_binop (PLUS_EXPR, gnu_size, offset);
gnu_size = round_up (gnu_size, POINTER_SIZE); gnu_size = round_up (gnu_size, POINTER_SIZE);
uint_size = annotate_value (gnu_size); Uint uint_size = annotate_value (gnu_size);
Set_Esize (gnat_entity, uint_size);
Set_RM_Size (gnat_entity, uint_size); Set_RM_Size (gnat_entity, uint_size);
Set_Esize (gnat_entity, uint_size);
}
/* If there is a rep clause, only adjust alignment and Esize. */
else if (type_annotate_only && Is_Tagged_Type (gnat_entity))
{
unsigned int align
= MAX (TYPE_ALIGN (gnu_type), POINTER_SIZE) / BITS_PER_UNIT;
Set_Alignment (gnat_entity, UI_From_Int (align));
gnu_size = round_up (gnu_size, POINTER_SIZE);
Set_Esize (gnat_entity, annotate_value (gnu_size));
} }
/* Otherwise no adjustment is needed. */
else else
Set_Esize (gnat_entity, annotate_value (gnu_size)); Set_Esize (gnat_entity, annotate_value (gnu_size));
} }
...@@ -7933,12 +7958,19 @@ annotate_rep (Entity_Id gnat_entity, tree gnu_type) ...@@ -7933,12 +7958,19 @@ annotate_rep (Entity_Id gnat_entity, tree gnu_type)
{ {
/* If there is no entry, this is an inherited component whose /* If there is no entry, this is an inherited component whose
position is the same as in the parent type. */ position is the same as in the parent type. */
Set_Component_Bit_Offset Entity_Id gnat_orig_field = Original_Record_Component (gnat_field);
(gnat_field,
Component_Bit_Offset (Original_Record_Component (gnat_field)));
Set_Esize (gnat_field, /* If we are just annotating types, discriminants renaming those of
Esize (Original_Record_Component (gnat_field))); the parent have no entry so deal with them specifically. */
if (type_annotate_only
&& gnat_orig_field == gnat_field
&& Ekind (gnat_field) == E_Discriminant)
gnat_orig_field = Corresponding_Discriminant (gnat_field);
Set_Component_Bit_Offset (gnat_field,
Component_Bit_Offset (gnat_orig_field));
Set_Esize (gnat_field, Esize (gnat_orig_field));
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment