From patchwork Tue Jun 20 07:47:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 110299 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp3495519vqr; Tue, 20 Jun 2023 00:51:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7QqeX23BL81wD6zFAs0FqEuBJ2mopGt8jNm0FalNA9Z2Lm71fCVqd2aE1nlgcFI+wqO5gE X-Received: by 2002:a17:906:6a0f:b0:988:686a:233 with SMTP id qw15-20020a1709066a0f00b00988686a0233mr6459663ejc.13.1687247512764; Tue, 20 Jun 2023 00:51:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687247512; cv=none; d=google.com; s=arc-20160816; b=jjWnAKznnpQpiCK54es50zn2TdR7n3FEBH1FGHKG0woPKT4kmkBweOxm4uZXmRueoa eeVtUej+cE40OrA6rMbEPwEjrVtSlcWIsUxUBg3k2k3SA+cy77iKEcIV6TSf9uTLBW9O J7t4HRnzqLrOAKVi0E5oLKYSsOUDKB3uvde6l+X5G0tYWuCmS+fMIaBOlxsAFfZmseYJ nkW2AyECi7kAdjPdVvp3B5loY5DovwrE+eyYDzT5IlI018DZ+1bfTztCvnYICTw1tgKF X1V2ZIXlR2jcbCmjPZEOwBtH6Kokai5caDNUi+dIp8X0Lv113v+OxzUft7OJBvygrZ8J rLzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=84oNHEIbU3pzRuWDW2cF4GYJMGBgieza48Z1k+gVi9M=; b=eKo3oBI0cVi7J12bacL/Ad8P7ZZGLGjHt+rM+qxm5qiLAyLmOWIOV/v8DQ9YnLPXIK aUmW8Gy5hRIUndpSE9n4xh76fTo03tzVGvsR/F1kddZA7Uhr0UTSUBw+25j6CjS2sC0J HY965wnrKIZoCcNVBGb6GWgPWOoSX1mVZorsMbJrvkj6eZ/Oc1IWTh9+dB9LDoSCHhX+ O+AikGZO9jdUtAMW5KJ7V3AR4F9JunVGuEu9+/KpUSgqJ6SPed+vV0SBJ02EqnwxEKA0 JMFscTwuP2xJ+1uaPPIRDwPmNFI8cOYOj8L6NDApcNyA2C0seS0enw8FtvDqw4VE6fp/ 3s9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=aunDHwOF; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id gh5-20020a170906e08500b00986a8116949si784770ejb.90.2023.06.20.00.51.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 00:51:52 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=aunDHwOF; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EA8B5382C106 for ; Tue, 20 Jun 2023 07:49:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EA8B5382C106 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687247344; bh=84oNHEIbU3pzRuWDW2cF4GYJMGBgieza48Z1k+gVi9M=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=aunDHwOFp/C17BF3YLls6AyvXZWmf8GUjdfOJhgo4SI6eru8nJLDG2PpRIVngiP+b HUuCBY/wANF+5K264LCvia5/K0P0ajbyYZ0fXxqqkYRE82xIWly+1KpNcbnFlHQ8+c TkKjd9Jv+lQrTS08VQpROIEByg3Zswp8MfeWn9QY= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by sourceware.org (Postfix) with ESMTPS id B9FED3857803 for ; Tue, 20 Jun 2023 07:47:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B9FED3857803 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-311153ec442so3320434f8f.1 for ; Tue, 20 Jun 2023 00:47:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687247224; x=1689839224; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=84oNHEIbU3pzRuWDW2cF4GYJMGBgieza48Z1k+gVi9M=; b=eNhor05qxn2+03pAxvuKH0GDbyreJJQauJ+Pli2gUYBSVMkY2Td8RiMl1CWlamATsr GI/xWolqMXutWU3gWhGY2iOpNawI9J0MPXKn4RDBUmqtvdFDpuXzw8zivYajA/P9th2O 4DECfQhWvK66qqR3xgChwuv6yyjv4QPvn+QFDVWIF4SqwPzrQXMch2enqcEyp5zYGT56 BAgGZOeLxTrFuOgrIUQodxf+PQouXwzfZK9+PDmGVeu/YZAd1Ctb6uYDOb1u3Ml52FEA 15ebkpeCaQ2ca9opvQJyUk5hG+W9G4Tw2FDiJP3kjGDonoYMA5s1RgquNWIDK7Pq8SjB F5GA== X-Gm-Message-State: AC+VfDySu1XL9f/tkdl8d/a/AH9kgBbScFlphJyV4eCIVbN3U3o+EZ5i Hkr51tJZzpFFxVdgB6vbJIqr3PUi5cRJgWkAFfki+g== X-Received: by 2002:adf:f1c5:0:b0:307:7959:6461 with SMTP id z5-20020adff1c5000000b0030779596461mr10647829wro.31.1687247224595; Tue, 20 Jun 2023 00:47:04 -0700 (PDT) Received: from poulhies-Precision-5550.lan ([2001:861:3382:1a90:4c16:36ea:1b76:c001]) by smtp.gmail.com with ESMTPSA id p7-20020a056000018700b003095bd71159sm1379313wrx.7.2023.06.20.00.47.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 00:47:03 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Fix fallout of fix to handling of private views in instances Date: Tue, 20 Jun 2023 09:47:03 +0200 Message-Id: <20230620074703.1252933-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769207248113617538?= X-GMAIL-MSGID: =?utf-8?q?1769207248113617538?= From: Eric Botcazou 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)