From: Eric Botcazou Date: Tue, 16 Jun 2020 07:58:09 +0000 (+0200) Subject: [Ada] Remove obsolete special case in Switch_View X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=2c3bc159a8ca5f128e934b0357900c40b9d965fb;p=gcc.git [Ada] Remove obsolete special case in Switch_View gcc/ada/ * sem_ch12.adb (Instantiate_Package_Body): Add commentary for a nesting issue with parent handling and private view switching. (Switch_View): Do not skip specific private-dependent subtypes. --- diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index b3a4ad4d468..e09a7ac1e3f 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -12029,6 +12029,19 @@ package body Sem_Ch12 is end if; Restore_Hidden_Primitives (Vis_Prims_List); + + -- Restore the private views that were made visible when the body of + -- the instantiation was created. Note that, in the case where one of + -- these private views is declared in the parent, there is a nesting + -- issue with the calls to Install_Parent and Remove_Parent made in + -- between above with In_Body set to True, because these calls also + -- want to swap and restore this private view respectively. In this + -- case, the call to Install_Parent does nothing, but the call to + -- Remove_Parent does restore the private view, thus undercutting the + -- call to Restore_Private_Views. That's OK under the condition that + -- the two mechanisms swap exactly the same entities, in particular + -- the private entities dependent on the primary private entities. + Restore_Private_Views (Act_Decl_Id); -- Remove the current unit from visibility if this is an instance @@ -16680,19 +16693,9 @@ package body Sem_Ch12 is end if; while Present (Priv_Elmt) loop - Priv_Sub := (Node (Priv_Elmt)); - - -- We avoid flipping the subtype if the Etype of its full view is - -- private because this would result in a malformed subtype. This - -- occurs when the Etype of the subtype full view is the full view of - -- the base type (and since the base types were just switched, the - -- subtype is pointing to the wrong view). This is currently the case - -- for tagged record types, access types (maybe more?) and needs to - -- be resolved. ??? - - if Present (Full_View (Priv_Sub)) - and then not Is_Private_Type (Etype (Full_View (Priv_Sub))) - then + Priv_Sub := Node (Priv_Elmt); + + if Present (Full_View (Priv_Sub)) then Prepend_Elmt (Full_View (Priv_Sub), Exchanged_Views); Exchange_Declarations (Priv_Sub); end if;