]> gcc.gnu.org Git - gcc.git/commitdiff
ada: Fix fallout of fix to handling of private views in instances
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 31 May 2023 12:32:59 +0000 (14:32 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 20 Jun 2023 07:30:49 +0000 (09:30 +0200)
Check_Actual_Type incorrectly switches the view of a private type declared
in the enclosing scope of a generic unit but that has a private ancestor.

gcc/ada/

* einfo.ads (Has_Private_Ancestor): Fix inaccuracy in description.
* sem_ch12.adb (Check_Actual_Type): Do not switch the view of the
type if it has a private ancestor.

gcc/ada/einfo.ads
gcc/ada/sem_ch12.adb

index a861ff787a4bcb3011c5b6bcf6234031a8d95d6d..b356b76f0de697798cceb16aee31bb00431b80bd 100644 (file)
@@ -1969,7 +1969,7 @@ package Einfo is
 --       is defined for the type.
 
 --    Has_Private_Ancestor
---       Applies to type extensions. True if some ancestor is derived from a
+--       Applies to derived record types. True if an ancestor is derived from a
 --       private type, making some components invisible and aggregates illegal.
 --       This flag is set at the point of derivation. The legality of the
 --       aggregate must be rechecked because it also depends on the visibility
index a65bd0fdfb53a545bd8fff68d2370fd5fb264a64..a8e7c909c394ade6e370a504993e7ca84e6d1bdb 100644 (file)
@@ -6980,7 +6980,8 @@ package body Sem_Ch12 is
 
       procedure Check_Actual_Type (Typ : Entity_Id);
       --  If the type of the actual is a private type declared in the
-      --  enclosing scope of the generic unit, the body of the generic
+      --  enclosing scope of the generic unit, but not a derived type
+      --  of a private type declared elsewhere, the body of the generic
       --  sees the full view of the type (because it has to appear in
       --  the corresponding package body). If the type is private now,
       --  exchange views to restore the proper visibility in the instance.
@@ -6999,6 +7000,7 @@ package body Sem_Ch12 is
 
          if Is_Private_Type (Btyp)
            and then Scope (Btyp) = Parent_Scope
+           and then not Has_Private_Ancestor (Btyp)
            and then Ekind (Parent_Scope) in E_Package | E_Generic_Package
            and then Scope (Instance) /= Parent_Scope
            and then not Is_Child_Unit (Gen_Id)
This page took 0.083531 seconds and 5 git commands to generate.