Commit cb55aefb by Eric Botcazou Committed by Eric Botcazou

decl.c (is_from_limited_with_of_main): New predicate.

	* gcc-interface/decl.c (is_from_limited_with_of_main): New predicate.
	(gnat_to_gnu_entity) <E_Subprogram_Type>: Invoke it on return and
	parameter types to detect circularities in ASIS mode.
	* gcc-interface/trans.c (Attribute_to_gnu): Mention AI05-0151.

From-SVN: r221447
parent c8dbf886
2015-03-16 Eric Botcazou <ebotcazou@adacore.com> 2015-03-16 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (is_from_limited_with_of_main): New predicate.
(gnat_to_gnu_entity) <E_Subprogram_Type>: Invoke it on return and
parameter types to detect circularities in ASIS mode.
* gcc-interface/trans.c (Attribute_to_gnu): Mention AI05-0151.
2015-03-16 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Abstract_State>: Do not * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Abstract_State>: Do not
short-circuit the regular handling. short-circuit the regular handling.
......
...@@ -182,6 +182,7 @@ static tree gnat_to_gnu_component_type (Entity_Id, bool, bool); ...@@ -182,6 +182,7 @@ static tree gnat_to_gnu_component_type (Entity_Id, bool, bool);
static tree gnat_to_gnu_param (Entity_Id, Mechanism_Type, Entity_Id, bool, static tree gnat_to_gnu_param (Entity_Id, Mechanism_Type, Entity_Id, bool,
bool *); bool *);
static tree gnat_to_gnu_field (Entity_Id, tree, int, bool, bool); static tree gnat_to_gnu_field (Entity_Id, tree, int, bool, bool);
static bool is_from_limited_with_of_main (Entity_Id);
static tree change_qualified_type (tree, int); static tree change_qualified_type (tree, int);
static bool same_discriminant_p (Entity_Id, Entity_Id); static bool same_discriminant_p (Entity_Id, Entity_Id);
static bool array_type_has_nonaliased_component (tree, Entity_Id); static bool array_type_has_nonaliased_component (tree, Entity_Id);
...@@ -4252,11 +4253,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -4252,11 +4253,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
context may now appear in parameter and result profiles. If context may now appear in parameter and result profiles. If
we are only annotating types, break circularities here. */ we are only annotating types, break circularities here. */
if (type_annotate_only if (type_annotate_only
&& IN (Ekind (gnat_return_type), Incomplete_Kind) && is_from_limited_with_of_main (gnat_return_type))
&& From_Limited_With (gnat_return_type)
&& In_Extended_Main_Code_Unit
(Non_Limited_View (gnat_return_type))
&& !present_gnu_tree (Non_Limited_View (gnat_return_type)))
gnu_return_type = ptr_void_type_node; gnu_return_type = ptr_void_type_node;
else else
gnu_return_type = gnat_to_gnu_type (gnat_return_type); gnu_return_type = gnat_to_gnu_type (gnat_return_type);
...@@ -4365,11 +4362,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) ...@@ -4365,11 +4362,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
context may now appear in parameter and result profiles. If context may now appear in parameter and result profiles. If
we are only annotating types, break circularities here. */ we are only annotating types, break circularities here. */
if (type_annotate_only if (type_annotate_only
&& IN (Ekind (gnat_param_type), Incomplete_Kind) && is_from_limited_with_of_main (gnat_param_type))
&& From_Limited_With (Etype (gnat_param_type))
&& In_Extended_Main_Code_Unit
(Non_Limited_View (gnat_param_type))
&& !present_gnu_tree (Non_Limited_View (gnat_param_type)))
{ {
gnu_param_type = ptr_void_type_node; gnu_param_type = ptr_void_type_node;
fake_param_type = true; fake_param_type = true;
...@@ -5810,6 +5803,30 @@ gnat_to_gnu_param (Entity_Id gnat_param, Mechanism_Type mech, ...@@ -5810,6 +5803,30 @@ gnat_to_gnu_param (Entity_Id gnat_param, Mechanism_Type mech,
return gnu_param; return gnu_param;
} }
/* Return true if GNAT_ENTITY is an incomplete entity coming from a limited
with of the main unit and whose full view has not been elaborated yet. */
static bool
is_from_limited_with_of_main (Entity_Id gnat_entity)
{
/* Class-wide types are always transformed into their root type. */
if (Ekind (gnat_entity) == E_Class_Wide_Type)
gnat_entity = Root_Type (gnat_entity);
if (IN (Ekind (gnat_entity), Incomplete_Kind)
&& From_Limited_With (gnat_entity))
{
Entity_Id gnat_full_view = Non_Limited_View (gnat_entity);
if (present_gnu_tree (gnat_full_view))
return false;
return In_Extended_Main_Code_Unit (gnat_full_view);
}
return false;
}
/* Like build_qualified_type, but TYPE_QUALS is added to the existing /* Like build_qualified_type, but TYPE_QUALS is added to the existing
qualifiers on TYPE. */ qualifiers on TYPE. */
......
...@@ -1593,8 +1593,9 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) ...@@ -1593,8 +1593,9 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute)
bool prefix_unused = false; bool prefix_unused = false;
/* ??? If this is an access attribute for a public subprogram to be used in /* ??? If this is an access attribute for a public subprogram to be used in
a dispatch table, do not translate its type as it's useless there and the a dispatch table, do not translate its type as it's useless in this case
parameter types might be incomplete types coming from a limited with. */ and the parameter types might be incomplete types coming from a limited
context in Ada 2012 (AI05-0151). */
if (Ekind (Etype (gnat_node)) == E_Access_Subprogram_Type if (Ekind (Etype (gnat_node)) == E_Access_Subprogram_Type
&& Is_Dispatch_Table_Entity (Etype (gnat_node)) && Is_Dispatch_Table_Entity (Etype (gnat_node))
&& Nkind (gnat_prefix) == N_Identifier && Nkind (gnat_prefix) == N_Identifier
......
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