einfo.adb (First_Private_Entity, [...]): Addition of one barrier to avoid wrong usage...
authorJavier Miranda <miranda@adacore.com>
Fri, 18 Mar 2005 11:48:05 +0000 (12:48 +0100)
committerArnaud Charlet <charlet@gcc.gnu.org>
Fri, 18 Mar 2005 11:48:05 +0000 (12:48 +0100)
2005-03-17  Javier Miranda  <miranda@adacore.com>

* einfo.adb (First_Private_Entity, Set_First_Private_Entity): Addition
of one barrier to avoid wrong usage of this attribute.

* sem_ch12.adb (Formal_Entity): Fix erroneous usage of the attribute
First_Private_Entity.

* sem_ch7.adb (Install_Visible_Declarations): Add a barrier to protect
the subprogram against wrong usage.
Adapt the code to traverse the entities in the
scope of a record_type because in addition to its usage regarding
packages, this subprogram is also called by Expand_N_Freeze_Entity
to install the visible declarations of the enclosing scope of a
record_type_with_private to establish the proper visibility before
freezing the entity and related subprograms.

From-SVN: r96664

gcc/ada/einfo.adb
gcc/ada/sem_ch12.adb
gcc/ada/sem_ch7.adb

index 900b69a7e2bd613bf9a6d11f99d0d53d40f4ade4..20327cb6d4bf9b55509ac9e985be4da814436901 100644 (file)
@@ -1003,6 +1003,12 @@ package body Einfo is
 
    function First_Private_Entity (Id : E) return E is
    begin
+      pragma Assert (Ekind (Id) = E_Package
+                       or else Ekind (Id) = E_Generic_Package
+                       or else Ekind (Id) = E_Protected_Type
+                       or else Ekind (Id) = E_Protected_Subtype
+                       or else Ekind (Id) = E_Task_Type
+                       or else Ekind (Id) = E_Task_Subtype);
       return Node16 (Id);
    end First_Private_Entity;
 
@@ -2981,7 +2987,12 @@ package body Einfo is
 
    procedure Set_First_Private_Entity (Id : E; V : E) is
    begin
-      pragma Assert (Nkind (Id) in N_Entity);
+      pragma Assert (Ekind (Id) = E_Package
+                       or else Ekind (Id) = E_Generic_Package
+                       or else Ekind (Id) = E_Protected_Type
+                       or else Ekind (Id) = E_Protected_Subtype
+                       or else Ekind (Id) = E_Task_Type
+                       or else Ekind (Id) = E_Task_Subtype);
       Set_Node16 (Id, V);
    end Set_First_Private_Entity;
 
index 53bb2579796ee99068ab662604426ff6b8ac1014..661ac7651bc45d0d1dbcc8ba4dd1e08a77ab4580 100644 (file)
@@ -6518,7 +6518,7 @@ package body Sem_Ch12 is
 
                   while Present (Actual_Ent)
                     and then Present (Formal_Node)
-                    and then Actual_Ent /= First_Private_Entity (Act_Ent)
+                    and then Actual_Ent /= First_Private_Entity (Act_Pkg)
                   loop
                      --  ???  Are the following calls also needed here:
                      --
index cf1cc2f502538f5d6492a900b3c11c22b9269b6a..5660b1555a4c9c6d791f200047c1cd80f83b0653 100644 (file)
@@ -1506,12 +1506,21 @@ package body Sem_Ch7 is
    ----------------------------------
 
    procedure Install_Visible_Declarations (P : Entity_Id) is
-      Id : Entity_Id;
+      Id          : Entity_Id;
+      Last_Entity : Entity_Id;
 
    begin
+      pragma Assert (Is_Package (P) or else Is_Record_Type (P));
+
+      if Is_Package (P) then
+         Last_Entity := First_Private_Entity (P);
+      else
+         Last_Entity := Empty;
+      end if;
+
       Id := First_Entity (P);
 
-      while Present (Id) and then Id /= First_Private_Entity (P) loop
+      while Present (Id) and then Id /= Last_Entity loop
          Install_Package_Entity (Id);
          Next_Entity (Id);
       end loop;