Commit 8ea456b9 by Eric Botcazou Committed by Eric Botcazou

decl.c (gnat_to_gnu_entity): Retrofit handling of unconstrained array types as…

decl.c (gnat_to_gnu_entity): Retrofit handling of unconstrained array types as designated types into common...

	* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Access_Type>: Retrofit
	handling of unconstrained array types as designated types into common
	processing.  Also handle array types as incomplete designated types.

From-SVN: r233807
parent 68ec5613
2016-02-29 Eric Botcazou <ebotcazou@adacore.com> 2016-02-29 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Access_Type>: Retrofit
handling of unconstrained array types as designated types into common
processing. Also handle array types as incomplete designated types.
2016-02-29 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity) <Concurrent types>: In * gcc-interface/decl.c (gnat_to_gnu_entity) <Concurrent types>: In
ASIS mode, fully lay out the minimal record type. ASIS mode, fully lay out the minimal record type.
......
...@@ -3855,8 +3855,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -3855,8 +3855,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
/* The type actually used to represent the designated type, either /* The type actually used to represent the designated type, either
gnat_desig_full or gnat_desig_equiv. */ gnat_desig_full or gnat_desig_equiv. */
Entity_Id gnat_desig_rep; Entity_Id gnat_desig_rep;
/* True if this is a pointer to an unconstrained array. */
bool is_unconstrained_array;
/* We want to know if we'll be seeing the freeze node for any /* We want to know if we'll be seeing the freeze node for any
incomplete type we may be pointing to. */ incomplete type we may be pointing to. */
bool in_main_unit bool in_main_unit
...@@ -3890,62 +3888,26 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -3890,62 +3888,26 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
&& Ekind (Etype (gnat_desig_full)) == E_Record_Type))) && Ekind (Etype (gnat_desig_full)) == E_Record_Type)))
gnat_desig_full = Etype (gnat_desig_full); gnat_desig_full = Etype (gnat_desig_full);
/* Set the type that's actually the representation of the designated /* Set the type that's the representation of the designated type. */
type and also flag whether we have a unconstrained array. */
gnat_desig_rep gnat_desig_rep
= Present (gnat_desig_full) ? gnat_desig_full : gnat_desig_equiv; = Present (gnat_desig_full) ? gnat_desig_full : gnat_desig_equiv;
is_unconstrained_array
= Is_Array_Type (gnat_desig_rep) && !Is_Constrained (gnat_desig_rep);
/* If we are pointing to an incomplete type whose completion is an
unconstrained array, make dummy fat and thin pointer types to it.
Likewise if the type itself is dummy or an unconstrained array. */
if (is_unconstrained_array
&& (Present (gnat_desig_full)
|| (present_gnu_tree (gnat_desig_equiv)
&& TYPE_IS_DUMMY_P
(TREE_TYPE (get_gnu_tree (gnat_desig_equiv))))
|| (!in_main_unit
&& defer_incomplete_level != 0
&& !present_gnu_tree (gnat_desig_equiv))
|| (in_main_unit
&& is_from_limited_with
&& Present (Freeze_Node (gnat_desig_equiv)))))
{
if (present_gnu_tree (gnat_desig_rep))
gnu_desig_type = TREE_TYPE (get_gnu_tree (gnat_desig_rep));
else
{
gnu_desig_type = make_dummy_type (gnat_desig_rep);
made_dummy = true;
}
/* If the call above got something that has a pointer, the pointer
is our type. This could have happened either because the type
was elaborated or because somebody else executed the code. */
if (!TYPE_POINTER_TO (gnu_desig_type))
build_dummy_unc_pointer_types (gnat_desig_equiv, gnu_desig_type);
gnu_type = TYPE_POINTER_TO (gnu_desig_type);
}
/* If we already know what the full type is, use it. */ /* If we already know what the full type is, use it. */
else if (Present (gnat_desig_full) if (Present (gnat_desig_full) && present_gnu_tree (gnat_desig_full))
&& present_gnu_tree (gnat_desig_full))
gnu_desig_type = TREE_TYPE (get_gnu_tree (gnat_desig_full)); gnu_desig_type = TREE_TYPE (get_gnu_tree (gnat_desig_full));
/* Get the type of the thing we are to point to and build a pointer to /* Get the type of the thing we are to point to and build a pointer to
it. If it is a reference to an incomplete or private type with a it. If it is a reference to an incomplete or private type with a
full view that is a record, make a dummy type node and get the full view that is a record or an array, make a dummy type node and
actual type later when we have verified it is safe. */ get the actual type later when we have verified it is safe. */
else if ((!in_main_unit else if ((!in_main_unit
&& !present_gnu_tree (gnat_desig_equiv) && !present_gnu_tree (gnat_desig_equiv)
&& Present (gnat_desig_full) && Present (gnat_desig_full)
&& !present_gnu_tree (gnat_desig_full) && (Is_Record_Type (gnat_desig_full)
&& Is_Record_Type (gnat_desig_full)) || Is_Array_Type (gnat_desig_full)))
/* Likewise if we are pointing to a record or array and we are /* Likewise if we are pointing to a record or array and we are
to defer elaborating incomplete types. We do this as this to defer elaborating incomplete types. We do this as this
access type may be the full view of a private type. Note access type may be the full view of a private type. */
that the unconstrained array case is handled above. */
|| ((!in_main_unit || imported_p) || ((!in_main_unit || imported_p)
&& defer_incomplete_level != 0 && defer_incomplete_level != 0
&& !present_gnu_tree (gnat_desig_equiv) && !present_gnu_tree (gnat_desig_equiv)
...@@ -3958,11 +3920,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -3958,11 +3920,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
in which case we make the dummy type and it will be reused in which case we make the dummy type and it will be reused
when the declaration is finally processed. In both cases, when the declaration is finally processed. In both cases,
the pointer eventually created below will be automatically the pointer eventually created below will be automatically
adjusted when the freeze node is processed. Note that the adjusted when the freeze node is processed. */
unconstrained array case is handled above. */ || (in_main_unit
|| (in_main_unit && is_from_limited_with
&& is_from_limited_with && Present (Freeze_Node (gnat_desig_rep))))
&& Present (Freeze_Node (gnat_desig_rep))))
{ {
gnu_desig_type = make_dummy_type (gnat_desig_equiv); gnu_desig_type = make_dummy_type (gnat_desig_equiv);
made_dummy = true; made_dummy = true;
...@@ -3995,8 +3956,19 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -3995,8 +3956,19 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
break; break;
} }
/* For an unconstrained array, make dummy fat & thin pointer types. */
if (Is_Array_Type (gnat_desig_rep) && !Is_Constrained (gnat_desig_rep))
{
/* If the processing above got something that has a pointer, then
we are done. This could have happened either because the type
was elaborated or because somebody else executed the code. */
if (!TYPE_POINTER_TO (gnu_desig_type))
build_dummy_unc_pointer_types (gnat_desig_equiv, gnu_desig_type);
gnu_type = TYPE_POINTER_TO (gnu_desig_type);
}
/* If we haven't done it yet, build the pointer type the usual way. */ /* If we haven't done it yet, build the pointer type the usual way. */
if (!gnu_type) else if (!gnu_type)
{ {
/* Modify the designated type if we are pointing only to constant /* Modify the designated type if we are pointing only to constant
objects, but don't do it for unconstrained arrays. */ objects, but don't do it for unconstrained arrays. */
......
-- { dg-do compile }
with Incomplete4_Pkg; use Incomplete4_Pkg;
with System;
procedure Incomplete4 is
L : System.Address := A'Address;
begin
null;
end;
package Incomplete4_Pkg is
type Circular_Type;
type Ptr is access Circular_Type;
type Circular_Type is array (1..100) of Ptr;
A : Circular_Type;
end Incomplete4_Pkg;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment