From 8a91f77d3ac51d7b1aa07c00929c64a91b08175f Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Sat, 18 Jan 2020 23:40:05 +0100 Subject: [PATCH] [Ada] Fix fallout of cleanup to Has_Private_View mechanism 2020-06-04 Eric Botcazou gcc/ada/ * sem_ch12.adb (Check_Generic_Actuals): Also restore the proper views of the actuals of the parent instances if the formals are used as actuals of the children. (Instantiate_Type): Add comment. --- gcc/ada/sem_ch12.adb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index bb49e8388b5..23ee796b455 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -6802,8 +6802,35 @@ package body Sem_Ch12 is and then Scope (Etype (E)) /= Instance and then Is_Entity_Name (Subtype_Indication (Parent (E))) then + -- Restore the proper view of the actual from the information + -- saved earlier by Instantiate_Type. + Check_Private_View (Subtype_Indication (Parent (E))); + -- If the actual is itself the formal of a parent instance, + -- then also restore the proper view of its actual and so on. + -- That's necessary for nested instantiations of the form + + -- generic + -- type Component is private; + -- type Array_Type is array (Positive range <>) of Component; + -- procedure Proc; + + -- when the outermost actuals have inconsistent views, because + -- the Component_Type of Array_Type of the inner instantiations + -- is the actual of Component of the outermost one and not that + -- of the corresponding inner instantiations. + + Astype := Ancestor_Subtype (E); + while Present (Astype) + and then Nkind (Parent (Astype)) = N_Subtype_Declaration + and then Present (Generic_Parent_Type (Parent (Astype))) + and then Is_Entity_Name (Subtype_Indication (Parent (Astype))) + loop + Check_Private_View (Subtype_Indication (Parent (Astype))); + Astype := Ancestor_Subtype (Astype); + end loop; + Set_Is_Generic_Actual_Type (E); if Is_Private_Type (E) and then Present (Full_View (E)) then @@ -13603,6 +13630,10 @@ package body Sem_Ch12 is Defining_Identifier => Subt, Subtype_Indication => New_Occurrence_Of (Act_T, Loc)); + -- Record whether the actual is private at this point, so that + -- Check_Generic_Actuals can restore its proper view before the + -- semantic analysis of the instance. + if Is_Private_Type (Act_T) then Set_Has_Private_View (Subtype_Indication (Decl_Node)); end if; -- 2.30.2