diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2023-06-12 12:36:56 +0200 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2023-06-27 14:05:50 +0200 |
commit | 125a2260ce07e384238f8569c77d07c56762d39c (patch) | |
tree | 4b468aa442c7c317532859c539c3bb4b54278dfd /gcc | |
parent | f404dd44078fdecf83b142831d6cc6f52f3a76b6 (diff) | |
download | gcc-125a2260ce07e384238f8569c77d07c56762d39c.zip gcc-125a2260ce07e384238f8569c77d07c56762d39c.tar.gz gcc-125a2260ce07e384238f8569c77d07c56762d39c.tar.bz2 |
ada: Plug another loophole in the handling of private views in instances
This deals with discriminants of types declared in package bodies.
gcc/ada/
* sem_ch12.adb (Check_Private_View): Also check the type of
visible discriminants in record and concurrent types.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/sem_ch12.adb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index d5280ce..fbfc2db 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -7710,6 +7710,9 @@ package body Sem_Ch12 is Prepend_Elmt (Typ, Exchanged_Views); Exchange_Declarations (Etype (Get_Associated_Node (N))); + -- Check that the available views of Typ match their respective flag. + -- Note that the type of a visible discriminant is never private. + else Check_Private_Type (Typ, Has_Private_View (N)); @@ -7720,6 +7723,20 @@ package body Sem_Ch12 is elsif Is_Array_Type (Typ) then Check_Private_Type (Component_Type (Typ), Has_Secondary_Private_View (N)); + + elsif (Is_Record_Type (Typ) or else Is_Concurrent_Type (Typ)) + and then Has_Discriminants (Typ) + then + declare + Disc : Entity_Id; + + begin + Disc := First_Discriminant (Typ); + while Present (Disc) loop + Check_Private_Type (Etype (Disc), False); + Next_Discriminant (Disc); + end loop; + end; end if; end if; end if; |