From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7871) id 0AB5A385842C; Tue, 20 Jun 2023 07:46:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0AB5A385842C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687247202; bh=nf0v/Lj91pjs+HrRT3OLJVHl6AkcKz/nkEKR0AcoDOU=; h=From:To:Subject:Date:From; b=shUo2Jh6cxr8pnXfnFjXGLyai9PyKjSfgKWNEv2ZoJ7ZNysbFU7Hh9ycvDgay+x2/ jAI55neZehDgIikOkoYDPruz64lNHIRs2z+WXpuV9i0Fq9NFuDz9ENo895gBIzFfB9 HQvQhhW59oECeapx9QlGrt+swOjFoK7GEIJDvsPI= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Marc Poulhi?s To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-1971] ada: Fix fallout of fix to handling of private views in instances X-Act-Checkin: gcc X-Git-Author: Eric Botcazou X-Git-Refname: refs/heads/master X-Git-Oldrev: b9b1dcc841436964d344befe38ef66c5ee68913d X-Git-Newrev: d39664b659f2442a456be865ee6adcfe1a4a5aed Message-Id: <20230620074642.0AB5A385842C@sourceware.org> Date: Tue, 20 Jun 2023 07:46:42 +0000 (GMT) List-Id: https://gcc.gnu.org/g:d39664b659f2442a456be865ee6adcfe1a4a5aed commit r14-1971-gd39664b659f2442a456be865ee6adcfe1a4a5aed Author: Eric Botcazou Date: Wed May 31 14:32:59 2023 +0200 ada: Fix fallout of fix to handling of private views in instances 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. Diff: --- 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)