From patchwork Tue Sep 6 07:15:58 2022 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: 1027 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp507088wrt; Tue, 6 Sep 2022 00:30:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR4uPtaHnmhOJaYKMo46Px0dkZfFSNy/6gSrkEZ1YEdzpmdXGqjNf1OdXvLZFy/ZYC7MMUtC X-Received: by 2002:a17:907:7b8e:b0:741:5903:9307 with SMTP id ne14-20020a1709077b8e00b0074159039307mr31356673ejc.201.1662449426933; Tue, 06 Sep 2022 00:30:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662449426; cv=none; d=google.com; s=arc-20160816; b=LAspxB1iyytYKPhH+uuQuDNpXHRPoghmLpgR66Qatd1acfGmOG2F3CA6s+4fWLjSEl BkE1gMC0xIEWaLeLZ/4MjbXNL9JiEkyEVBSCL1aJhJIBLo405+F/sytMH0gz++yRHQDV U1Yjj2ux60Gl9fRgAyLAodyKWLZesk5HbjucNyiSl3916zj6177UKZxmU9HAP5gE1Oh9 GedVcbn81kG9YOUQbXX+wzIOim6GK8jVuAuFto88ybn4wwJCa6sg3hcBY6EAI6EdeeJv Z0BD1CGYQaZIYu61dn4u3UBRlgJYxEvukuBR/DFwwjQJ02jhB8mHO5offv9MkhKPYrMa x3Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=1i9wS1t898K6GKjC3RN64B4mCD73Az99IVhWFDVUDXs=; b=L319CKE7oq3MPG+2n6Ka9NJ1+Nn7oChasJ64mO0psV3s+eWejU4F4cTNjJBF5Nztf/ 6SYTD+fwxIzF1SjxsqeORdy47STUQ4jKNjcLKFUA5Dvc9SneIXAWDX5eD/hNXdfjhPQ3 rFX/TcagwFSEnZToCsYWcusxhWR92nb6ptTHNflgsENWg7DSdfYtjXVRjLatg66tldya 57zabBdhp6Y8fIp/AKyRhGQ0m7mE0wPkc7mS17hqhI1tV0b4vckxcZANiajIZm/60ma3 9HvyDu7r6bwHCRVd8hyRwgzVvqdnWU5/0CRvLbg8G0cKivVHMGrnKFmLROTmobIH++uv tEDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=pO7aUUj4; 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id eb8-20020a0564020d0800b0043e1c8af8c8si1047618edb.241.2022.09.06.00.30.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 00:30:26 -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=pO7aUUj4; 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 ED99D3948A6B for ; Tue, 6 Sep 2022 07:23:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ED99D3948A6B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662449011; bh=1i9wS1t898K6GKjC3RN64B4mCD73Az99IVhWFDVUDXs=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=pO7aUUj4WfFVs6H22foRHzXwTX6CpL8y9DEnwbUIXLjlCD5NhZixUn2EgcGyGUvaE iLQ4WY6YYip0FOHcUsbeLaIp4DpiJ2fddRPB5nUWGXIXJuBJQiZIwb0J24JmAuajTd LPjBl+jGp2U3Znsy6f/at54RMIV6JKz1F63tov5E= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by sourceware.org (Postfix) with ESMTPS id 125E93851150 for ; Tue, 6 Sep 2022 07:16:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 125E93851150 Received: by mail-wr1-x42c.google.com with SMTP id e20so13983675wri.13 for ; Tue, 06 Sep 2022 00:16:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date; bh=1i9wS1t898K6GKjC3RN64B4mCD73Az99IVhWFDVUDXs=; b=pdNqPqFCxXdHUEShoRIg1UdTPNOAM2++cN0c6rNXd/DpoEfJC8fgpYZftvf+te5i5L q9v1QKMg8nxI4J/840MxLNnoAi6vbtM4/aMpSUAvP/on58t3iOSLsCnDiGT+YlyMXp2c MbegCF+SRi9d2xLuB5PaG+lJWUudAk+ykGZAceLwsRrWYybwQFaKTElV22RWH0IjqKSq ZsHxGEtTZ1T2jssigfL4jFQde3Z0iWHvWfoLcegxFe1d2lFT0zoMng8mfxT0+V3h7ZdZ ivJ//JBOykqU1xH7vE/HiY54jEJhiziCH6yQu31jpvgUD6V55rKVfiPI1qRfRWA+ekhk iUVQ== X-Gm-Message-State: ACgBeo0VIT206JULgqXbTzXdj2kBFiFKNsdwDR2TYc3QTJA6Yc45uTkC HyyhqFLey+Nny5hqMQoJ6pL2kzexKlkq9w== X-Received: by 2002:a5d:550e:0:b0:228:da13:952c with SMTP id b14-20020a5d550e000000b00228da13952cmr754939wrv.694.1662448558970; Tue, 06 Sep 2022 00:15:58 -0700 (PDT) Received: from poulhies-Precision-5550 (static-176-191-105-132.ftth.abo.bbox.fr. [176.191.105.132]) by smtp.gmail.com with ESMTPSA id m18-20020adff392000000b00228b3ff1f5dsm4908334wro.117.2022.09.06.00.15.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Sep 2022 00:15:58 -0700 (PDT) Date: Tue, 6 Sep 2022 09:15:58 +0200 To: gcc-patches@gcc.gnu.org Subject: [Ada] Retain Has_Private_View flag for actuals of inlined subprograms Message-ID: <20220906071558.GA1280468@poulhies-Precision-5550> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.0 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: Marc =?iso-8859-1?q?Poulhi=E8s?= Cc: Piotr Trojanek 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?1743204570061633157?= X-GMAIL-MSGID: =?utf-8?q?1743204570061633157?= When instantiating a body to inline (either because frontend inlining is enabled with switch -gnatN or because of inlining-for-proof in GNATprove mode) we rewrite occurrences of formal parameters into the corresponding actual parameters. Then we switch type views, so that if the formal had a full view in the body to inline then the corresponding actual will have a full view in the particular inlined body. However, when rewriting occurrences of the formal parameter we were losing information about whether the formal had a private view. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * inline.adb (Process_Formals): Preserve Has_Private_View flag while rewriting formal into actual parameters. diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb --- a/gcc/ada/inline.adb +++ b/gcc/ada/inline.adb @@ -3367,6 +3367,8 @@ package body Inline is E : Entity_Id; Ret : Node_Id; + Had_Private_View : Boolean; + begin if Is_Entity_Name (N) and then Present (Entity (N)) then E := Entity (N); @@ -3380,13 +3382,21 @@ package body Inline is -- subtype is private at the call point but its full view is -- visible to the body, then the inlined tree here must be -- analyzed with the full view). + -- + -- The Has_Private_View flag is cleared by rewriting, so it + -- must be explicitly saved and restored, just like when + -- instantiating the body to inline. if Is_Entity_Name (A) then + Had_Private_View := Has_Private_View (N); Rewrite (N, New_Occurrence_Of (Entity (A), Sloc (N))); + Set_Has_Private_View (N, Had_Private_View); Check_Private_View (N); elsif Nkind (A) = N_Defining_Identifier then + Had_Private_View := Has_Private_View (N); Rewrite (N, New_Occurrence_Of (A, Sloc (N))); + Set_Has_Private_View (N, Had_Private_View); Check_Private_View (N); -- Numeric literal