From patchwork Tue Jun 27 12:08:00 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: 113383 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp8144394vqr; Tue, 27 Jun 2023 05:09:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ64l9oobfKl9ogs1Z+Cl1J8kBe2a+QDAmh+oaXvmakzFCbBmEClcMg6uwYg7FwF43tFlq3O X-Received: by 2002:a17:907:805:b0:989:450:e57d with SMTP id wv5-20020a170907080500b009890450e57dmr18306432ejb.73.1687867788629; Tue, 27 Jun 2023 05:09:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687867788; cv=none; d=google.com; s=arc-20160816; b=JWOKCnwyRVzQ3eUVGGxMXjQJlxSy3RWM2EE3FlRo7kfV6kWkJ1+6b1ve8uMNWgCU+g T12nbR7TduKHgPPxWn/rqI9rUY45l+BITAsMyLoS+AyMRxxrWHNj4ld2EDDNDJ9umiQE /dNQCRud5/m1QP6lDbv/jLOwz0lIBQnlJUcZ6xbRZ/WQsjgTJLdqNUnqo10RNyu1nZsi 0oSOW6EE//6Q50HITSzaI5paqcebeLYVgjVVgKYZWSc8VhHhsyLh8wIz0BBSHEHLMZ9T IolhcIVPRuZnInZRuXxBnUl3k5+a1FrAEWqLIRH0Q5d6rVCvq1Po9Fm8rxs46S+CLLYp OYqA== 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=YmeuH6uYS5IynQ61iCI0L9KtqPfzQhRcED6szTzXVcE=; fh=hOhsC1930eHatDPYd2EALQ9Ry/g++vvN4vxlQkRuX+0=; b=odlOPMjkRkAWJkmVlXrE+UveYLQc5hYgskX/HdFO8qC+0iJTO0QWjojl+FER8QGWM7 lcDYWWi4omlvTMi0QSAL0ERW8Jm929FhN10wt+yRmtCQCRk/UZVTNTynDxTalKqrHKsn xOz602N5hkfJSBx4pKHNFSS6AeQdCJ/VFp922edfTmWF/hAM0a4jDwmRvJJhnD9HFU9s ueTaMillpEUaGElaEjtNt3E46TypqnYd6ZtzChBndRZm4fXNNAcTPqwZPXohAR5td3Zf e3m4MfxS1RQpr6vEbIbgJ7GWTxiANwhEABRFgY1qwaROPFozIU/NwMZWGZeZyJzCFbRa yraA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=FVunYG8Z; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id pv3-20020a170907208300b00987ab18f597si4409844ejb.814.2023.06.27.05.09.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 05:09:48 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=FVunYG8Z; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 173E63857838 for ; Tue, 27 Jun 2023 12:08:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 173E63857838 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687867733; bh=YmeuH6uYS5IynQ61iCI0L9KtqPfzQhRcED6szTzXVcE=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=FVunYG8Z9eU2Sb6l4KVxpxr6zr9RaeqFtU7yN8ij/Sd8MbWt6YYyES2km9t/uYYlW hjMRhwdvaIsOFA4onBHlbe6BVcu9CLTwXTnPTt1ZTRhI1V2CSUKDdnAEV3Fc3AEkm5 9t7wp6UNZtPyFSxut7RM5/1OcPqJq92U15spN34c= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id C3B8D3858D39 for ; Tue, 27 Jun 2023 12:08:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C3B8D3858D39 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-313f58d6652so1864209f8f.2 for ; Tue, 27 Jun 2023 05:08:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687867681; x=1690459681; 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=YmeuH6uYS5IynQ61iCI0L9KtqPfzQhRcED6szTzXVcE=; b=Ob1m6Hr7tgtFyp2cOTet2engUsclJ1AevzhebfueXUqyvixgAlGD+MYVtbxWMyzkHY VLgzin/hkHdZGOqvf9PCwi4KEku2FgFWxugo816tEoav+Pa714wLycaq92ONOf7BgtT4 JpXhE1/O5vGivzilo7lxBMuji1DGdL93oUKmiWhkM3k3u59AhnU5K1nPjRgHjoQ0iFyV MddL4v9UkP7Vo3k6rkQABrbRrKVkDh1Xkv3q0DNCT0Bt3gBZSaOXsWSZRHN94TgmFUBZ /2ybHBI9ibKrgGIYExRvujGMYzzQRWLrFLKhKfLVt0Qr3nkfOL9zgM1ES6KmtVNSZxYi rYaA== X-Gm-Message-State: AC+VfDwTs1+IciGQe9TeCozHuhf3fJVvODDOSE1Vnyvb+aDaTYGXWsl2 VBL2haVl+2u+tSPBdqoGAkLT2ZogwA7W5k3TP/D1aA== X-Received: by 2002:a5d:68ce:0:b0:314:21b:1ea4 with SMTP id p14-20020a5d68ce000000b00314021b1ea4mr869816wrw.12.1687867681390; Tue, 27 Jun 2023 05:08:01 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id a11-20020a056000050b00b003110dc7f408sm10375730wrf.41.2023.06.27.05.08.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 05:08:00 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Plug another loophole in the handling of private views in instances Date: Tue, 27 Jun 2023 14:08:00 +0200 Message-Id: <20230627120800.3419785-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?1769857654469327277?= X-GMAIL-MSGID: =?utf-8?q?1769857654469327277?= From: Eric Botcazou This deals with discriminants of types declared in package bodies. gcc/ada/ * sem_ch12.adb (Check_Private_View): Also check the type of visible discriminants in record and concurrent types. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch12.adb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index d5280cea712..fbfc2db7f9a 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -7710,6 +7710,9 @@ package body Sem_Ch12 is Prepend_Elmt (Typ, Exchanged_Views); Exchange_Declarations (Etype (Get_Associated_Node (N))); + -- Check that the available views of Typ match their respective flag. + -- Note that the type of a visible discriminant is never private. + else Check_Private_Type (Typ, Has_Private_View (N)); @@ -7720,6 +7723,20 @@ package body Sem_Ch12 is elsif Is_Array_Type (Typ) then Check_Private_Type (Component_Type (Typ), Has_Secondary_Private_View (N)); + + elsif (Is_Record_Type (Typ) or else Is_Concurrent_Type (Typ)) + and then Has_Discriminants (Typ) + then + declare + Disc : Entity_Id; + + begin + Disc := First_Discriminant (Typ); + while Present (Disc) loop + Check_Private_Type (Etype (Disc), False); + Next_Discriminant (Disc); + end loop; + end; end if; end if; end if;