From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-wr1-x42c.google.com with SMTP id e20so13983675wri.13 for ; Tue, 06 Sep 2022 00:16:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date; bh=1i9wS1t898K6GKjC3RN64B4mCD73Az99IVhWFDVUDXs=; b=SyWqPFAQl8+0smmqSXViz3+TmBPC1Hzl12vVIivZspcg72hakvXWGJtzdp3DySZCV5 7P7KozJ4iM1RemOM6q6ysTUdCH6WDiVIwEI0WUcM58T8edZCbdJvJLedm2dobUNgA81Z P1py5IwIlCGJw2h3D5b48kVzgulWUXtghWSm+NNTA8ZmhzhzHa2AFMgZabDFVGc5r8jy NDgnUp8AehkYx4cMI79M4JEv1gfDHM4gyTxyyqrdiBP8U7jpR5Z9C2QIy3x4n7yLtLeB mhrRybj4GLOa5P+d3Spx517d35pMLepOdyJF2HbL3XLu/tK3mMOX6S9MikallIXhoq20 mCEg== 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-Google-Smtp-Source: AA6agR6W5RR/4pXQcv31ymF8PiV9HviXmt/KSB6VswMOigXGxnWvD9xCOfCeUQJp4ux+zG6JvFHnCg== 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 From: Marc =?iso-8859-1?Q?Poulhi=E8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [Ada] Retain Has_Private_View flag for actuals of inlined subprograms Message-ID: <20220906071558.GA1280468@poulhies-Precision-5550> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="5vNYLRcllDrimb99" 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 List-Id: --5vNYLRcllDrimb99 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. --5vNYLRcllDrimb99 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" 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 --5vNYLRcllDrimb99--