public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [COMMITTED] ada: Fix fallout of fix to handling of private views in instances
@ 2023-06-20  7:47 Marc Poulhiès
  0 siblings, 0 replies; only message in thread
From: Marc Poulhiès @ 2023-06-20  7:47 UTC (permalink / raw)
  To: gcc-patches; +Cc: Eric Botcazou

From: Eric Botcazou <ebotcazou@adacore.com>

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.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/einfo.ads    | 2 +-
 gcc/ada/sem_ch12.adb | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads
index a861ff787a4..b356b76f0de 100644
--- a/gcc/ada/einfo.ads
+++ b/gcc/ada/einfo.ads
@@ -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
diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb
index a65bd0fdfb5..a8e7c909c39 100644
--- a/gcc/ada/sem_ch12.adb
+++ b/gcc/ada/sem_ch12.adb
@@ -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)
-- 
2.40.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-20  7:47 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-20  7:47 [COMMITTED] ada: Fix fallout of fix to handling of private views in instances Marc Poulhiès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).