In ihe context of a generic package declaration, a private with-clause on a
child unit implies that the implicit with clauses on its parents are private
as well. Previous to this patch, GNAT applied this  rule applied only to non-
eneric units.

Compiling the following must be rejected with:

   gp1.ads:4:23: "Ada" is not visible
   gp1.ads:4:23: non-visible declaration at ada.ads:16

---
private with Ada.Containers.Vectors;  -- NB: private with
generic
   type T1 is tagged private;
   Default_Capacity : Ada.Containers.Count_Type := 2;
   -- What allows 'Ada.Containers.Count_Type' to be visible?
package GP1 is
   type T2 is tagged limited private;
private
   package T1_Vectors is
      new Ada.Containers.Vectors (Natural, T1);
   type T2 is tagged limited record
      Capacity : Ada.Containers.Count_Type := Default_Capacity;
      V        : T1_Vectors.Vector;
   end record;
end GP1;

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-05-15  Ed Schonberg  <schonb...@adacore.com>

        * sem_ch10.adb (Expand_With_Clause): In the context of a generic
        package declaration, a private with-clause on a child unit implies
        that the implicit with clauses on its parents are private as well.

Index: sem_ch10.adb
===================================================================
--- sem_ch10.adb        (revision 187522)
+++ sem_ch10.adb        (working copy)
@@ -2987,10 +2987,13 @@
       Set_First_Name         (Withn, True);
       Set_Implicit_With      (Withn, True);
 
-      --  If the unit is a package declaration, a private_with_clause on a
-      --  child unit implies the implicit with on the parent is also private.
+      --  If the unit is a package or generic package  declaration, a private_
+      --  with_clause on a child unit implies that the implicit with on the
+      --  parent is also private.
 
-      if Nkind (Unit (N)) = N_Package_Declaration then
+      if Nkind_In
+         (Unit (N), N_Package_Declaration, N_Generic_Package_Declaration)
+      then
          Set_Private_Present (Withn, Private_Present (Item));
       end if;
 

Reply via email to