Commit 9cbad0a3 by Eric Botcazou Committed by Eric Botcazou

decl.c (gnat_to_gnu_entity): Translate the Esize on entry only for elementary…

decl.c (gnat_to_gnu_entity): Translate the Esize on entry only for elementary types and abort if it is too large.

	* gcc-interface/decl.c (gnat_to_gnu_entity): Translate the Esize on
	entry only for elementary types and abort if it is too large.
	<E_Record_Type>: Make sure the Esize is known before using it.

From-SVN: r188378
parent ebf78003
2012-06-11 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity): Translate the Esize on
entry only for elementary types and abort if it is too large.
<E_Record_Type>: Make sure the Esize is known before using it.
2012-06-04 Steven Bosscher <steven@gcc.gnu.org> 2012-06-04 Steven Bosscher <steven@gcc.gnu.org>
* gcc-interface/utils2.c: Do not include output.h. * gcc-interface/utils2.c: Do not include output.h.
......
...@@ -377,11 +377,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -377,11 +377,12 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
prepend_attributes (First_Subtype (Base_Type (gnat_entity)), prepend_attributes (First_Subtype (Base_Type (gnat_entity)),
&attr_list); &attr_list);
/* Compute a default value for the size of the type. */ /* Compute a default value for the size of an elementary type. */
if (Known_Esize (gnat_entity) if (Known_Esize (gnat_entity) && Is_Elementary_Type (gnat_entity))
&& UI_Is_In_Int_Range (Esize (gnat_entity)))
{ {
unsigned int max_esize; unsigned int max_esize;
gcc_assert (UI_Is_In_Int_Range (Esize (gnat_entity)));
esize = UI_To_Int (Esize (gnat_entity)); esize = UI_To_Int (Esize (gnat_entity));
if (IN (kind, Float_Kind)) if (IN (kind, Float_Kind))
...@@ -2948,14 +2949,16 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -2948,14 +2949,16 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
if (Known_Alignment (gnat_entity)) if (Known_Alignment (gnat_entity))
TYPE_ALIGN (gnu_type) TYPE_ALIGN (gnu_type)
= validate_alignment (Alignment (gnat_entity), gnat_entity, 0); = validate_alignment (Alignment (gnat_entity), gnat_entity, 0);
else if (Is_Atomic (gnat_entity)) else if (Is_Atomic (gnat_entity) && Known_Esize (gnat_entity))
TYPE_ALIGN (gnu_type) {
= esize >= BITS_PER_WORD ? BITS_PER_WORD : ceil_pow2 (esize); unsigned int size = UI_To_Int (Esize (gnat_entity));
TYPE_ALIGN (gnu_type)
= size >= BITS_PER_WORD ? BITS_PER_WORD : ceil_pow2 (size);
}
/* If a type needs strict alignment, the minimum size will be the /* If a type needs strict alignment, the minimum size will be the
type size instead of the RM size (see validate_size). Cap the type size instead of the RM size (see validate_size). Cap the
alignment, lest it causes this type size to become too large. */ alignment, lest it causes this type size to become too large. */
else if (Strict_Alignment (gnat_entity) else if (Strict_Alignment (gnat_entity) && Known_RM_Size (gnat_entity))
&& Known_RM_Size (gnat_entity))
{ {
unsigned int raw_size = UI_To_Int (RM_Size (gnat_entity)); unsigned int raw_size = UI_To_Int (RM_Size (gnat_entity));
unsigned int raw_align = raw_size & -raw_size; unsigned int raw_align = raw_size & -raw_size;
......
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