diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2020-01-18 23:40:05 +0100 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-06-04 05:10:56 -0400 |
commit | 8a91f77d3ac51d7b1aa07c00929c64a91b08175f (patch) | |
tree | b5f8ac3372049b6b6f497765da62df00ca3836cf /gcc | |
parent | 9f3a17960b09f36bf67e15eb8a5e1feea9c2c9ba (diff) | |
download | gcc-8a91f77d3ac51d7b1aa07c00929c64a91b08175f.zip gcc-8a91f77d3ac51d7b1aa07c00929c64a91b08175f.tar.gz gcc-8a91f77d3ac51d7b1aa07c00929c64a91b08175f.tar.bz2 |
[Ada] Fix fallout of cleanup to Has_Private_View mechanism
2020-06-04 Eric Botcazou <ebotcazou@adacore.com>
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.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/sem_ch12.adb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index bb49e83..23ee796 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; |