From patchwork Mon Sep 12 08:19:20 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: 1142 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp1780345wrt; Mon, 12 Sep 2022 01:25:52 -0700 (PDT) X-Google-Smtp-Source: AA6agR7YUtj7IAqy9EbHuko9fwnHhVRFKWY9kWBl4owLZ4s4fAHPplA5FcHgyZYnCEOmiW/T5GDn X-Received: by 2002:a17:907:a051:b0:77a:e136:6ad2 with SMTP id gz17-20020a170907a05100b0077ae1366ad2mr7219604ejc.764.1662971151835; Mon, 12 Sep 2022 01:25:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662971151; cv=none; d=google.com; s=arc-20160816; b=BhOLjY0VOgQNFAoeK4xfzXBJTMLGUC0GswoN2SxUgZlkM9MAgJlgJ8drCrd9CRjA4U xX+9CzL63S1D2SLF0jvXwi30KqAVpFPSr592MQFN0vdPn6YAh2eYE2mRcia/+JUcaOLr DpIxQK6mVA1zbJE8ojqptWCeqf2LEPYlmaaQiGAJzv1uIz2sbtKIbLay8ab2i8uYBzuf +34iLXCHmfBNX2aWJtb8il8u+Eyb/1dg9lCCsnNJ2nkCRbnnKkPhwPbpGHyz2auYZc0Q NVs3u60TGS7OTc5pwUnRzAGVYB10FcumAEdKXVWXRAw1OPVp1JPP65tydrLOGrvSUCZK 0tbQ== 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=xq7otcVa4s6Fl9y4OrLy1IUvbRDuZI7UgSK6xY0mRgU=; b=sHAPkcGS2NquXQnVemz/ZQCx2iqaFSN+p28E+Cfc7h1e+b4+HX8qVmi3yKkICMEOIK 9Ihxve+dUAC464KLdLLrYbCKa8gKNOx7LKFmkKTxpLymj+eA0yTFIYyVqsQz6xbNYV94 74I9wF5W8/DRrKcY8dEE6vJJwUBqZO/Q5o88Z4Ttva2UNGjP4y0p6Tu8JaMbl5kvKZiC 4DiZD6yrpjQQ7aT7Q49TbQ4xz1+FErhYoCGmf2jcQLhy8zTvX6DjojDq6YK1XgM0cQmN o3DyFcRe9iDLVVZZYw2P93dnl7YTY4zf6A+YAKcOex9GXF8Cr6ZmOC2QTYE3dHLfm8aG hJ2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=gpyIZa7b; 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 gn26-20020a1709070d1a00b0077eb65c41e5si822672ejc.22.2022.09.12.01.25.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 01:25:51 -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=gpyIZa7b; 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 A12C0394B01A for ; Mon, 12 Sep 2022 08:22:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A12C0394B01A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662970939; bh=xq7otcVa4s6Fl9y4OrLy1IUvbRDuZI7UgSK6xY0mRgU=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=gpyIZa7bJA5vPJMBRjBwG50IPNaZY/iJQsCvOtLsqSZRKMTiXNr45exzLRff04+Ri TXBs2aJoQWTqkizuu4Ufz3S6EXq5irSevpZmshxCGzv61N4KCq87RU88MhbFdaWfb5 GJTBS18QRoXl491XMmtysJCja8ZW7tZ+gghQEwtI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by sourceware.org (Postfix) with ESMTPS id 181F03856970 for ; Mon, 12 Sep 2022 08:19:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 181F03856970 Received: by mail-wm1-x332.google.com with SMTP id n17-20020a05600c501100b003a84bf9b68bso6650239wmr.3 for ; Mon, 12 Sep 2022 01:19:23 -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=xq7otcVa4s6Fl9y4OrLy1IUvbRDuZI7UgSK6xY0mRgU=; b=rUNhzBojDsv/CqX3OMLYaPC5ywhHruUWn6MU4md6a9G0VYPtqzim6RjHHlTRsG0/CM SKu4cXZHk6bLh/x/pm2Kn2bYz09r5QdeehoZNYU5KX6IaoAgaMaW3i/OM1ImfzMQQ6cu EyEIR+B+MuQWBfIJrbCY654AnSug6p11sQ7ZIeaNu3hsV1DlNwubXAxa5wSFPg8SdPGC 7+myU1T/rcsF3UXKXtY1cBHexgKCD6T6UBOCI/Ol4lXlWWLafBA/6PTOF9dizZrO6N3p PPr4fzBgfM9RbWXI45DQ7daLX/uV72LLTAgBnqrbJDMfN7wW59zLmZKdZ+/N5sfFfIkf +9hQ== X-Gm-Message-State: ACgBeo0H86Sq0X/gqPkSXSX7Gr97WwcIcMcBPeOya3Yg4OnivsZRY1DZ PeCbMWB2UtWGJ3214MdIXOFnFiTqO8dV/Q== X-Received: by 2002:a05:600c:3b92:b0:3a6:8d6:9a2f with SMTP id n18-20020a05600c3b9200b003a608d69a2fmr13280002wms.159.1662970761913; Mon, 12 Sep 2022 01:19:21 -0700 (PDT) Received: from poulhies-Precision-5550 (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id j13-20020adff54d000000b00229d55994e0sm6480612wrp.59.2022.09.12.01.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 01:19:21 -0700 (PDT) Date: Mon, 12 Sep 2022 10:19:20 +0200 To: gcc-patches@gcc.gnu.org Subject: [Ada] Do not mark user parameters of protected subprograms as artificial Message-ID: <20220912081920.GA1512860@poulhies-Precision-5550> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-12.5 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: Eric Botcazou 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?1743751638104469017?= X-GMAIL-MSGID: =?utf-8?q?1743751638104469017?= This occurs because protected subprograms are not translated directly into object code but first rewritten as a pair of subprograms by the front-end. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch9.adb (Build_Protected_Spec): Tidy up and propagate the Comes_From_Source flag onto the new formal parameters. * sem_ch6.adb (Analyze_Subprogram_Body_Helper): Do not check references for subprograms generated for protected subprograms. diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb --- a/gcc/ada/exp_ch9.adb +++ b/gcc/ada/exp_ch9.adb @@ -3868,32 +3868,35 @@ package body Exp_Ch9 is Ident : Entity_Id; Unprotected : Boolean := False) return List_Id is - Loc : constant Source_Ptr := Sloc (N); - Decl : Node_Id; - Formal : Entity_Id; - New_Plist : List_Id; - New_Param : Node_Id; + Loc : constant Source_Ptr := Sloc (N); + + Decl : Node_Id; + Formal : Entity_Id; + New_Formal : Entity_Id; + New_Plist : List_Id; begin New_Plist := New_List; Formal := First_Formal (Ident); while Present (Formal) loop - New_Param := + New_Formal := + Make_Defining_Identifier (Sloc (Formal), Chars (Formal)); + Set_Comes_From_Source (New_Formal, Comes_From_Source (Formal)); + + if Unprotected then + Mutate_Ekind (New_Formal, Ekind (Formal)); + Set_Protected_Formal (Formal, New_Formal); + end if; + + Append_To (New_Plist, Make_Parameter_Specification (Loc, - Defining_Identifier => - Make_Defining_Identifier (Sloc (Formal), Chars (Formal)), + Defining_Identifier => New_Formal, Aliased_Present => Aliased_Present (Parent (Formal)), In_Present => In_Present (Parent (Formal)), Out_Present => Out_Present (Parent (Formal)), - Parameter_Type => New_Occurrence_Of (Etype (Formal), Loc)); - - if Unprotected then - Set_Protected_Formal (Formal, Defining_Identifier (New_Param)); - Mutate_Ekind (Defining_Identifier (New_Param), Ekind (Formal)); - end if; + Parameter_Type => New_Occurrence_Of (Etype (Formal), Loc))); - Append (New_Param, New_Plist); Next_Formal (Formal); end loop; diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -5511,12 +5511,22 @@ package body Sem_Ch6 is -- Check references of the subprogram spec when we are dealing with -- an expression function due to it having a generated body. - -- Otherwise, we simply check the formals of the subprogram body. if Present (Spec_Id) and then Is_Expression_Function (Spec_Id) then Check_References (Spec_Id); + + -- Skip the check for subprograms generated for protected subprograms + -- because it is also done for the protected subprograms themselves. + + elsif Present (Spec_Id) + and then Present (Protected_Subprogram (Spec_Id)) + then + null; + + -- Otherwise, we simply check the formals of the subprogram body. + else Check_References (Body_Id); end if;