[Ada] Refine logic to set Needs_Activation_Record on subprogram types

2018-05-30  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* sem_ch3.adb (Access_Subprogram_Declaration): The flag
	Needs_Activation_Record is only needed on a subprogram type, not on a
	pointer to such.
	* sem_res.adb (Resolve_Selected_Component): If the context type and the
	component type are anonymous access to subprograms, use the component
	type to obtain the proper value of Needs_Activation_Record flag for the
	expression.

From-SVN: r260932
This commit is contained in:
Ed Schonberg 2018-05-30 08:57:11 +00:00 committed by Pierre-Marie de Rodat
parent df8aa2b7e1
commit 131780ac08
3 changed files with 23 additions and 4 deletions

View File

@ -1,3 +1,13 @@
2018-05-30 Ed Schonberg <schonberg@adacore.com>
* sem_ch3.adb (Access_Subprogram_Declaration): The flag
Needs_Activation_Record is only needed on a subprogram type, not on a
pointer to such.
* sem_res.adb (Resolve_Selected_Component): If the context type and the
component type are anonymous access to subprograms, use the component
type to obtain the proper value of Needs_Activation_Record flag for the
expression.
2018-05-30 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/trans.c (gnat_to_gnu) <N_Assignment_Statement>: Add

View File

@ -1307,11 +1307,9 @@ package body Sem_Ch3 is
-- If the access_to_subprogram is not declared at the library level,
-- it can only point to subprograms that are at the same or deeper
-- accessibility level. All such might require an activation record
-- when compiling for C.
-- accessibility level. The corresponding subprogram type might
-- require an activation record when compiling for C.
Set_Needs_Activation_Record (T_Name,
not Is_Library_Level_Entity (T_Name));
Set_Needs_Activation_Record (Desig_Type,
not Is_Library_Level_Entity (T_Name));

View File

@ -10118,6 +10118,17 @@ package body Sem_Res is
Set_Etype (N, Typ);
Set_Entity_With_Checks (S, Comp1);
-- The type of the context and that of the component are
-- compatible and in general identical, but if they are anonymous
-- access_to_subprogram types the relevwnt type is that of the
-- component. Thid matters in Unnest_Subprograms mode, where the
-- relevant context is the one in which the type is declared. not
-- the point of use. this determines what activation record to use.
if Ekind (Typ) = E_Anonymous_Access_Subprogram_Type then
Set_Etype (N, Etype (Comp1));
end if;
else
-- Resolve prefix with its type