]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Plug another loophole in the handling of private views in instances
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 12 Jun 2023 10:36:56 +0000 (12:36 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 27 Jun 2023 12:05:50 +0000 (14:05 +0200)
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.

gcc/ada/sem_ch12.adb

index d5280cea712750e9fdb41b2233379e1a0efa0f0d..fbfc2db7f9a2254a12a1ef8c889c64a43db279a2 100644 (file)
@@ -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;