re PR ada/19900 (ACATS c391002 c432002 ICE categorize_ctor_elements_1)

2005-03-08  Eric Botcazou  <ebotcazou@adacore.com>
	    Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
	    Nicolas Setton  <setton@adacore.com>
	    Ed Schonberg  <schonberg@adacore.com>

	PR ada/19900
	PR ada/19408
	PR ada/19140
	PR ada/20255

	* decl.c (gnat_to_gnu_field): Reject aliased components with a
	representation clause that prescribes a size not equal to the rounded
	size of their types.
	(gnat_to_gnu_entity, case E_Component): Always look at
	Original_Record_Component if Present and not the entity.
	(gnat_to_gnu_entity, case E_Record_Subtype): Rework handling of subtypes
	of tagged extension types by not making field for components that are
	inside the parent.
	(gnat_to_gnu_entity) <E_Record_Type>: Fix typo in the alignment formula
	(gnat_to_gnu_entity) <E_Variable>: Do not convert again the
	expression to the type of the object when the object is constant.
	Reverse defer_debug_incomplete_list before traversing it, so that trees
	are processed in the order at which they were added to the list. This
	order is important when using the stabs debug format.
	If we are deferring the output of debug information, also defer this
	output for a function return type.
	When adding fields to a record, prevent emitting debug information
	for incomplete records, emit the information only when the record is
	complete.
	(components_to_record): New parameter defer_debug.
	(gnat_to_gnu_entity, case E_Array_Subtype): Call copy_alias_set.
	(gnat_to_gnu_field_decl): New function.
	(substitution_list, annotate_rep): Call it.
	(gnat_to_gnu_entity, case E_Record_Subtype): Likewise.
	(gnat_to_gnu_entity, case E_Record_Type): Likewise.
	No longer update discriminants to not be a COMPONENT_REF.
	(copy_alias_set): Strip padding from input type; also handle
	unconstrained arrays properly.

	* gigi.h (write_record_type_debug_info): New function.
	Convert to use ANSI-style prototypes. Remove unused
	declarations for emit_stack_check, elab_all_gnat and
	set_second_error_entity.
	(gnat_to_gnu_field_decl): New decl.

	* utils.c (write_record_type_debug_info): New function.
	(finish_record_type): Delegate generation of debug information to
	write_record_type_debug_info.
	(update_pointer_to): Remove unneeded calls to rest_of_decl_compilation.
	(update_pointer_to): Fix pasto.
	(convert) <UNION_TYPE>: Accept slight type variations when
	converting to an unchecked union type.

	* exp_ch13.adb (Expand_N_Freeze_Entity): If Freeze_Type returns True,
	replace the N_Freeze_Entity with a null statement.

	* freeze.adb (Freeze_Expression): If the freeze nodes are generated
	within a constrained subcomponent of an enclosing record, place the
	freeze nodes in the scope stack entry for the enclosing record.
	(Undelay_Type): New Subprogram.
	(Set_Small_Size): Pass T, the type to modify; all callers changed.
	(Freeze_Entity, Freeze_Record_Type): Change the way we handle types
	within records; allow them to have freeze nodes if their base types
	aren't frozen yet.

	* sem_ch3.adb (Derived_Type_Declaration): New predicate
	Comes_From_Generic, to recognize accurately that the parent type in a
	derived type declaration can be traced back to a formal type, because
	it is one or is derived from one, or because its completion is derived
	from one.
	(Constrain_Component_Type): If component comes from source and has no
	explicit constraint, no need to constrain in in a subtype of the
	enclosing record.
	(Constrain_Access, Constrain_Array): Allow itypes to be delayed.
	Minor change to propagate Is_Ada_2005 flag

	* trans.c (gnat_to_gnu, case N_Aggregate): Verify that
	Expansion_Delayed is False.
	(assoc_to_constructor): Ignore fields that have a
	Corresponding_Discriminant.
	(gnat_to_gnu) <N_Return_Statement>: Restructure. If the
	function returns "by target", dereference the target pointer using the
	type of the actual return value.
	<all>: Be prepared for a null gnu_result.
	(processed_inline_subprograms): Check flag_really_no_inline
	instead of flag_no_inline.
	(set_second_error_entity): Remove unused function.
	(gnat_to_gnu, case N_Selected_Component): Call
	gnat_to_gnu_field_decl.
	(assoc_to_constructor): Likewise.

From-SVN: r96492
This commit is contained in:
Eric Botcazou 2005-03-15 16:59:54 +01:00 committed by Arnaud Charlet
parent 3a8b9f38bf
commit c6823a20b2
7 changed files with 856 additions and 606 deletions

View File

@ -80,6 +80,12 @@ static struct incomplete
Entity_Id full_type;
} *defer_incomplete_list = 0;
/* These two variables are used to defer emission of debug information for
nested incomplete record types */
static int defer_debug_level = 0;
static tree defer_debug_incomplete_list;
static void copy_alias_set (tree, tree);
static tree substitution_list (Entity_Id, Entity_Id, tree, bool);
static bool allocatable_size_p (tree, bool);
@ -91,7 +97,7 @@ static tree elaborate_expression_1 (Node_Id, Entity_Id, tree, tree,
static tree make_packable_type (tree);
static tree gnat_to_gnu_field (Entity_Id, tree, int, bool);
static void components_to_record (tree, Node_Id, tree, int, bool, tree *,
bool, bool);
bool, bool, bool);
static int compare_field_bitpos (const PTR, const PTR);
static Uint annotate_value (tree);
static void annotate_rep (Entity_Id, tree);
@ -151,6 +157,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
bool saved = false;
/* Nonzero if we incremented defer_incomplete_level. */
bool this_deferred = false;
/* Nonzero if we incremented defer_debug_level. */
bool debug_deferred = false;
/* Nonzero if we incremented force_global. */
bool this_global = false;
/* Nonzero if we should check to see if elaborated during processing. */
@ -390,11 +398,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
stored discriminant. Also use Original_Record_Component
if the record has a private extension. */
if ((Base_Type (gnat_record) == gnat_record
|| Ekind (Scope (gnat_entity)) == E_Private_Subtype
|| Ekind (Scope (gnat_entity)) == E_Record_Subtype_With_Private
|| Ekind (Scope (gnat_entity)) == E_Record_Type_With_Private)
&& Present (Original_Record_Component (gnat_entity))
if (Present (Original_Record_Component (gnat_entity))
&& Original_Record_Component (gnat_entity) != gnat_entity)
{
gnu_decl
@ -1011,6 +1015,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
const_flag = true;
}
if (const_flag)
gnu_type = build_qualified_type (gnu_type, (TYPE_QUALS (gnu_type)
| TYPE_QUAL_CONST));
/* Convert the expression to the type of the object except in the
case where the object's type is unconstrained or the object's type
is a padded record whose field is of self-referential size. In
@ -1038,14 +1046,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
|| Is_Exported (gnat_entity)))))
gnu_ext_name = create_concat_name (gnat_entity, 0);
if (const_flag)
{
gnu_type = build_qualified_type (gnu_type, (TYPE_QUALS (gnu_type)
| TYPE_QUAL_CONST));
if (gnu_expr)
gnu_expr = convert (gnu_type, gnu_expr);
}
/* If this is constant initialized to a static constant and the
object has an aggregrate type, force it to be statically
allocated. */
@ -1113,7 +1113,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
/* Back-annotate the Alignment of the object if not already in the
tree. Likewise for Esize if the object is of a constant size.
But if the "object" is actually a pointer to an object, the
alignment and size are the same as teh type, so don't back-annotate
alignment and size are the same as the type, so don't back-annotate
the values for the pointer. */
if (!used_by_ref && Unknown_Alignment (gnat_entity))
Set_Alignment (gnat_entity,
@ -2221,6 +2221,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
gnu_type
= build_array_type (gnat_to_gnu_type (Component_Type (gnat_entity)),
gnu_index_type);
copy_alias_set (gnu_type, gnu_string_type);
}
break;
@ -2355,7 +2356,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
else if (Is_Atomic (gnat_entity))
TYPE_ALIGN (gnu_type)
= (esize >= BITS_PER_WORD ? BITS_PER_WORD
: 1 << ((floor_log2 (esize) - 1) + 1));
: 1 << (floor_log2 (esize - 1) + 1));
/* If we have a Parent_Subtype, make a field for the parent. If
this record has rep clauses, force the position to zero. */
@ -2387,9 +2388,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
build3 (COMPONENT_REF,
get_unpadded_type (Etype (gnat_field)),
gnu_get_parent,
gnat_to_gnu_entity (Corresponding_Discriminant
(gnat_field),
NULL_TREE, 0),
gnat_to_gnu_field_decl (Corresponding_Discriminant
(gnat_field)),
NULL_TREE),
true);
@ -2447,32 +2447,25 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
/* Add the listed fields into the record and finish up. */
components_to_record (gnu_type, Component_List (record_definition),
gnu_field_list, packed, definition, NULL,
false, all_rep);
false, all_rep, this_deferred);
if (this_deferred)
{
debug_deferred = true;
defer_debug_level++;
defer_debug_incomplete_list
= tree_cons (NULL_TREE, gnu_type,
defer_debug_incomplete_list);
}
/* We used to remove the associations of the discriminants and
_Parent for validity checking, but we may need them if there's
Freeze_Node for a subtype used in this record. */
TYPE_VOLATILE (gnu_type) = Treat_As_Volatile (gnat_entity);
TYPE_BY_REFERENCE_P (gnu_type) = Is_By_Reference_Type (gnat_entity);
/* If this is an extension type, reset the tree for any
inherited discriminants. Also remove the PLACEHOLDER_EXPR
for non-inherited discriminants. */
if (!Is_Unchecked_Union (gnat_entity)
&& Has_Discriminants (gnat_entity))
for (gnat_field = First_Stored_Discriminant (gnat_entity);
Present (gnat_field);
gnat_field = Next_Stored_Discriminant (gnat_field))
{
if (Present (Parent_Subtype (gnat_entity))
&& Present (Corresponding_Discriminant (gnat_field)))
save_gnu_tree (gnat_field, NULL_TREE, false);
else
{
gnu_field = get_gnu_tree (gnat_field);
save_gnu_tree (gnat_field, NULL_TREE, false);
save_gnu_tree (gnat_field, TREE_OPERAND (gnu_field, 1),
false);
}
}
/* If it is a tagged record force the type to BLKmode to insure
that these objects will always be placed in memory. Do the
same thing for limited record types. */
@ -2581,7 +2574,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
&& Present (Discriminant_Constraint (gnat_entity)))
{
Entity_Id gnat_field;
Entity_Id gnat_root_type;
tree gnu_field_list = 0;
tree gnu_pos_list
= compute_field_positions (gnu_orig_type, NULL_TREE,
@ -2590,41 +2582,9 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
tree gnu_subst_list
= substitution_list (gnat_entity, gnat_base_type, NULL_TREE,
definition);
bool possibly_overlapping_fields = false;
tree gnu_temp;
/* If this is a derived type, we may be seeing fields from any
original records, so add those positions and discriminant
substitutions to our lists. */
for (gnat_root_type = gnat_base_type;
Underlying_Type (Etype (gnat_root_type)) != gnat_root_type;
gnat_root_type = Underlying_Type (Etype (gnat_root_type)))
{
gnu_pos_list
= compute_field_positions
(gnat_to_gnu_type (Etype (gnat_root_type)),
gnu_pos_list, size_zero_node, bitsize_zero_node,
BIGGEST_ALIGNMENT);
if (Present (Parent_Subtype (gnat_root_type)))
{
gnu_subst_list
= substitution_list (Parent_Subtype (gnat_root_type),
Empty, gnu_subst_list,
definition);
/* If there's a _Parent field, it may overlap the
fields we have that appear to be in this record but
actually are from the parent. So make note of that
fact and later we'll make a UNION_TYPE instead of
a RECORD_TYPE, since the latter may not have
overlapping fields. */
possibly_overlapping_fields = true;
}
}
gnu_type = make_node (possibly_overlapping_fields
? UNION_TYPE : RECORD_TYPE);
gnu_type = make_node (RECORD_TYPE);
TYPE_NAME (gnu_type) = gnu_entity_id;
TYPE_STUB_DECL (gnu_type)
= create_type_decl (NULL_TREE, gnu_type, NULL, false, false,
@ -2633,12 +2593,17 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
for (gnat_field = First_Entity (gnat_entity);
Present (gnat_field); gnat_field = Next_Entity (gnat_field))
if (Ekind (gnat_field) == E_Component
|| Ekind (gnat_field) == E_Discriminant)
if ((Ekind (gnat_field) == E_Component
|| Ekind (gnat_field) == E_Discriminant)
&& (Underlying_Type (Scope (Original_Record_Component
(gnat_field)))
== gnat_base_type)
&& (No (Corresponding_Discriminant (gnat_field))
|| !Is_Tagged_Type (gnat_base_type)))
{
tree gnu_old_field
= gnat_to_gnu_entity
(Original_Record_Component (gnat_field), NULL_TREE, 0);
= gnat_to_gnu_field_decl (Original_Record_Component
(gnat_field));
tree gnu_offset
= TREE_VALUE (purpose_member (gnu_old_field,
gnu_pos_list));
@ -2728,6 +2693,16 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
save_gnu_tree (gnat_field, gnu_field, false);
}
/* Now go through the entities again looking for Itypes that
we have not elaborated but should (e.g., Etypes of fields
that have Original_Components). */
for (gnat_field = First_Entity (gnat_entity);
Present (gnat_field); gnat_field = Next_Entity (gnat_field))
if ((Ekind (gnat_field) == E_Discriminant
|| Ekind (gnat_field) == E_Component)
&& !present_gnu_tree (Etype (gnat_field)))
gnat_to_gnu_entity (Etype (gnat_field), NULL_TREE, 0);
finish_record_type (gnu_type, nreverse (gnu_field_list),
true, false);
@ -2812,7 +2787,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
&& !Is_Unchecked_Union (gnat_base_type))
|| Ekind (gnat_temp) == E_Component)
save_gnu_tree (gnat_temp,
get_gnu_tree
gnat_to_gnu_field_decl
(Original_Record_Component (gnat_temp)), false);
}
break;
@ -3633,8 +3608,24 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
stubbed since structures are incomplete for the back-end. */
if (gnu_field_list
&& Convention (gnat_entity) != Convention_Stubbed)
finish_record_type (gnu_return_type, nreverse (gnu_field_list),
false, false);
{
/* If all types are not complete, defer emission of debug
information for this record types. Otherwise, we risk emitting
debug information for a dummy type contained in the fields
for that record. */
finish_record_type (gnu_return_type, nreverse (gnu_field_list),
false, defer_incomplete_level);
if (defer_incomplete_level)
{
debug_deferred = true;
defer_debug_level++;
defer_debug_incomplete_list
= tree_cons (NULL_TREE, gnu_return_type,
defer_debug_incomplete_list);
}
}
/* If we have a CICO list but it has only one entry, we convert
this function into a function that simply returns that one
@ -3739,7 +3730,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
else if (kind == E_Subprogram_Type)
gnu_decl = create_type_decl (gnu_entity_id, gnu_type, attr_list,
!Comes_From_Source (gnat_entity),
debug_info_p, gnat_entity);
debug_info_p && !defer_incomplete_level,
gnat_entity);
else
{
gnu_decl = create_subprog_decl (gnu_entity_id, gnu_ext_name,
@ -4165,6 +4157,31 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
}
}
/* If there are no incomplete types and we have deferred emission
of debug information, check whether we have finished defining
all nested records.
If so, handle the list now. */
if (debug_deferred)
defer_debug_level--;
if (defer_debug_incomplete_list
&& !defer_incomplete_level
&& !defer_debug_level)
{
tree c, n;
defer_debug_incomplete_list = nreverse (defer_debug_incomplete_list);
for (c = defer_debug_incomplete_list; c; c = n)
{
n = TREE_CHAIN (c);
write_record_type_debug_info (TREE_VALUE (c));
}
defer_debug_incomplete_list = 0;
}
if (this_global)
force_global--;
@ -4176,6 +4193,20 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
return gnu_decl;
}
/* Similar, but if the returned value is a COMPONENT_REF, return the
FIELD_DECL. */
tree
gnat_to_gnu_field_decl (Entity_Id gnat_entity)
{
tree gnu_field = gnat_to_gnu_entity (gnat_entity, NULL_TREE, 0);
if (TREE_CODE (gnu_field) == COMPONENT_REF)
gnu_field = TREE_OPERAND (gnu_field, 1);
return gnu_field;
}
/* Given GNAT_ENTITY, elaborate all expressions that are required to
be elaborated at the point of its definition, but do nothing else. */
@ -4292,19 +4323,26 @@ mark_out_of_scope (Entity_Id gnat_entity)
static void
copy_alias_set (tree gnu_new_type, tree gnu_old_type)
{
/* Remove any padding from GNU_OLD_TYPE. It doesn't matter in the case
of a one-dimensional array, since the padding has the same alias set
as the field type, but if it's a multi-dimensional array, we need to
see the inner types. */
while (TREE_CODE (gnu_old_type) == RECORD_TYPE
&& (TYPE_JUSTIFIED_MODULAR_P (gnu_old_type)
|| TYPE_IS_PADDING_P (gnu_old_type)))
gnu_old_type = TREE_TYPE (TYPE_FIELDS (gnu_old_type));
/* We need to be careful here in case GNU_OLD_TYPE is an unconstrained
array. In that case, it doesn't have the same shape as GNU_NEW_TYPE,
so we need to go down to what does. */
if (TREE_CODE (gnu_old_type) == UNCONSTRAINED_ARRAY_TYPE)
gnu_old_type
= TREE_TYPE (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (gnu_old_type))));
if (TREE_CODE (gnu_new_type) == ARRAY_TYPE
&& TREE_CODE (TREE_TYPE (gnu_new_type)) == ARRAY_TYPE
&& TYPE_MULTI_ARRAY_P (TREE_TYPE (gnu_new_type)))
{
/* We need to be careful here in case GNU_OLD_TYPE is an unconstrained
array. In that case, it doesn't have the same shape as GNU_NEW_TYPE,
so we need to go down to what does. */
if (TREE_CODE (gnu_old_type) == UNCONSTRAINED_ARRAY_TYPE)
gnu_old_type
= TREE_TYPE (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (gnu_old_type))));
copy_alias_set (TREE_TYPE (gnu_new_type), TREE_TYPE (gnu_old_type));
}
copy_alias_set (TREE_TYPE (gnu_new_type), TREE_TYPE (gnu_old_type));
TYPE_ALIAS_SET (gnu_new_type) = get_alias_set (gnu_old_type);
record_component_aliases (gnu_new_type);
@ -4336,8 +4374,8 @@ substitution_list (Entity_Id gnat_subtype, Entity_Id gnat_type,
gnat_value = Next_Elmt (gnat_value))
/* Ignore access discriminants. */
if (!Is_Access_Type (Etype (Node (gnat_value))))
gnu_list = tree_cons (gnat_to_gnu_entity (gnat_discrim, NULL_TREE, 0),
elaborate_expression
gnu_list = tree_cons (gnat_to_gnu_field_decl (gnat_discrim),
elaborate_expression
(Node (gnat_value), gnat_subtype,
get_entity_name (gnat_discrim), definition,
1, 0),
@ -5168,14 +5206,13 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed,
consistent with the alignment. */
if (needs_strict_alignment)
{
tree gnu_min_size = round_up (rm_size (gnu_field_type),
TYPE_ALIGN (gnu_field_type));
tree gnu_rounded_size = round_up (rm_size (gnu_field_type),
TYPE_ALIGN (gnu_field_type));
TYPE_ALIGN (gnu_record_type)
= MAX (TYPE_ALIGN (gnu_record_type), TYPE_ALIGN (gnu_field_type));
/* If Atomic, the size must match exactly and if aliased, the size
must not be less than the rounded size. */
/* If Atomic, the size must match exactly that of the field. */
if ((Is_Atomic (gnat_field) || Is_Atomic (Etype (gnat_field)))
&& !operand_equal_p (gnu_size, TYPE_SIZE (gnu_field_type), 0))
{
@ -5187,13 +5224,18 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed,
gnu_size = NULL_TREE;
}
/* If Aliased, the size must match exactly the rounded size. We
used to be more accomodating here and accept greater sizes, but
fully supporting this case on big-endian platforms would require
switching to a more involved layout for the field. */
else if (Is_Aliased (gnat_field)
&& gnu_size && tree_int_cst_lt (gnu_size, gnu_min_size))
&& gnu_size
&& ! operand_equal_p (gnu_size, gnu_rounded_size, 0))
{
post_error_ne_tree
("size of aliased field& too small{, minimum required is ^}",
("size of aliased field& must be ^ bits",
Last_Bit (Component_Clause (gnat_field)), gnat_field,
gnu_min_size);
gnu_rounded_size);
gnu_size = NULL_TREE;
}
@ -5345,6 +5387,9 @@ is_variable_size (tree type)
ALL_REP, if true, means a rep clause was found for all the fields. This
simplifies the logic since we know we're not in the mixed case.
DEFER_DEBUG, if true, means that the debugging routines should not be
called when finishing constructing the record type.
The processing of the component list fills in the chain with all of the
fields of the record and then the record type is finished. */
@ -5352,7 +5397,7 @@ static void
components_to_record (tree gnu_record_type, Node_Id component_list,
tree gnu_field_list, int packed, bool definition,
tree *p_gnu_rep_list, bool cancel_alignment,
bool all_rep)
bool all_rep, bool defer_debug)
{
Node_Id component_decl;
Entity_Id gnat_field;
@ -5474,7 +5519,8 @@ components_to_record (tree gnu_record_type, Node_Id component_list,
components_to_record (gnu_variant_type, Component_List (variant),
NULL_TREE, packed, definition,
&gnu_our_rep_list, !all_rep_and_size, all_rep);
&gnu_our_rep_list, !all_rep_and_size, all_rep,
false);
gnu_qual = choices_to_gnu (gnu_discriminant,
Discrete_Choices (variant));
@ -5611,7 +5657,7 @@ components_to_record (tree gnu_record_type, Node_Id component_list,
TYPE_ALIGN (gnu_record_type) = 0;
finish_record_type (gnu_record_type, nreverse (gnu_field_list),
layout_with_rep, false);
layout_with_rep, defer_debug);
}
/* Called via qsort from the above. Returns -1, 1, depending on the
@ -5781,7 +5827,7 @@ annotate_rep (Entity_Id gnat_entity, tree gnu_type)
tree gnu_entry;
Entity_Id gnat_field;
/* We operate by first making a list of all field and their positions
/* We operate by first making a list of all fields and their positions
(we can get the sizes easily at any time) by a recursive call
and then update all the sizes into the tree. */
gnu_list = compute_field_positions (gnu_type, NULL_TREE,
@ -5796,9 +5842,8 @@ annotate_rep (Entity_Id gnat_entity, tree gnu_type)
{
tree parent_offset = bitsize_zero_node;
gnu_entry
= purpose_member (gnat_to_gnu_entity (gnat_field, NULL_TREE, 0),
gnu_list);
gnu_entry = purpose_member (gnat_to_gnu_field_decl (gnat_field),
gnu_list);
if (gnu_entry)
{

View File

@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2004, Free Software Foundation, Inc. --
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@ -243,6 +243,7 @@ package body Exp_Ch13 is
In_Other_Scope : Boolean;
In_Outer_Scope : Boolean;
Decl : Node_Id;
Delete : Boolean := False;
begin
-- For object, with address clause, check alignment is OK
@ -317,7 +318,7 @@ package body Exp_Ch13 is
-- If type, freeze the type
if Is_Type (E) then
Freeze_Type (N);
Delete := Freeze_Type (N);
-- And for enumeration type, build the enumeration tables
@ -388,6 +389,13 @@ package body Exp_Ch13 is
end loop;
end if;
-- If we are to delete this N_Freeze_Entity, do so by rewriting so that
-- a loop on all nodes being inserted will work propertly.
if Delete then
Rewrite (N, Make_Null_Statement (Sloc (N)));
end if;
if In_Other_Scope then
if Ekind (Current_Scope) = E_Package then
End_Package_Scope (E_Scope);

View File

@ -6,7 +6,7 @@
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2004, Free Software Foundation, Inc. --
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
@ -164,6 +164,11 @@ package body Freeze is
-- needed -- see body for details). Never has any effect on T if the
-- Debug_Info_Off flag is set.
procedure Undelay_Type (T : Entity_Id);
-- T is a type of a component that we know to be an Itype.
-- We don't want this to have a Freeze_Node, so ensure it doesn't.
-- Do the same for any Full_View or Corresponding_Record_Type.
procedure Warn_Overlay
(Expr : Node_Id;
Typ : Entity_Id;
@ -506,9 +511,9 @@ package body Freeze is
procedure Check_Compile_Time_Size (T : Entity_Id) is
procedure Set_Small_Size (S : Uint);
procedure Set_Small_Size (T : Entity_Id; S : Uint);
-- Sets the compile time known size (32 bits or less) in the Esize
-- field, checking for a size clause that was given which attempts
-- field, of T checking for a size clause that was given which attempts
-- to give a smaller size.
function Size_Known (T : Entity_Id) return Boolean;
@ -525,7 +530,7 @@ package body Freeze is
-- Set_Small_Size --
--------------------
procedure Set_Small_Size (S : Uint) is
procedure Set_Small_Size (T : Entity_Id; S : Uint) is
begin
if S > 32 then
return;
@ -576,7 +581,8 @@ package body Freeze is
elsif Is_Array_Type (T) then
if Ekind (T) = E_String_Literal_Subtype then
Set_Small_Size (Component_Size (T) * String_Literal_Length (T));
Set_Small_Size (T, Component_Size (T)
* String_Literal_Length (T));
return True;
elsif not Is_Constrained (T) then
@ -632,7 +638,7 @@ package body Freeze is
Next_Index (Index);
end loop;
Set_Small_Size (Esiz);
Set_Small_Size (T, Esiz);
return True;
end;
@ -864,7 +870,7 @@ package body Freeze is
end loop;
if Packed_Size_Known then
Set_Small_Size (Packed_Size);
Set_Small_Size (T, Packed_Size);
end if;
return True;
@ -1365,6 +1371,7 @@ package body Freeze is
-------------------
function Freeze_Entity (E : Entity_Id; Loc : Source_Ptr) return List_Id is
Test_E : Entity_Id := E;
Comp : Entity_Id;
F_Node : Node_Id;
Result : List_Id;
@ -1460,6 +1467,7 @@ package body Freeze is
IR : Node_Id;
Junk : Boolean;
ADC : Node_Id;
Prev : Entity_Id;
Unplaced_Component : Boolean := False;
-- Set True if we find at least one component with no component
@ -1537,80 +1545,14 @@ package body Freeze is
end if;
end if;
-- Freeze components and embedded subtypes
-- Freeze components and embedded subtypes.
Comp := First_Entity (Rec);
Prev := Empty;
while Present (Comp) loop
if not Is_Type (Comp) then
Freeze_And_Append (Etype (Comp), Loc, Result);
end if;
-- If the component is an access type with an allocator
-- as default value, the designated type will be frozen
-- by the corresponding expression in init_proc. In order
-- to place the freeze node for the designated type before
-- that for the current record type, freeze it now.
-- Same process if the component is an array of access types,
-- initialized with an aggregate. If the designated type is
-- private, it cannot contain allocators, and it is premature
-- to freeze the type, so we check for this as well.
if Is_Access_Type (Etype (Comp))
and then Present (Parent (Comp))
and then Present (Expression (Parent (Comp)))
and then Nkind (Expression (Parent (Comp))) = N_Allocator
then
declare
Alloc : constant Node_Id := Expression (Parent (Comp));
begin
-- If component is pointer to a classwide type, freeze
-- the specific type in the expression being allocated.
-- The expression may be a subtype indication, in which
-- case freeze the subtype mark.
if Is_Class_Wide_Type (Designated_Type (Etype (Comp))) then
if Is_Entity_Name (Expression (Alloc)) then
Freeze_And_Append
(Entity (Expression (Alloc)), Loc, Result);
elsif
Nkind (Expression (Alloc)) = N_Subtype_Indication
then
Freeze_And_Append
(Entity (Subtype_Mark (Expression (Alloc))),
Loc, Result);
end if;
elsif Is_Itype (Designated_Type (Etype (Comp))) then
Check_Itype (Designated_Type (Etype (Comp)));
else
Freeze_And_Append
(Designated_Type (Etype (Comp)), Loc, Result);
end if;
end;
elsif Is_Access_Type (Etype (Comp))
and then Is_Itype (Designated_Type (Etype (Comp)))
then
Check_Itype (Designated_Type (Etype (Comp)));
elsif Is_Array_Type (Etype (Comp))
and then Is_Access_Type (Component_Type (Etype (Comp)))
and then Present (Parent (Comp))
and then Nkind (Parent (Comp)) = N_Component_Declaration
and then Present (Expression (Parent (Comp)))
and then Nkind (Expression (Parent (Comp))) = N_Aggregate
and then Is_Fully_Defined
(Designated_Type (Component_Type (Etype (Comp))))
then
Freeze_And_Append
(Designated_Type
(Component_Type (Etype (Comp))), Loc, Result);
end if;
-- Processing for real components (exclude anonymous subtypes)
-- First handle the (real) component case.
if Ekind (Comp) = E_Component
or else Ekind (Comp) = E_Discriminant
@ -1619,6 +1561,23 @@ package body Freeze is
CC : constant Node_Id := Component_Clause (Comp);
begin
-- Freezing a record type freezes the type of each of its
-- components. However, if the type of the component is
-- part of this record, we do not want or need a separate
-- Freeze_Node. Note that Is_Itype is wrong because that's
-- also set in private type cases. We also can't check for
-- the Scope being exactly Rec because of private types and
-- record extensions.
if Is_Itype (Etype (Comp))
and then Is_Record_Type (Underlying_Type
(Scope (Etype (Comp))))
then
Undelay_Type (Etype (Comp));
end if;
Freeze_And_Append (Etype (Comp), Loc, Result);
-- Check for error of component clause given for variable
-- sized type. We have to delay this test till this point,
-- since the component type has to be frozen for us to know
@ -1779,6 +1738,135 @@ package body Freeze is
end;
end if;
-- If the component is an Itype with Delayed_Freeze and is either
-- a record or array subtype and its base type has not yet been
-- frozen, we must remove this from the entity list of this
-- record and put it on the entity list of the scope of its base
-- type. Note that we know that this is not the type of a
-- component since we cleared Has_Delayed_Freeze for it in the
-- previous loop. Thus this must be the Designated_Type of an
-- access type, which is the type of a component.
if Is_Itype (Comp)
and then Is_Type (Scope (Comp))
and then Is_Composite_Type (Comp)
and then Base_Type (Comp) /= Comp
and then Has_Delayed_Freeze (Comp)
and then not Is_Frozen (Base_Type (Comp))
then
declare
Will_Be_Frozen : Boolean := False;
S : Entity_Id := Scope (Rec);
begin
-- We have a pretty bad kludge here. Suppose Rec is a
-- subtype being defined in a subprogram that's created
-- as part of the freezing of Rec'Base. In that case,
-- we know that Comp'Base must have already been frozen by
-- the time we get to elaborate this because Gigi doesn't
-- elaborate any bodies until it has elaborated all of the
-- declarative part. But Is_Frozen will not be set at this
-- point because we are processing code in lexical order.
-- We detect this case by going up the Scope chain of
-- Rec and seeing if we have a subprogram scope before
-- reaching the top of the scope chain or that of Comp'Base.
-- If we do, then mark that Comp'Base will actually be
-- frozen. If so, we merely undelay it.
while Present (S) loop
if Is_Subprogram (S) then
Will_Be_Frozen := True;
exit;
elsif S = Scope (Base_Type (Comp)) then
exit;
end if;
S := Scope (S);
end loop;
if Will_Be_Frozen then
Undelay_Type (Comp);
else
if Present (Prev) then
Set_Next_Entity (Prev, Next_Entity (Comp));
else
Set_First_Entity (Rec, Next_Entity (Comp));
end if;
-- Insert in entity list of scope of base type (which
-- must be an enclosing scope, because still unfrozen).
Append_Entity (Comp, Scope (Base_Type (Comp)));
end if;
end;
-- If the component is an access type with an allocator as
-- default value, the designated type will be frozen by the
-- corresponding expression in init_proc. In order to place the
-- freeze node for the designated type before that for the
-- current record type, freeze it now.
-- Same process if the component is an array of access types,
-- initialized with an aggregate. If the designated type is
-- private, it cannot contain allocators, and it is premature to
-- freeze the type, so we check for this as well.
elsif Is_Access_Type (Etype (Comp))
and then Present (Parent (Comp))
and then Present (Expression (Parent (Comp)))
and then Nkind (Expression (Parent (Comp))) = N_Allocator
then
declare
Alloc : constant Node_Id := Expression (Parent (Comp));
begin
-- If component is pointer to a classwide type, freeze
-- the specific type in the expression being allocated.
-- The expression may be a subtype indication, in which
-- case freeze the subtype mark.
if Is_Class_Wide_Type (Designated_Type (Etype (Comp))) then
if Is_Entity_Name (Expression (Alloc)) then
Freeze_And_Append
(Entity (Expression (Alloc)), Loc, Result);
elsif
Nkind (Expression (Alloc)) = N_Subtype_Indication
then
Freeze_And_Append
(Entity (Subtype_Mark (Expression (Alloc))),
Loc, Result);
end if;
elsif Is_Itype (Designated_Type (Etype (Comp))) then
Check_Itype (Designated_Type (Etype (Comp)));
else
Freeze_And_Append
(Designated_Type (Etype (Comp)), Loc, Result);
end if;
end;
elsif Is_Access_Type (Etype (Comp))
and then Is_Itype (Designated_Type (Etype (Comp)))
then
Check_Itype (Designated_Type (Etype (Comp)));
elsif Is_Array_Type (Etype (Comp))
and then Is_Access_Type (Component_Type (Etype (Comp)))
and then Present (Parent (Comp))
and then Nkind (Parent (Comp)) = N_Component_Declaration
and then Present (Expression (Parent (Comp)))
and then Nkind (Expression (Parent (Comp))) = N_Aggregate
and then Is_Fully_Defined
(Designated_Type (Component_Type (Etype (Comp))))
then
Freeze_And_Append
(Designated_Type
(Component_Type (Etype (Comp))), Loc, Result);
end if;
Prev := Comp;
Next_Entity (Comp);
end loop;
@ -1882,17 +1970,28 @@ package body Freeze is
-- Start of processing for Freeze_Entity
begin
-- We are going to test for various reasons why this entity need not be
-- frozen here, but in the case of an Itype that's defined within a
-- record, that test actually applies to the record.
if Is_Itype (E) and then Is_Record_Type (Scope (E)) then
Test_E := Scope (E);
elsif Is_Itype (E) and then Present (Underlying_Type (Scope (E)))
and then Is_Record_Type (Underlying_Type (Scope (E)))
then
Test_E := Underlying_Type (Scope (E));
end if;
-- Do not freeze if already frozen since we only need one freeze node
if Is_Frozen (E) then
return No_List;
-- It is improper to freeze an external entity within a generic
-- because its freeze node will appear in a non-valid context.
-- The entity will be frozen in the proper scope after the current
-- generic is analyzed.
-- It is improper to freeze an external entity within a generic because
-- its freeze node will appear in a non-valid context. The entity will
-- be frozen in the proper scope after the current generic is analyzed.
elsif Inside_A_Generic and then External_Ref_In_Generic (E) then
elsif Inside_A_Generic and then External_Ref_In_Generic (Test_E) then
return No_List;
-- Do not freeze a global entity within an inner scope created during
@ -1906,9 +2005,9 @@ package body Freeze is
-- comes from source, or is a generic instance, then the freeze point
-- is the one mandated by the language. and we freze the entity.
elsif In_Open_Scopes (Scope (E))
and then Scope (E) /= Current_Scope
and then Ekind (E) /= E_Constant
elsif In_Open_Scopes (Scope (Test_E))
and then Scope (Test_E) /= Current_Scope
and then Ekind (Test_E) /= E_Constant
then
declare
S : Entity_Id := Current_Scope;
@ -1940,10 +2039,11 @@ package body Freeze is
elsif Front_End_Inlining
and then In_Instance_Body
and then Present (Scope (E))
and then Present (Scope (Test_E))
then
declare
S : Entity_Id := Scope (E);
S : Entity_Id := Scope (Test_E);
begin
while Present (S) loop
if Is_Generic_Instance (S) then
@ -2694,6 +2794,12 @@ package body Freeze is
Freeze_And_Append (Comp, Loc, Result);
elsif (Ekind (Comp)) /= E_Function then
if Is_Itype (Etype (Comp))
and then Underlying_Type (Scope (Etype (Comp))) = E
then
Undelay_Type (Etype (Comp));
end if;
Freeze_And_Append (Etype (Comp), Loc, Result);
end if;
@ -2904,66 +3010,8 @@ package body Freeze is
Check_Restriction (No_Standard_Storage_Pools, E);
end if;
-- If the current entity is an array or record subtype and has
-- discriminants used to constrain it, it must not freeze, because
-- Freeze_Entity nodes force Gigi to process the frozen type.
if Is_Composite_Type (E) then
if Is_Array_Type (E) then
declare
Index : Node_Id := First_Index (E);
Expr1 : Node_Id;
Expr2 : Node_Id;
begin
while Present (Index) loop
if Etype (Index) /= Any_Type then
Get_Index_Bounds (Index, Expr1, Expr2);
for J in 1 .. 2 loop
if Nkind (Expr1) = N_Identifier
and then Ekind (Entity (Expr1)) = E_Discriminant
then
Set_Has_Delayed_Freeze (E, False);
Set_Freeze_Node (E, Empty);
Check_Debug_Info_Needed (E);
return Result;
end if;
Expr1 := Expr2;
end loop;
end if;
Next_Index (Index);
end loop;
end;
elsif Has_Discriminants (E)
and Is_Constrained (E)
then
declare
Constraint : Elmt_Id;
Expr : Node_Id;
begin
Constraint := First_Elmt (Discriminant_Constraint (E));
while Present (Constraint) loop
Expr := Node (Constraint);
if Nkind (Expr) = N_Identifier
and then Ekind (Entity (Expr)) = E_Discriminant
then
Set_Has_Delayed_Freeze (E, False);
Set_Freeze_Node (E, Empty);
Check_Debug_Info_Needed (E);
return Result;
end if;
Next_Elmt (Constraint);
end loop;
end;
end if;
-- AI-117 requires that all new primitives of a tagged type
-- must inherit the convention of the full view of the type.
-- Inherited and overriding operations are defined to inherit
@ -3065,7 +3113,7 @@ package body Freeze is
-- in particular the size and alignment values. This processing is
-- not required for generic types, since generic types do not play
-- any part in code generation, and so the size and alignment values
-- for suhc types are irrelevant.
-- for such types are irrelevant.
if Is_Generic_Type (E) then
return Result;
@ -3242,7 +3290,7 @@ package body Freeze is
function In_Exp_Body (N : Node_Id) return Boolean;
-- Given an N_Handled_Sequence_Of_Statements node N, determines whether
-- it is the handled statement sequence of an expander generated
-- it is the handled statement sequence of an expander-generated
-- subprogram (init proc, or stream subprogram). If so, it returns
-- True, otherwise False.
@ -3607,6 +3655,11 @@ package body Freeze is
-- specification, the scope is still void. The expression can also
-- appear in the discriminant part of a private or concurrent type.
-- If the expression appears in a constrained subcomponent of an
-- enclosing record declaration, the freeze nodes must be attached
-- to the outer record type so they can eventually be placed in the
-- enclosing declaration list.
-- The other case requiring this special handling is if we are in
-- a default expression, since in that case we are about to freeze
-- a static type, and the freeze scope needs to be the outer scope,
@ -3626,6 +3679,7 @@ package body Freeze is
declare
Loc : constant Source_Ptr := Sloc (Current_Scope);
Freeze_Nodes : List_Id := No_List;
Pos : Int := Scope_Stack.Last;
begin
if Present (Desig_Typ) then
@ -3640,16 +3694,21 @@ package body Freeze is
Freeze_And_Append (Nam, Loc, Freeze_Nodes);
end if;
-- The current scope may be that of a constrained component of
-- an enclosing record declaration, which is above the current
-- scope in the scope stack.
if Is_Record_Type (Scope (Current_Scope)) then
Pos := Pos - 1;
end if;
if Is_Non_Empty_List (Freeze_Nodes) then
if No (Scope_Stack.Table
(Scope_Stack.Last).Pending_Freeze_Actions)
then
Scope_Stack.Table
(Scope_Stack.Last).Pending_Freeze_Actions :=
if No (Scope_Stack.Table (Pos).Pending_Freeze_Actions) then
Scope_Stack.Table (Pos).Pending_Freeze_Actions :=
Freeze_Nodes;
else
Append_List (Freeze_Nodes, Scope_Stack.Table
(Scope_Stack.Last).Pending_Freeze_Actions);
(Pos).Pending_Freeze_Actions);
end if;
end if;
end;
@ -4727,6 +4786,44 @@ package body Freeze is
end if;
end Set_Debug_Info_Needed;
------------------
-- Undelay_Type --
------------------
procedure Undelay_Type (T : Entity_Id) is
begin
Set_Has_Delayed_Freeze (T, False);
Set_Freeze_Node (T, Empty);
-- Since we don't want T to have a Freeze_Node, we don't want its
-- Full_View or Corresponding_Record_Type to have one either.
-- ??? Fundamentally, this whole handling is a kludge. What we really
-- want is to be sure that for an Itype that's part of record R and is
-- a subtype of type T, that it's frozen after the later of the freeze
-- points of R and T. We have no way of doing that directly, so what we
-- do is force most such Itypes to be frozen as part of freezing R via
-- this procedure and only delay the ones that need to be delayed
-- (mostly the designated types of access types that are defined as
-- part of the record).
if Is_Private_Type (T)
and then Present (Full_View (T))
and then Is_Itype (Full_View (T))
and then Is_Record_Type (Scope (Full_View (T)))
then
Undelay_Type (Full_View (T));
end if;
if Is_Concurrent_Type (T)
and then Present (Corresponding_Record_Type (T))
and then Is_Itype (Corresponding_Record_Type (T))
and then Is_Record_Type (Scope (Corresponding_Record_Type (T)))
then
Undelay_Type (Corresponding_Record_Type (T));
end if;
end Undelay_Type;
------------------
-- Warn_Overlay --
------------------

View File

@ -6,7 +6,7 @@
* *
* C Header File *
* *
* Copyright (C) 1992-2004 Free Software Foundation, Inc. *
* Copyright (C) 1992-2005 Free Software Foundation, Inc. *
* *
* GNAT is free software; you can redistribute it and/or modify it under *
* terms of the GNU General Public License as published by the Free Soft- *
@ -30,30 +30,23 @@
* *
****************************************************************************/
/* Declare all functions and types used by gigi. */
/* The largest alignment, in bits, that is needed for using the widest
move instruction. */
extern unsigned int largest_move_alignment;
/* Declare all functions and types used by gigi. */
/* Compute the alignment of the largest mode that can be used for copying
objects. */
extern void gnat_compute_largest_alignment (void);
/* Routine called by gcc for emitting a stack check. GNU_EXPR is the
expression that contains the last address on the stack to check. */
extern tree emit_stack_check (tree);
/* GNU_TYPE is a type. Determine if it should be passed by reference by
default. */
extern bool default_pass_by_ref (tree);
extern bool default_pass_by_ref (tree gnu_type);
/* GNU_TYPE is the type of a subprogram parameter. Determine from the type
if it should be passed by reference. */
extern bool must_pass_by_ref (tree);
/* Elaboration routines for the front end. */
extern void elab_all_gnat (void);
extern bool must_pass_by_ref (tree gnu_type);
/* Initialize DUMMY_NODE_TABLE. */
extern void init_dummy_type (void);
@ -73,46 +66,51 @@ extern void init_dummy_type (void);
was not created previously. The value of 1 is normally used for a non-zero
DEFINITION, but a value of 2 is used in special circumstances, defined in
the code. */
extern tree gnat_to_gnu_entity (Entity_Id, tree, int);
extern tree gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr,
int definition);
/* Similar, but if the returned value is a COMPONENT_REF, return the
FIELD_DECL. */
extern tree gnat_to_gnu_field_decl (Entity_Id gnat_entity);
/* Given GNAT_ENTITY, an entity in the incoming GNAT tree, return a
GCC type corresponding to that entity. GNAT_ENTITY is assumed to
refer to an Ada type. */
extern tree gnat_to_gnu_type (Entity_Id);
extern tree gnat_to_gnu_type (Entity_Id gnat_entity);
/* Add GNU_STMT to the current BLOCK_STMT node. */
extern void add_stmt (tree);
extern void add_stmt (tree gnu_stmt);
/* Similar, but set the location of GNU_STMT to that of GNAT_NODE. */
extern void add_stmt_with_node (tree, Node_Id);
extern void add_stmt_with_node (tree gnu_stmt, Node_Id gnat_node);
/* Set the BLOCK node corresponding to the current code group to GNU_BLOCK. */
extern void set_block_for_group (tree);
/* Add a declaration statement for GNU_DECL to the current BLOCK_STMT node.
Get SLOC from Entity_Id. */
extern void add_decl_expr (tree, Entity_Id);
Get SLOC from GNAT_ENTITY. */
extern void add_decl_expr (tree gnu_decl, Entity_Id gnat_entity);
/* Given GNAT_ENTITY, elaborate all expressions that are required to
be elaborated at the point of its definition, but do nothing else. */
extern void elaborate_entity (Entity_Id);
extern void elaborate_entity (Entity_Id gnat_entity);
/* Mark GNAT_ENTITY as going out of scope at this point. Recursively mark
any entities on its entity chain similarly. */
extern void mark_out_of_scope (Entity_Id);
extern void mark_out_of_scope (Entity_Id gnat_entity);
/* Make a dummy type corresponding to GNAT_TYPE. */
extern tree make_dummy_type (Entity_Id);
extern tree make_dummy_type (Entity_Id gnat_type);
/* Get the unpadded version of a GNAT type. */
extern tree get_unpadded_type (Entity_Id);
extern tree get_unpadded_type (Entity_Id gnat_entity);
/* Called when we need to protect a variable object using a save_expr. */
extern tree maybe_variable (tree);
extern tree maybe_variable (tree gnu_operand);
/* Create a record type that contains a field of TYPE with a starting bit
position so that it is aligned to ALIGN bits and is SIZE bytes long. */
extern tree make_aligning_type (tree, int, tree);
extern tree make_aligning_type (tree type, int align, tree size);
/* Ensure that TYPE has SIZE and ALIGN. Make and return a new padded type
if needed. We have already verified that SIZE and TYPE are large enough.
@ -127,36 +125,38 @@ extern tree make_aligning_type (tree, int, tree);
SAME_RM_SIZE is true if the RM_Size of the resulting type is to be
set to its TYPE_SIZE; otherwise, it's set to the RM_Size of the original
type. */
extern tree maybe_pad_type (tree, tree, unsigned int, Entity_Id,
const char *, bool, bool, bool);
extern tree maybe_pad_type (tree type, tree size, unsigned int align,
Entity_Id gnat_entity, const char *name_trailer,
bool is_user_type, bool definition,
bool same_rm_size);
/* Given a GNU tree and a GNAT list of choices, generate an expression to test
the value passed against the list of choices. */
extern tree choices_to_gnu (tree, Node_Id);
extern tree choices_to_gnu (tree operand, Node_Id choices);
/* Given a type T, a FIELD_DECL F, and a replacement value R,
return a new type with all size expressions that contain F
updated by replacing F with R. This is identical to GCC's
substitute_in_type except that it knows about TYPE_INDEX_TYPE. */
extern tree gnat_substitute_in_type (tree, tree, tree);
extern tree gnat_substitute_in_type (tree t, tree f, tree r);
/* Return the "RM size" of GNU_TYPE. This is the actual number of bits
needed to represent the object. */
extern tree rm_size (tree);
extern tree rm_size (tree gnu_type);
/* Given GNU_ID, an IDENTIFIER_NODE containing a name and SUFFIX, a
/* Given GNU_ID, an IDENTIFIER_NODE containing a name, and SUFFIX, a
string, return a new IDENTIFIER_NODE that is the concatenation of
the name in GNU_ID and SUFFIX. */
extern tree concat_id_with_name (tree, const char *);
extern tree concat_id_with_name (tree gnu_id, const char *suffix);
/* Return the name to be used for GNAT_ENTITY. If a type, create a
fully-qualified name, possibly with type information encoding.
Otherwise, return the name. */
extern tree get_entity_name (Entity_Id);
extern tree get_entity_name (Entity_Id gnat_entity);
/* Return a name for GNAT_ENTITY concatenated with two underscores and
SUFFIX. */
extern tree create_concat_name (Entity_Id, const char *);
extern tree create_concat_name (Entity_Id gnat_entity, const char *suffix);
/* If true, then gigi is being called on an analyzed but unexpanded tree, and
the only purpose of the call is to properly annotate types with
@ -167,36 +167,48 @@ extern bool type_annotate_only;
extern const char *ref_filename;
/* This is the main program of the back-end. It sets up all the table
structures and then generates code. */
structures and then generates code.
extern void gigi (Node_Id, int, int, struct Node *, Node_Id *, Node_Id *,
struct Elist_Header *, struct Elmt_Item *,
struct String_Entry *, Char_Code *, struct List_Header *,
Int, char *, Entity_Id, Entity_Id, Entity_Id, Int);
??? Needs parameter descriptions */
extern void gigi (Node_Id gnat_root, int max_gnat_node, int number_name,
struct Node *nodes_ptr, Node_Id *next_node_ptr,
Node_Id *prev_node_ptr, struct Elist_Header *elists_ptr,
struct Elmt_Item *elmts_ptr,
struct String_Entry *strings_ptr,
Char_Code *strings_chars_ptr,
struct List_Header *list_headers_ptr,
Int number_units ATTRIBUTE_UNUSED,
char *file_info_ptr ATTRIBUTE_UNUSED,
Entity_Id standard_integer,
Entity_Id standard_long_long_float,
Entity_Id standard_exception_type,
Int gigi_operating_mode);
/* GNAT_NODE is the root of some GNAT tree. Return the root of the
GCC tree corresponding to that GNAT tree. Normally, no code is generated;
we just return an equivalent tree which is used elsewhere to generate
code. */
extern tree gnat_to_gnu (Node_Id);
extern tree gnat_to_gnu (Node_Id gnat_node);
/* GNU_STMT is a statement. We generate code for that statement. */
extern void gnat_expand_stmt (tree);
extern void gnat_expand_stmt (tree gnu_stmt);
extern int gnat_gimplify_expr (tree *, tree *, tree *);
/* ??? missing documentation */
extern int gnat_gimplify_expr (tree *expr_p, tree *pre_p,
tree *post_p ATTRIBUTE_UNUSED);
/* Do the processing for the declaration of a GNAT_ENTITY, a type. If
a separate Freeze node exists, delay the bulk of the processing. Otherwise
make a GCC type for GNAT_ENTITY and set up the correspondance. */
extern void process_type (Entity_Id);
extern void process_type (Entity_Id gnat_entity);
/* Convert Sloc into *LOCUS (a location_t). Return true if this Sloc
corresponds to a source code location and false if it doesn't. In the
latter case, we don't update *LOCUS. We also set the Gigi global variable
REF_FILENAME to the reference file name as given by sinput (i.e no
directory). */
extern bool Sloc_to_locus (Source_Ptr, location_t *);
extern bool Sloc_to_locus (Source_Ptr Sloc, location_t *locus);
/* Post an error message. MSG is the error message, properly annotated.
NODE is the node at which to post the error and the node to use for the
@ -205,28 +217,28 @@ extern void post_error (const char *, Node_Id);
/* Similar, but NODE is the node at which to post the error and ENT
is the node to use for the "&" substitution. */
extern void post_error_ne (const char *, Node_Id, Entity_Id);
extern void post_error_ne (const char *msg, Node_Id node, Entity_Id ent);
/* Similar, but NODE is the node at which to post the error, ENT is the node
to use for the "&" substitution, and N is the number to use for the ^. */
extern void post_error_ne_num (const char *, Node_Id, Entity_Id, int);
extern void post_error_ne_num (const char *msg, Node_Id node, Entity_Id ent,
int n);
/* Similar to post_error_ne_num, but T is a GCC tree representing the number
to write. If the tree represents a constant that fits within a
host integer, the text inside curly brackets in MSG will be output
(presumably including a '^'). Otherwise that text will not be output
and the text inside square brackets will be output instead. */
extern void post_error_ne_tree (const char *, Node_Id, Entity_Id, tree);
extern void post_error_ne_tree (const char *msg, Node_Id node, Entity_Id ent,
tree t);
/* Similar to post_error_ne_tree, except that NUM is a second
integer to write in the message. */
extern void post_error_ne_tree_2 (const char *, Node_Id, Entity_Id, tree, int);
/* Set the node for a second '&' in the error message. */
extern void set_second_error_entity (Entity_Id);
extern void post_error_ne_tree_2 (const char *msg, Node_Id node, Entity_Id ent,
tree t, int num);
/* Protect EXP from multiple evaluation. This may make a SAVE_EXPR. */
extern tree protect_multiple_eval (tree);
extern tree protect_multiple_eval (tree exp);
/* Initialize the table that maps GNAT codes to GCC codes for simple
binary and unary operations. */
@ -239,7 +251,7 @@ extern Node_Id error_gnat_node;
/* This is equivalent to stabilize_reference in GCC's tree.c, but we know
how to handle our new nodes and we take an extra argument that says
whether to force evaluation of everything. */
extern tree gnat_stabilize_reference (tree, bool);
extern tree gnat_stabilize_reference (tree ref, bool force);
/* Highest number in the front-end node table. */
extern int max_gnat_nodes;
@ -381,10 +393,10 @@ extern void gnat_poplevel (void);
/* Set SUPERCONTEXT of the BLOCK for the current binding level to FNDECL
and point FNDECL to this BLOCK. */
extern void set_current_block_context (tree);
extern void set_current_block_context (tree fndecl);
/* Set the jmpbuf_decl for the current binding level to DECL. */
extern void set_block_jmpbuf_decl (tree);
extern void set_block_jmpbuf_decl (tree decl);
/* Get the setjmp_decl, if any, for the current binding level. */
extern tree get_block_jmpbuf_decl (void);
@ -392,42 +404,42 @@ extern tree get_block_jmpbuf_decl (void);
/* Insert BLOCK at the end of the list of subblocks of the
current binding level. This is used when a BIND_EXPR is expanded,
to handle the BLOCK node inside the BIND_EXPR. */
extern void insert_block (tree);
extern void insert_block (tree block);
/* Records a ..._DECL node DECL as belonging to the current lexical scope
and uses GNAT_ENTITY for location information. */
extern void gnat_pushdecl (tree, Entity_Id);
and uses GNAT_NODE for location information. */
extern void gnat_pushdecl (tree decl, Node_Id gnat_node);
extern void gnat_init_stmt_group (void);
extern void gnat_init_decl_processing (void);
extern void init_gigi_decls (tree, tree);
extern void init_gigi_decls (tree long_long_float_type, tree exception_type);
extern void gnat_init_gcc_eh (void);
/* Return an integer type with the number of bits of precision given by
PRECISION. UNSIGNEDP is nonzero if the type is unsigned; otherwise
it is a signed type. */
extern tree gnat_type_for_size (unsigned, int);
extern tree gnat_type_for_size (unsigned precision, int unsignedp);
/* Return a data type that has machine mode MODE. UNSIGNEDP selects
an unsigned type; otherwise a signed type is returned. */
extern tree gnat_type_for_mode (enum machine_mode, int);
extern tree gnat_type_for_mode (enum machine_mode mode, int unsignedp);
/* Return the unsigned version of a TYPE_NODE, a scalar type. */
extern tree gnat_unsigned_type (tree);
extern tree gnat_unsigned_type (tree type_node);
/* Return the signed version of a TYPE_NODE, a scalar type. */
extern tree gnat_signed_type (tree);
extern tree gnat_signed_type (tree type_node);
/* Return a type the same as TYPE except unsigned or signed according to
UNSIGNEDP. */
extern tree gnat_signed_or_unsigned_type (int, tree);
extern tree gnat_signed_or_unsigned_type (int unsignedp, tree type);
/* Create an expression whose value is that of EXPR,
converted to type TYPE. The TREE_TYPE of the value
is always TYPE. This function implements all reasonable
conversions; callers should filter out those that are
not permitted by the language being compiled. */
extern tree convert (tree, tree);
extern tree convert (tree type, tree expr);
/* Routines created solely for the tree translator's sake. Their prototypes
can be changed as desired. */
@ -437,15 +449,16 @@ extern tree convert (tree, tree);
GNAT_ENTITY. Such gnu tree node is always an ..._DECL node.
If NO_CHECK is nonzero, the latter check is suppressed.
If GNU_DECL is zero, a previous association is to be reset. */
extern void save_gnu_tree (Entity_Id, tree, bool);
extern void save_gnu_tree (Entity_Id gnat_entity, tree gnu_decl,
bool no_check);
/* GNAT_ENTITY is a GNAT tree node for a defining identifier.
Return the ..._DECL node that was associated with it. If there is no tree
node associated with GNAT_ENTITY, abort. */
extern tree get_gnu_tree (Entity_Id);
extern tree get_gnu_tree (Entity_Id gnat_entity);
/* Return nonzero if a GCC tree has been associated with GNAT_ENTITY. */
extern bool present_gnu_tree (Entity_Id);
extern bool present_gnu_tree (Entity_Id gnat_entity);
/* Initialize tables for above routines. */
extern void init_gnat_to_gnu (void);
@ -456,7 +469,11 @@ extern void init_gnat_to_gnu (void);
layout_type but merely set the size and alignment ourselves.
If DEFER_DEBUG is true, do not call the debugging routines
on this type; it will be done later. */
extern void finish_record_type (tree, tree, bool, bool);
extern void finish_record_type (tree record_type, tree fieldlist,
bool has_rep, bool defer_debug);
/* Output the debug information associated to a record type. */
extern void write_record_type_debug_info (tree);
/* Returns a FUNCTION_TYPE node. RETURN_TYPE is the type returned by the
subprogram. If it is void_type_node, then we are dealing with a procedure,
@ -469,14 +486,17 @@ extern void finish_record_type (tree, tree, bool, bool);
depressed stack pointer. RETURNS_BY_TARGET_PTR is true if the function
is to be passed (as its first parameter) the address of the place to copy
its result. */
extern tree create_subprog_type (tree, tree, tree, bool, bool, bool, bool);
extern tree create_subprog_type (tree return_type, tree param_decl_list,
tree cico_list, bool returns_unconstrained,
bool returns_by_ref, bool returns_with_dsp,
bool returns_by_target_ptr);
/* Return a copy of TYPE, but safe to modify in any way. */
extern tree copy_type (tree);
extern tree copy_type (tree type);
/* Return an INTEGER_TYPE of SIZETYPE with range MIN to MAX and whose
TYPE_INDEX_TYPE is INDEX. */
extern tree create_index_type (tree, tree, tree);
extern tree create_index_type (tree min, tree max, tree index);
/* Return a TYPE_DECL node. TYPE_NAME gives the name of the type (a character
string) and TYPE is a ..._TYPE node giving its data type.
@ -484,8 +504,10 @@ extern tree create_index_type (tree, tree, tree);
by the compiler. DEBUG_INFO_P is true if we need to write debugging
information about this type. GNAT_NODE is used for the position of
the decl. */
extern tree create_type_decl (tree, tree, struct attrib *, bool, bool,
Node_Id);
extern tree create_type_decl (tree type_name, tree type,
struct attrib *attr_list,
bool artificial_p, bool debug_info_p,
Node_Id gnat_node);
/* Returns a GCC VAR_DECL node. VAR_NAME gives the name of the variable.
ASM_NAME is its assembler name (if provided). TYPE is
@ -504,11 +526,14 @@ extern tree create_type_decl (tree, tree, struct attrib *, bool, bool,
it indicates whether to always allocate storage to the variable.
GNAT_NODE is used for the position of the decl. */
extern tree create_var_decl (tree, tree, tree, tree, bool, bool, bool, bool,
struct attrib *, Node_Id);
extern tree create_var_decl (tree var_name, tree asm_name, tree type,
tree var_init, bool const_flag,
bool public_flag, bool extern_flag,
bool static_flag,
struct attrib *attr_list, Node_Id gnat_node);
/* Given a DECL and ATTR_LIST, apply the listed attributes. */
extern void process_attributes (tree, struct attrib *);
extern void process_attributes (tree decl, struct attrib *attr_list);
/* Returns a FIELD_DECL node. FIELD_NAME the field name, FIELD_TYPE is its
type, and RECORD_TYPE is the type of the parent. PACKED is nonzero if
@ -516,13 +541,16 @@ extern void process_attributes (tree, struct attrib *);
it is the specified size for this field. If POS is nonzero, it is the bit
position. If ADDRESSABLE is nonzero, it means we are allowed to take
the address of this field for aliasing purposes. */
extern tree create_field_decl (tree, tree, tree, int, tree, tree, int);
extern tree create_field_decl (tree field_name, tree field_type,
tree record_type, int packed, tree size,
tree pos, int addressable);
/* Returns a PARM_DECL node. PARAM_NAME is the name of the parameter,
PARAM_TYPE is its type. READONLY is true if the parameter is
readonly (either an IN parameter or an address of a pass-by-ref
parameter). */
extern tree create_param_decl (tree, tree, bool);
extern tree create_param_decl (tree param_name, tree param_type,
bool readonly);
/* Returns a FUNCTION_DECL node. SUBPROG_NAME is the name of the subprogram,
ASM_NAME is its assembler name, SUBPROG_TYPE is its type (a FUNCTION_TYPE
@ -531,26 +559,29 @@ extern tree create_param_decl (tree, tree, bool);
INLINE_FLAG, PUBLIC_FLAG, EXTERN_FLAG, and ATTR_LIST are used to set the
appropriate fields in the FUNCTION_DECL. GNAT_NODE gives the location. */
extern tree create_subprog_decl (tree, tree, tree, tree, bool, bool, bool,
struct attrib *, Node_Id);
extern tree create_subprog_decl (tree subprog_name, tree asm_name,
tree subprog_type, tree param_decl_list,
bool inlinee_flag, bool public_flag,
bool extern_flag,
struct attrib *attr_list, Node_Id gnat_node);
/* Returns a LABEL_DECL node for LABEL_NAME. */
extern tree create_label_decl (tree);
extern tree create_label_decl (tree label_name);
/* Set up the framework for generating code for SUBPROG_DECL, a subprogram
body. This routine needs to be invoked before processing the declarations
appearing in the subprogram. */
extern void begin_subprog_body (tree);
extern void begin_subprog_body (tree subprog_decl);
/* Finish the definition of the current subprogram and compile it all the way
to assembler language output. BODY is the tree corresponding to
the subprogram. */
extern void end_subprog_body (tree);
extern void end_subprog_body (tree body);
/* Build a template of type TEMPLATE_TYPE from the array bounds of ARRAY_TYPE.
EXPR is an expression that we can use to locate any PLACEHOLDER_EXPRs.
Return a constructor for the template. */
extern tree build_template (tree, tree, tree);
extern tree build_template (tree template_type, tree array_type, tree expr);
/* Build a VMS descriptor from a Mechanism_Type, which must specify
a descriptor type, and the GCC type of an object. Each FIELD_DECL
@ -559,7 +590,8 @@ extern tree build_template (tree, tree, tree);
to print out an error message if the mechanism cannot be applied to
an object of that type and also for the name. */
extern tree build_vms_descriptor (tree, Mechanism_Type, Entity_Id);
extern tree build_vms_descriptor (tree type, Mechanism_Type mech,
Entity_Id gnat_entity);
/* Build a type to be used to represent an aliased object whose nominal
type is an unconstrained array. This consists of a RECORD_TYPE containing
@ -567,94 +599,99 @@ extern tree build_vms_descriptor (tree, Mechanism_Type, Entity_Id);
ARRAY_TYPE. If ARRAY_TYPE is that of the unconstrained array, this
is used to represent an arbitrary unconstrained object. Use NAME
as the name of the record. */
extern tree build_unc_object_type (tree, tree, tree);
extern tree build_unc_object_type (tree template_type, tree object_type,
tree name);
/* Update anything previously pointing to OLD_TYPE to point to NEW_TYPE. In
the normal case this is just two adjustments, but we have more to do
if NEW is an UNCONSTRAINED_ARRAY_TYPE. */
extern void update_pointer_to (tree, tree);
extern void update_pointer_to (tree old_type, tree new_type);
/* EXP is an expression for the size of an object. If this size contains
discriminant references, replace them with the maximum (if MAX_P) or
minimum (if !MAX_P) possible value of the discriminant. */
extern tree max_size (tree, bool);
extern tree max_size (tree exp, bool max_p);
/* Remove all conversions that are done in EXP. This includes converting
from a padded type or to a left-justified modular type. If TRUE_ADDRESS
is true, always return the address of the containing object even if
the address is not bit-aligned. */
extern tree remove_conversions (tree, bool);
extern tree remove_conversions (tree exp, bool true_address);
/* If EXP's type is an UNCONSTRAINED_ARRAY_TYPE, return an expression that
refers to the underlying array. If its type has TYPE_CONTAINS_TEMPLATE_P,
likewise return an expression pointing to the underlying array. */
extern tree maybe_unconstrained_array (tree);
extern tree maybe_unconstrained_array (tree exp);
/* Return an expression that does an unchecked converstion of EXPR to TYPE.
If NOTRUNC_P is true, truncation operations should be suppressed. */
extern tree unchecked_convert (tree, tree, bool);
extern tree unchecked_convert (tree type, tree expr, bool notrunc_p);
/* Prepare expr to be an argument of a TRUTH_NOT_EXPR or other logical
operation.
This preparation consists of taking the ordinary
representation of an expression expr and producing a valid tree
boolean expression describing whether expr is nonzero. We could
representation of an expression EXPR and producing a valid tree
boolean expression describing whether EXPR is nonzero. We could
simply always do build_binary_op (NE_EXPR, expr, integer_zero_node, 1),
but we optimize comparisons, &&, ||, and !.
The resulting type should always be the same as the input type.
This function is simpler than the corresponding C version since
the only possible operands will be things of Boolean type. */
extern tree gnat_truthvalue_conversion (tree);
extern tree gnat_truthvalue_conversion (tree expr);
/* Return the base type of TYPE. */
extern tree get_base_type (tree);
extern tree get_base_type (tree type);
/* Likewise, but only return types known at Ada source. */
extern tree get_ada_base_type (tree);
extern tree get_ada_base_type (tree type);
/* EXP is a GCC tree representing an address. See if we can find how
strictly the object at that address is aligned. Return that alignment
strictly the object at that address is aligned. Return that alignment
in bits. If we don't know anything about the alignment, return 0. */
extern unsigned int known_alignment (tree);
extern unsigned int known_alignment (tree exp);
/* Make a binary operation of kind OP_CODE. RESULT_TYPE is the type
desired for the result. Usually the operation is to be performed
in that type. For MODIFY_EXPR and ARRAY_REF, RESULT_TYPE may be 0
in which case the type to be used will be derived from the operands. */
extern tree build_binary_op (enum tree_code, tree, tree, tree);
extern tree build_binary_op (enum tree_code op_code, tree retult_type,
tree left_operand, tree right_operand);
/* Similar, but make unary operation. */
extern tree build_unary_op (enum tree_code, tree, tree);
extern tree build_unary_op (enum tree_code op_code, tree result_type,
tree operand);
/* Similar, but for COND_EXPR. */
extern tree build_cond_expr (tree, tree, tree, tree);
extern tree build_cond_expr (tree result_type, tree condition_operand,
tree true_operand, tree false_operand);
/* Build a CALL_EXPR to call FUNDECL with one argument, ARG. Return
the CALL_EXPR. */
extern tree build_call_1_expr (tree, tree);
extern tree build_call_1_expr (tree fundecl, tree arg);
/* Build a CALL_EXPR to call FUNDECL with two argument, ARG1 & ARG2. Return
the CALL_EXPR. */
extern tree build_call_2_expr (tree, tree, tree);
extern tree build_call_2_expr (tree fundecl, tree arg1, tree arg2);
/* Likewise to call FUNDECL with no arguments. */
extern tree build_call_0_expr (tree);
extern tree build_call_0_expr (tree fundecl);
/* Call a function that raises an exception and pass the line number and file
name, if requested. MSG says which exception function to call. */
extern tree build_call_raise (int);
extern tree build_call_raise (int msg);
/* Return a CONSTRUCTOR of TYPE whose list is LIST. This is not the
same as build_constructor in the language-independent tree.c. */
extern tree gnat_build_constructor (tree, tree);
extern tree gnat_build_constructor (tree type, tree list);
/* Return a COMPONENT_REF to access a field that is given by COMPONENT,
an IDENTIFIER_NODE giving the name of the field, FIELD, a FIELD_DECL,
for the field, or both. Don't fold the result if NO_FOLD_P. */
extern tree build_component_ref (tree, tree, tree, bool);
extern tree build_component_ref (tree record_variable, tree component,
tree field, bool no_fold_p);
/* Build a GCC tree to call an allocation or deallocation function.
If GNU_OBJ is nonzero, it is an object to deallocate. Otherwise,
@ -663,8 +700,9 @@ extern tree build_component_ref (tree, tree, tree, bool);
GNU_SIZE is the size of the object and ALIGN is the alignment.
GNAT_PROC, if present is a procedure to call and GNAT_POOL is the
storage pool to use. If not preset, malloc and free will be used. */
extern tree build_call_alloc_dealloc (tree, tree, unsigned int, Entity_Id,
Entity_Id, Node_Id);
extern tree build_call_alloc_dealloc (tree gnu_obj, tree gnu_size,
unsigned align, Entity_Id gnat_proc,
Entity_Id gnat_pool, Node_Id gnat_node);
/* Build a GCC tree to correspond to allocating an object of TYPE whose
initial value if INIT, if INIT is nonzero. Convert the expression to
@ -672,25 +710,28 @@ extern tree build_call_alloc_dealloc (tree, tree, unsigned int, Entity_Id,
GNAT_PROC and GNAT_POOL optionally give the procedure to call and
the storage pool to use. GNAT_NODE is used to provide an error
location for restriction violations messages. */
extern tree build_allocator (tree, tree, tree, Entity_Id, Entity_Id, Node_Id);
extern tree build_allocator (tree type, tree init, tree result_type,
Entity_Id gnat_proc, Entity_Id gnat_pool,
Node_Id gnat_node);
/* Fill in a VMS descriptor for EXPR and return a constructor for it.
GNAT_FORMAL is how we find the descriptor record. */
extern tree fill_vms_descriptor (tree, Entity_Id);
extern tree fill_vms_descriptor (tree expr, Entity_Id gnat_formal);
/* Indicate that we need to make the address of EXPR_NODE and it therefore
should not be allocated in a register. Return true if successful. */
extern bool gnat_mark_addressable (tree);
extern bool gnat_mark_addressable (tree expr_node);
/* Implementation of the builtin_function langhook. */
extern tree builtin_function (const char *, tree, int, enum built_in_class,
const char *, tree);
extern tree builtin_function (const char *name, tree type, int function_code,
enum built_in_class class,
const char *library_name, tree attrs);
/* Search the chain of currently reachable declarations for a builtin
FUNCTION_DECL node corresponding to function NAME (an IDENTIFIER_NODE).
Return the first node found, if any, or NULL_TREE otherwise. */
extern tree builtin_decl_for (tree);
extern tree builtin_decl_for (tree name ATTRIBUTE_UNUSED);
/* This function is called by the front end to enumerate all the supported
modes for the machine. We pass a function which is called back with
@ -708,8 +749,8 @@ extern void enumerate_modes (void (*f) (int, int, int, int, int, int,
/* These are temporary function to deal with recent GCC changes related to
FP type sizes and precisions. */
extern int fp_prec_to_size (int);
extern int fp_size_to_prec (int);
extern int fp_prec_to_size (int prec);
extern int fp_size_to_prec (int size);
/* These functions return the basic data type sizes and related parameters
about the target machine. */

View File

@ -350,13 +350,13 @@ package body Sem_Ch3 is
-- discriminant constraints for Typ.
function Constrain_Component_Type
(Compon_Type : Entity_Id;
(Comp : Entity_Id;
Constrained_Typ : Entity_Id;
Related_Node : Node_Id;
Typ : Entity_Id;
Constraints : Elist_Id) return Entity_Id;
-- Given a discriminated base type Typ, a list of discriminant constraint
-- Constraints for Typ and the type of a component of Typ, Compon_Type,
-- Constraints for Typ and a component of Typ, with type Compon_Type,
-- create and return the type corresponding to Compon_type where all
-- discriminant references are replaced with the corresponding
-- constraint. If no discriminant references occur in Compon_Typ then
@ -2378,6 +2378,7 @@ package body Sem_Ch3 is
Set_Is_Volatile (Id, Is_Volatile (T));
Set_Treat_As_Volatile (Id, Treat_As_Volatile (T));
Set_Is_Atomic (Id, Is_Atomic (T));
Set_Is_Ada_2005 (Id, Is_Ada_2005 (T));
-- In the case where there is no constraint given in the subtype
-- indication, Process_Subtype just returns the Subtype_Mark,
@ -7374,12 +7375,7 @@ package body Sem_Ch3 is
Set_Depends_On_Private (Def_Id, Has_Private_Component (Def_Id));
Set_Is_Access_Constant (Def_Id, Is_Access_Constant (T));
-- Itypes created for constrained record components do not receive
-- a freeze node, they are elaborated when first seen.
if not Is_Record_Type (Current_Scope) then
Conditional_Delay (Def_Id, T);
end if;
Conditional_Delay (Def_Id, T);
end Constrain_Access;
---------------------
@ -7474,17 +7470,12 @@ package body Sem_Ch3 is
Set_Is_Private_Composite (Def_Id, Is_Private_Composite (T));
Set_Is_Limited_Composite (Def_Id, Is_Limited_Composite (T));
-- If the subtype is not that of a record component, build a freeze
-- node if parent still needs one.
-- If the subtype is not that of a record component, make sure
-- Build a freeze node if parent still needs one. Also, make sure
-- that the Depends_On_Private status is set (explanation ???)
-- and also that a conditional delay is set.
if not Is_Type (Scope (Def_Id)) then
Set_Depends_On_Private (Def_Id, Depends_On_Private (T));
Conditional_Delay (Def_Id, T);
end if;
Set_Depends_On_Private (Def_Id, Depends_On_Private (T));
Conditional_Delay (Def_Id, T);
end Constrain_Array;
@ -7493,13 +7484,14 @@ package body Sem_Ch3 is
------------------------------
function Constrain_Component_Type
(Compon_Type : Entity_Id;
(Comp : Entity_Id;
Constrained_Typ : Entity_Id;
Related_Node : Node_Id;
Typ : Entity_Id;
Constraints : Elist_Id) return Entity_Id
is
Loc : constant Source_Ptr := Sloc (Constrained_Typ);
Loc : constant Source_Ptr := Sloc (Constrained_Typ);
Compon_Type : constant Entity_Id := Etype (Comp);
function Build_Constrained_Array_Type
(Old_Type : Entity_Id) return Entity_Id;
@ -7876,7 +7868,17 @@ package body Sem_Ch3 is
-- Start of processing for Constrain_Component_Type
begin
if Is_Array_Type (Compon_Type) then
if Nkind (Parent (Comp)) = N_Component_Declaration
and then Comes_From_Source (Parent (Comp))
and then Comes_From_Source
(Subtype_Indication (Component_Definition (Parent (Comp))))
and then
Is_Entity_Name
(Subtype_Indication (Component_Definition (Parent (Comp))))
then
return Compon_Type;
elsif Is_Array_Type (Compon_Type) then
return Build_Constrained_Array_Type (Compon_Type);
elsif Has_Discriminants (Compon_Type) then
@ -7884,9 +7886,10 @@ package body Sem_Ch3 is
elsif Is_Access_Type (Compon_Type) then
return Build_Constrained_Access_Type (Compon_Type);
end if;
return Compon_Type;
else
return Compon_Type;
end if;
end Constrain_Component_Type;
--------------------------
@ -8723,7 +8726,7 @@ package body Sem_Ch3 is
Set_Etype
(New_C,
Constrain_Component_Type
(Etype (Old_C), Subt, Decl_Node, Typ, Constraints));
(Old_C, Subt, Decl_Node, Typ, Constraints));
Set_Is_Public (New_C, Is_Public (Subt));
Next_Elmt (Comp);
@ -8875,7 +8878,7 @@ package body Sem_Ch3 is
Set_Etype
(New_C,
Constrain_Component_Type
(Etype (Old_C), Subt, Decl_Node, Typ, Constraints));
(Old_C, Subt, Decl_Node, Typ, Constraints));
Set_Is_Public (New_C, Is_Public (Subt));
Next_Component (Old_C);
@ -9570,6 +9573,36 @@ package body Sem_Ch3 is
Parent_Scope : Entity_Id;
Taggd : Boolean;
function Comes_From_Generic (Typ : Entity_Id) return Boolean;
-- Check whether the parent type is a generic formal, or derives
-- directly or indirectly from one.
------------------------
-- Comes_From_Generic --
------------------------
function Comes_From_Generic (Typ : Entity_Id) return Boolean is
begin
if Is_Generic_Type (Typ) then
return True;
elsif Is_Generic_Type (Root_Type (Parent_Type)) then
return True;
elsif Is_Private_Type (Typ)
and then Present (Full_View (Typ))
and then Is_Generic_Type (Root_Type (Full_View (Typ)))
then
return True;
elsif Is_Generic_Actual_Type (Typ) then
return True;
else
return False;
end if;
end Comes_From_Generic;
begin
Parent_Type := Find_Type_Of_Subtype_Indic (Indic);
@ -9645,9 +9678,7 @@ package body Sem_Ch3 is
return;
elsif (Is_Incomplete_Or_Private_Type (Parent_Type)
and then not Is_Generic_Type (Parent_Type)
and then not Is_Generic_Type (Root_Type (Parent_Type))
and then not Is_Generic_Actual_Type (Parent_Type))
and then not Comes_From_Generic (Parent_Type))
or else Has_Private_Component (Parent_Type)
then
-- The ancestor type of a formal type can be incomplete, in which
@ -9666,7 +9697,7 @@ package body Sem_Ch3 is
("premature derivation of derived or private type", Indic);
-- Flag the type itself as being in error, this prevents some
-- nasty problems with people looking at the malformed type.
-- nasty problems with subsequent uses of the malformed type.
Set_Error_Posted (T);
@ -10685,8 +10716,10 @@ package body Sem_Ch3 is
then
Set_Etype (New_C, Etype (Old_C));
else
Set_Etype (New_C, Constrain_Component_Type (Etype (Old_C),
Derived_Base, N, Parent_Base, Discs));
Set_Etype
(New_C,
Constrain_Component_Type
(Old_C, Derived_Base, N, Parent_Base, Discs));
end if;
end if;

View File

@ -2956,7 +2956,7 @@ gnat_to_gnu (Node_Id gnat_node)
NULL_TREE, gnu_prefix);
else
{
gnu_field = gnat_to_gnu_entity (gnat_field, NULL_TREE, 0);
gnu_field = gnat_to_gnu_field_decl (gnat_field);
/* If there are discriminants, the prefix might be
evaluated more than once, which is a problem if it has
@ -3013,6 +3013,8 @@ gnat_to_gnu (Node_Id gnat_node)
/* ??? It is wrong to evaluate the type now, but there doesn't
seem to be any other practical way of doing it. */
gcc_assert (!Expansion_Delayed (gnat_node));
gnu_aggr_type = gnu_result_type
= get_unpadded_type (Etype (gnat_node));
@ -3497,11 +3499,7 @@ gnat_to_gnu (Node_Id gnat_node)
/* The return value from the subprogram. */
tree gnu_ret_val = NULL_TREE;
/* The place to put the return value. */
tree gnu_lhs
= (TYPE_RETURNS_BY_TARGET_PTR_P (gnu_subprog_type)
? build_unary_op (INDIRECT_REF, NULL_TREE,
DECL_ARGUMENTS (current_function_decl))
: DECL_RESULT (current_function_decl));
tree gnu_lhs;
/* If we are dealing with a "return;" from an Ada procedure with
parameters passed by copy in copy out, we need to return a record
@ -3524,6 +3522,7 @@ gnat_to_gnu (Node_Id gnat_node)
else if (TYPE_CI_CO_LIST (gnu_subprog_type))
{
gnu_lhs = DECL_RESULT (current_function_decl);
if (list_length (TYPE_CI_CO_LIST (gnu_subprog_type)) == 1)
gnu_ret_val = TREE_VALUE (TYPE_CI_CO_LIST (gnu_subprog_type));
else
@ -3543,12 +3542,26 @@ gnat_to_gnu (Node_Id gnat_node)
are doing a call, pass that target to the call. */
if (TYPE_RETURNS_BY_TARGET_PTR_P (gnu_subprog_type)
&& Nkind (Expression (gnat_node)) == N_Function_Call)
gnu_ret_val = call_to_gnu (Expression (gnat_node),
&gnu_result_type, gnu_lhs);
{
gnu_lhs
= build_unary_op (INDIRECT_REF, NULL_TREE,
DECL_ARGUMENTS (current_function_decl));
gnu_result = call_to_gnu (Expression (gnat_node),
&gnu_result_type, gnu_lhs);
}
else
{
gnu_ret_val = gnat_to_gnu (Expression (gnat_node));
if (TYPE_RETURNS_BY_TARGET_PTR_P (gnu_subprog_type))
/* The original return type was unconstrained so dereference
the TARGET pointer in the actual return value's type. */
gnu_lhs
= build_unary_op (INDIRECT_REF, TREE_TYPE (gnu_ret_val),
DECL_ARGUMENTS (current_function_decl));
else
gnu_lhs = DECL_RESULT (current_function_decl);
/* Do not remove the padding from GNU_RET_VAL if the inner
type is self-referential since we want to allocate the fixed
size in that case. */
@ -3591,18 +3604,19 @@ gnat_to_gnu (Node_Id gnat_node)
gnat_node);
}
}
gnu_result = build2 (MODIFY_EXPR, TREE_TYPE (gnu_ret_val),
gnu_lhs, gnu_ret_val);
if (TYPE_RETURNS_BY_TARGET_PTR_P (gnu_subprog_type))
{
add_stmt_with_node (gnu_result, gnat_node);
gnu_ret_val = NULL_TREE;
}
}
gnu_result = build1 (RETURN_EXPR, void_type_node,
gnu_ret_val ? gnu_result : gnu_ret_val);
if (gnu_ret_val)
gnu_result = build2 (MODIFY_EXPR, TREE_TYPE (gnu_ret_val),
gnu_lhs, gnu_ret_val);
if (TYPE_RETURNS_BY_TARGET_PTR_P (gnu_subprog_type))
{
add_stmt_with_node (gnu_result, gnat_node);
gnu_result = NULL_TREE;
}
gnu_result = build1 (RETURN_EXPR, void_type_node, gnu_result);
}
break;
@ -4021,12 +4035,14 @@ gnat_to_gnu (Node_Id gnat_node)
current_function_decl = NULL_TREE;
}
/* Set the location information into the result. If we're supposed to
return something of void_type, it means we have something we're
elaborating for effect, so just return. */
if (EXPR_P (gnu_result))
/* Set the location information into the result. Note that we may have
no result if we tried to build a CALL_EXPR node to a procedure with
no side-effects and optimization is enabled. */
if (gnu_result && EXPR_P (gnu_result))
annotate_with_node (gnu_result, gnat_node);
/* If we're supposed to return something of void_type, it means we have
something we're elaborating for effect, so just return. */
if (TREE_CODE (gnu_result_type) == VOID_TYPE)
return gnu_result;
@ -4807,7 +4823,7 @@ process_inlined_subprograms (Node_Id gnat_node)
/* If we can inline, generate RTL for all the inlined subprograms.
Define the entity first so we set DECL_EXTERNAL. */
if (optimize > 0 && !flag_no_inline)
if (optimize > 0 && !flag_really_no_inline)
for (gnat_entity = First_Inlined_Subprogram (gnat_node);
Present (gnat_entity);
gnat_entity = Next_Inlined_Subprogram (gnat_entity))
@ -5439,13 +5455,19 @@ assoc_to_constructor (Node_Id gnat_assoc, tree gnu_type)
gnat_assoc = Next (gnat_assoc))
{
Node_Id gnat_field = First (Choices (gnat_assoc));
tree gnu_field = gnat_to_gnu_entity (Entity (gnat_field), NULL_TREE, 0);
tree gnu_field = gnat_to_gnu_field_decl (Entity (gnat_field));
tree gnu_expr = gnat_to_gnu (Expression (gnat_assoc));
/* The expander is supposed to put a single component selector name
in every record component association */
gcc_assert (No (Next (gnat_field)));
/* Ignore fields that have Corresponding_Discriminants since we'll
be setting that field in the parent. */
if (Present (Corresponding_Discriminant (Entity (gnat_field)))
&& Is_Tagged_Type (Scope (Entity (gnat_field))))
continue;
/* Before assigning a value in an aggregate make sure range checks
are done if required. Then convert to the type of the field. */
if (Do_Range_Check (Expression (gnat_assoc)))
@ -5956,14 +5978,6 @@ post_error_ne_tree_2 (const char *msg,
Error_Msg_Uint_2 = UI_From_Int (num);
post_error_ne_tree (msg, node, ent, t);
}
/* Set the node for a second '&' in the error message. */
void
set_second_error_entity (Entity_Id e)
{
Error_Msg_Node_2 = e;
}
/* Initialize the table that maps GNAT codes to GCC codes for simple
binary and unary operations. */

View File

@ -359,8 +359,8 @@ gnat_pushdecl (tree decl, Node_Id gnat_node)
&& !DECL_ARTIFICIAL (decl))))
TYPE_NAME (TREE_TYPE (decl)) = decl;
if (TREE_CODE (decl) != CONST_DECL)
rest_of_decl_compilation (decl, global_bindings_p (), 0);
/* if (TREE_CODE (decl) != CONST_DECL)
rest_of_decl_compilation (decl, global_bindings_p (), 0); */
}
/* Do little here. Set up the standard declarations later after the
@ -804,156 +804,181 @@ finish_record_type (tree record_type, tree fieldlist, bool has_rep,
}
if (!defer_debug)
write_record_type_debug_info (record_type);
}
/* Output the debug information associated to a record type. */
void
write_record_type_debug_info (tree record_type)
{
tree fieldlist = TYPE_FIELDS (record_type);
tree field;
bool var_size = false;
for (field = fieldlist; field; field = TREE_CHAIN (field))
{
/* If this record is of variable size, rename it so that the
debugger knows it is and make a new, parallel, record
that tells the debugger how the record is laid out. See
exp_dbug.ads. But don't do this for records that are padding
since they confuse GDB. */
if (var_size
&& !(TREE_CODE (record_type) == RECORD_TYPE
&& TYPE_IS_PADDING_P (record_type)))
/* We need to make an XVE/XVU record if any field has variable size,
whether or not the record does. For example, if we have an union,
it may be that all fields, rounded up to the alignment, have the
same size, in which case we'll use that size. But the debug
output routines (except Dwarf2) won't be able to output the fields,
so we need to make the special record. */
if (TREE_CODE (DECL_SIZE (field)) != INTEGER_CST)
{
tree new_record_type
= make_node (TREE_CODE (record_type) == QUAL_UNION_TYPE
? UNION_TYPE : TREE_CODE (record_type));
tree orig_name = TYPE_NAME (record_type);
tree orig_id
= (TREE_CODE (orig_name) == TYPE_DECL ? DECL_NAME (orig_name)
: orig_name);
tree new_id
= concat_id_with_name (orig_id,
TREE_CODE (record_type) == QUAL_UNION_TYPE
? "XVU" : "XVE");
tree last_pos = bitsize_zero_node;
tree old_field;
tree prev_old_field = 0;
var_size = true;
break;
}
}
TYPE_NAME (new_record_type) = new_id;
TYPE_ALIGN (new_record_type) = BIGGEST_ALIGNMENT;
TYPE_STUB_DECL (new_record_type)
= build_decl (TYPE_DECL, NULL_TREE, new_record_type);
DECL_ARTIFICIAL (TYPE_STUB_DECL (new_record_type)) = 1;
DECL_IGNORED_P (TYPE_STUB_DECL (new_record_type))
= DECL_IGNORED_P (TYPE_STUB_DECL (record_type));
TYPE_SIZE (new_record_type) = size_int (TYPE_ALIGN (record_type));
TYPE_SIZE_UNIT (new_record_type)
= size_int (TYPE_ALIGN (record_type) / BITS_PER_UNIT);
/* If this record is of variable size, rename it so that the
debugger knows it is and make a new, parallel, record
that tells the debugger how the record is laid out. See
exp_dbug.ads. But don't do this for records that are padding
since they confuse GDB. */
if (var_size
&& !(TREE_CODE (record_type) == RECORD_TYPE
&& TYPE_IS_PADDING_P (record_type)))
{
tree new_record_type
= make_node (TREE_CODE (record_type) == QUAL_UNION_TYPE
? UNION_TYPE : TREE_CODE (record_type));
tree orig_name = TYPE_NAME (record_type);
tree orig_id
= (TREE_CODE (orig_name) == TYPE_DECL ? DECL_NAME (orig_name)
: orig_name);
tree new_id
= concat_id_with_name (orig_id,
TREE_CODE (record_type) == QUAL_UNION_TYPE
? "XVU" : "XVE");
tree last_pos = bitsize_zero_node;
tree old_field;
tree prev_old_field = 0;
/* Now scan all the fields, replacing each field with a new
field corresponding to the new encoding. */
for (old_field = TYPE_FIELDS (record_type); old_field;
old_field = TREE_CHAIN (old_field))
TYPE_NAME (new_record_type) = new_id;
TYPE_ALIGN (new_record_type) = BIGGEST_ALIGNMENT;
TYPE_STUB_DECL (new_record_type)
= build_decl (TYPE_DECL, NULL_TREE, new_record_type);
DECL_ARTIFICIAL (TYPE_STUB_DECL (new_record_type)) = 1;
DECL_IGNORED_P (TYPE_STUB_DECL (new_record_type))
= DECL_IGNORED_P (TYPE_STUB_DECL (record_type));
TYPE_SIZE (new_record_type) = size_int (TYPE_ALIGN (record_type));
TYPE_SIZE_UNIT (new_record_type)
= size_int (TYPE_ALIGN (record_type) / BITS_PER_UNIT);
/* Now scan all the fields, replacing each field with a new
field corresponding to the new encoding. */
for (old_field = TYPE_FIELDS (record_type); old_field;
old_field = TREE_CHAIN (old_field))
{
tree field_type = TREE_TYPE (old_field);
tree field_name = DECL_NAME (old_field);
tree new_field;
tree curpos = bit_position (old_field);
bool var = false;
unsigned int align = 0;
tree pos;
/* See how the position was modified from the last position.
There are two basic cases we support: a value was added
to the last position or the last position was rounded to
a boundary and they something was added. Check for the
first case first. If not, see if there is any evidence
of rounding. If so, round the last position and try
again.
If this is a union, the position can be taken as zero. */
if (TREE_CODE (new_record_type) == UNION_TYPE)
pos = bitsize_zero_node, align = 0;
else
pos = compute_related_constant (curpos, last_pos);
if (!pos && TREE_CODE (curpos) == MULT_EXPR
&& TREE_CODE (TREE_OPERAND (curpos, 1)) == INTEGER_CST)
{
tree field_type = TREE_TYPE (old_field);
tree field_name = DECL_NAME (old_field);
tree new_field;
tree curpos = bit_position (old_field);
bool var = false;
unsigned int align = 0;
tree pos;
/* See how the position was modified from the last position.
There are two basic cases we support: a value was added
to the last position or the last position was rounded to
a boundary and they something was added. Check for the
first case first. If not, see if there is any evidence
of rounding. If so, round the last position and try
again.
If this is a union, the position can be taken as zero. */
if (TREE_CODE (new_record_type) == UNION_TYPE)
pos = bitsize_zero_node, align = 0;
else
pos = compute_related_constant (curpos, last_pos);
if (!pos && TREE_CODE (curpos) == MULT_EXPR
&& TREE_CODE (TREE_OPERAND (curpos, 1)) == INTEGER_CST)
{
align = TREE_INT_CST_LOW (TREE_OPERAND (curpos, 1));
pos = compute_related_constant (curpos,
round_up (last_pos, align));
}
else if (!pos && TREE_CODE (curpos) == PLUS_EXPR
&& TREE_CODE (TREE_OPERAND (curpos, 1)) == INTEGER_CST
&& TREE_CODE (TREE_OPERAND (curpos, 0)) == MULT_EXPR
&& host_integerp (TREE_OPERAND
(TREE_OPERAND (curpos, 0), 1),
1))
{
align
= tree_low_cst
(TREE_OPERAND (TREE_OPERAND (curpos, 0), 1), 1);
pos = compute_related_constant (curpos,
round_up (last_pos, align));
}
else if (potential_alignment_gap (prev_old_field, old_field,
pos))
{
align = TYPE_ALIGN (field_type);
pos = compute_related_constant (curpos,
round_up (last_pos, align));
}
/* If we can't compute a position, set it to zero.
??? We really should abort here, but it's too much work
to get this correct for all cases. */
if (!pos)
pos = bitsize_zero_node;
/* See if this type is variable-size and make a new type
and indicate the indirection if so. */
if (TREE_CODE (DECL_SIZE (old_field)) != INTEGER_CST)
{
field_type = build_pointer_type (field_type);
var = true;
}
/* Make a new field name, if necessary. */
if (var || align != 0)
{
char suffix[6];
if (align != 0)
sprintf (suffix, "XV%c%u", var ? 'L' : 'A',
align / BITS_PER_UNIT);
else
strcpy (suffix, "XVL");
field_name = concat_id_with_name (field_name, suffix);
}
new_field = create_field_decl (field_name, field_type,
new_record_type, 0,
DECL_SIZE (old_field), pos, 0);
TREE_CHAIN (new_field) = TYPE_FIELDS (new_record_type);
TYPE_FIELDS (new_record_type) = new_field;
/* If old_field is a QUAL_UNION_TYPE, take its size as being
zero. The only time it's not the last field of the record
is when there are other components at fixed positions after
it (meaning there was a rep clause for every field) and we
want to be able to encode them. */
last_pos = size_binop (PLUS_EXPR, bit_position (old_field),
(TREE_CODE (TREE_TYPE (old_field))
== QUAL_UNION_TYPE)
? bitsize_zero_node
: DECL_SIZE (old_field));
prev_old_field = old_field;
align = TREE_INT_CST_LOW (TREE_OPERAND (curpos, 1));
pos = compute_related_constant (curpos,
round_up (last_pos, align));
}
else if (!pos && TREE_CODE (curpos) == PLUS_EXPR
&& TREE_CODE (TREE_OPERAND (curpos, 1)) == INTEGER_CST
&& TREE_CODE (TREE_OPERAND (curpos, 0)) == MULT_EXPR
&& host_integerp (TREE_OPERAND
(TREE_OPERAND (curpos, 0), 1),
1))
{
align
= tree_low_cst
(TREE_OPERAND (TREE_OPERAND (curpos, 0), 1), 1);
pos = compute_related_constant (curpos,
round_up (last_pos, align));
}
else if (potential_alignment_gap (prev_old_field, old_field,
pos))
{
align = TYPE_ALIGN (field_type);
pos = compute_related_constant (curpos,
round_up (last_pos, align));
}
TYPE_FIELDS (new_record_type)
= nreverse (TYPE_FIELDS (new_record_type));
/* If we can't compute a position, set it to zero.
rest_of_type_compilation (new_record_type, global_bindings_p ());
??? We really should abort here, but it's too much work
to get this correct for all cases. */
if (!pos)
pos = bitsize_zero_node;
/* See if this type is variable-size and make a new type
and indicate the indirection if so. */
if (TREE_CODE (DECL_SIZE (old_field)) != INTEGER_CST)
{
field_type = build_pointer_type (field_type);
var = true;
}
/* Make a new field name, if necessary. */
if (var || align != 0)
{
char suffix[6];
if (align != 0)
sprintf (suffix, "XV%c%u", var ? 'L' : 'A',
align / BITS_PER_UNIT);
else
strcpy (suffix, "XVL");
field_name = concat_id_with_name (field_name, suffix);
}
new_field = create_field_decl (field_name, field_type,
new_record_type, 0,
DECL_SIZE (old_field), pos, 0);
TREE_CHAIN (new_field) = TYPE_FIELDS (new_record_type);
TYPE_FIELDS (new_record_type) = new_field;
/* If old_field is a QUAL_UNION_TYPE, take its size as being
zero. The only time it's not the last field of the record
is when there are other components at fixed positions after
it (meaning there was a rep clause for every field) and we
want to be able to encode them. */
last_pos = size_binop (PLUS_EXPR, bit_position (old_field),
(TREE_CODE (TREE_TYPE (old_field))
== QUAL_UNION_TYPE)
? bitsize_zero_node
: DECL_SIZE (old_field));
prev_old_field = old_field;
}
rest_of_type_compilation (record_type, global_bindings_p ());
TYPE_FIELDS (new_record_type)
= nreverse (TYPE_FIELDS (new_record_type));
rest_of_type_compilation (new_record_type, global_bindings_p ());
}
rest_of_type_compilation (record_type, global_bindings_p ());
}
/* Utility function of above to merge LAST_SIZE, the previous size of a record
@ -2451,28 +2476,12 @@ update_pointer_to (tree old_type, tree new_type)
for (; ptr; ptr = TYPE_NEXT_PTR_TO (ptr))
for (ptr1 = TYPE_MAIN_VARIANT (ptr); ptr1;
ptr1 = TYPE_NEXT_VARIANT (ptr1))
{
TREE_TYPE (ptr1) = new_type;
TREE_TYPE (ptr1) = new_type;
if (TYPE_NAME (ptr1)
&& TREE_CODE (TYPE_NAME (ptr1)) == TYPE_DECL
&& TREE_CODE (new_type) != ENUMERAL_TYPE)
rest_of_decl_compilation (TYPE_NAME (ptr1),
global_bindings_p (), 0);
}
for (; ref; ref = TYPE_NEXT_PTR_TO (ref))
for (; ref; ref = TYPE_NEXT_REF_TO (ref))
for (ref1 = TYPE_MAIN_VARIANT (ref); ref1;
ref1 = TYPE_NEXT_VARIANT (ref1))
{
TREE_TYPE (ref1) = new_type;
if (TYPE_NAME (ref1)
&& TREE_CODE (TYPE_NAME (ref1)) == TYPE_DECL
&& TREE_CODE (new_type) != ENUMERAL_TYPE)
rest_of_decl_compilation (TYPE_NAME (ref1),
global_bindings_p (), 0);
}
TREE_TYPE (ref1) = new_type;
}
/* Now deal with the unconstrained array case. In this case the "pointer"
@ -2919,10 +2928,13 @@ convert (tree type, tree expr)
{
if (TREE_TYPE (tem) == etype)
return build1 (CONVERT_EXPR, type, expr);
else if (TREE_CODE (TREE_TYPE (tem)) == RECORD_TYPE
&& (TYPE_JUSTIFIED_MODULAR_P (TREE_TYPE (tem))
|| TYPE_IS_PADDING_P (TREE_TYPE (tem)))
&& TREE_TYPE (TYPE_FIELDS (TREE_TYPE (tem))) == etype)
/* Accept slight type variations. */
if (TREE_TYPE (tem) == TYPE_MAIN_VARIANT (etype)
|| (TREE_CODE (TREE_TYPE (tem)) == RECORD_TYPE
&& (TYPE_JUSTIFIED_MODULAR_P (TREE_TYPE (tem))
|| TYPE_IS_PADDING_P (TREE_TYPE (tem)))
&& TREE_TYPE (TYPE_FIELDS (TREE_TYPE (tem))) == etype))
return build1 (CONVERT_EXPR, type,
convert (TREE_TYPE (tem), expr));
}