diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index df1daacec69..964d63d369f 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,13 @@ +2018-05-30 Ed Schonberg + + * 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 * gcc-interface/trans.c (gnat_to_gnu) : Add diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 871686b661c..3bb406da68a 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -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)); diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 327bf3148f9..ca54ffc5744 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -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