From patchwork Mon Sep 5 07:25:53 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: 964 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5044:0:0:0:0:0 with SMTP id h4csp56368wrt; Mon, 5 Sep 2022 00:27:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR61wStgCGPOr4Y9Ad+KBoxc7W48DC38+TjEi63Jd5m45QoBuUXHCAMNH/5bzutioEFdJvKK X-Received: by 2002:a17:906:99c1:b0:6fe:b01d:134 with SMTP id s1-20020a17090699c100b006feb01d0134mr34278432ejn.598.1662362854533; Mon, 05 Sep 2022 00:27:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662362854; cv=none; d=google.com; s=arc-20160816; b=WpbnRGe8Xb3EGfw/lkqKXC6QB4Egt4A1dvsBVMoQiFS9x+KINBMMKZ+mqYYcBZpnmn fHEpttoshQTEL+CjCzBrtTEb17FdiCFBygRP+O3NJFgEKxk+YieLpBWqdE8RcEFJxR1z Z/RT82EPPi1D1+yDnhix8KX/P7VeAk5BtwqTIMvwuEfsO96o4aYSpIS0C9SOYLejlXop 2qbxiymMkEypgWRWX+lI0W9x9P2u5x82ofmRpVDO9cPb84SaPPRRN6EqIehRKp6op1Ju bAcrKNo/NDwIwGQ9jFEGh7CMiCKp3pYwWeU2LZiYg17q/Zc0FcJpfiDJ8jSS4WsDv84h 8+cQ== 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=WFxOMjZK3/6R4kyQksM2iRU+J+CpOE5FmmWkkxvTr04=; b=EMWZiSXAFH2Ciywq23p+FN6R0mwuLcRWC31XOF1+7QYu99qdxR0WoJL8LcDMZvlHxg cIKQgy935MJaqvdwOXvk7qYMrrIMCkNlUQmxL2yjAlyM1OFHxQECI8lHx8uWsJ0Clrw2 LstC36CaFhId5La4UuSToDdd4pA4f+HOcpEpR7pmiRIrZ6IgftamMMSnug4T4ulVYenm NNmhCdX93yFWMUBYVKUL1ORUIAdOyjvaXUpkFT78CnV4ZssfC6xED4nwF9RPTa0VGyhg Z0MFVAZVurjm4Njs5IsPOCjfXPTvW7w85Xc6r046E91UvLpv/r8HdHdCybAmvSJGGdiH nqVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=VkE10eIZ; 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 dp22-20020a170906c15600b00731646a574esi5386902ejc.839.2022.09.05.00.27.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 00:27:34 -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=VkE10eIZ; 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 16AED38515F2 for ; Mon, 5 Sep 2022 07:26:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 16AED38515F2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1662362803; bh=WFxOMjZK3/6R4kyQksM2iRU+J+CpOE5FmmWkkxvTr04=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=VkE10eIZdYrdzEZQJPX6EYZPrsmsRl5H65ydt0AnRoF+nniV5LNbup3tUy3qaVwvv lYyktjjjSocc2vEWRa6Hhxneq3HVLltZs2g/XBBPElRyTpZhoB6HdGTDxoxJ17ssJ6 cVRvX5KfCIUhtDjK6a7L/wvv+WuhsF69fT6+Op/o= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 9DAC03858CDB for ; Mon, 5 Sep 2022 07:25:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9DAC03858CDB Received: by mail-wr1-x431.google.com with SMTP id w5so10048926wrn.12 for ; Mon, 05 Sep 2022 00:25:55 -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=WFxOMjZK3/6R4kyQksM2iRU+J+CpOE5FmmWkkxvTr04=; b=qXaToLBvNAGYbu9tvL6QAQEhz48IOmw+rK30//tBJS1QfNWVzsmWtasygMUssgXzmv b/buR2M8F47GbKgtOTcq77HSgq4DR8Lih4pn1geM9MOWlmGpBHaMXmxthPY/ten0PFI0 zucfETPpoopJ3vBY3b/q/gfao+JOABfqeXD0iPMiJZIRVzhSAtsm9ZlMBlLd/GwuEf+q Hh5Yt732RFJ6Gvxi4oqf/qU0krDR/FB4HOO4IHR0ZlDm2SE8ucOQ3rnTDt3SkB9NlfKK 82vcDMhBeSkGXBODP13Lqx3mEXSp6fthkG86KfsG3fjzazqFKM239kVyNZmdJnU/Zzlm /Nww== X-Gm-Message-State: ACgBeo2ZsAp7BMUGEM+Tq7y+aoKYAwUTbCne553M/gDs0I6APwKUCetm CGnjbqRgnnikIwDJu8ZnmbkLKemZooCQDg== X-Received: by 2002:adf:fa83:0:b0:205:c0cb:33c6 with SMTP id h3-20020adffa83000000b00205c0cb33c6mr5323876wrr.39.1662362754523; Mon, 05 Sep 2022 00:25:54 -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 n30-20020a05600c501e00b003a61306d79dsm11648636wmr.41.2022.09.05.00.25.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 00:25:54 -0700 (PDT) Date: Mon, 5 Sep 2022 09:25:53 +0200 To: gcc-patches@gcc.gnu.org Subject: [Ada] Cleanup expansion of attribute Priority Message-ID: <20220905072553.GA1174527@poulhies-Precision-5550> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-12.2 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?1743113792845616462?= X-GMAIL-MSGID: =?utf-8?q?1743113792845616462?= Semantically neutral cleanup after the main fix for expansion of attribute Priority. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * einfo-utils.adb (Number_Entries): Refine type of a local variable. * exp_attr.adb (Expand_N_Attribute_Reference): Rename Conctyp to Prottyp; refactor repeated calls to New_Occurrence_Of; replace Number_Entries with Has_Entries. * exp_ch5.adb (Expand_N_Assignment_Statement): Likewise; remove Subprg variable (apparently copy-pasted from expansion of the attribute). diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb --- a/gcc/ada/einfo-utils.adb +++ b/gcc/ada/einfo-utils.adb @@ -2081,7 +2081,7 @@ package body Einfo.Utils is -------------------- function Number_Entries (Id : E) return Nat is - N : Int; + N : Nat; Ent : Entity_Id; begin diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -5667,22 +5667,22 @@ package body Exp_Attr is -- which is illegal, because of the lack of aliasing. when Attribute_Priority => Priority : declare - Call : Node_Id; - Conctyp : Entity_Id; - New_Itype : Entity_Id; - Object_Parm : Node_Id; - Subprg : Entity_Id; - RT_Subprg_Name : Node_Id; + Call : Node_Id; + New_Itype : Entity_Id; + Object_Parm : Node_Id; + Prottyp : Entity_Id; + RT_Subprg : RE_Id; + Subprg : Entity_Id; begin -- Look for the enclosing protected type - Conctyp := Current_Scope; - while not Is_Protected_Type (Conctyp) loop - Conctyp := Scope (Conctyp); + Prottyp := Current_Scope; + while not Is_Protected_Type (Prottyp) loop + Prottyp := Scope (Prottyp); end loop; - pragma Assert (Is_Protected_Type (Conctyp)); + pragma Assert (Is_Protected_Type (Prottyp)); -- Generate the actual of the call @@ -5710,7 +5710,7 @@ package body Exp_Attr is New_Itype := Create_Itype (E_Access_Type, N); Set_Etype (New_Itype, New_Itype); Set_Directly_Designated_Type (New_Itype, - Corresponding_Record_Type (Conctyp)); + Corresponding_Record_Type (Prottyp)); Freeze_Itype (New_Itype, N); -- Generate: @@ -5745,15 +5745,16 @@ package body Exp_Attr is -- Select the appropriate run-time subprogram - if Number_Entries (Conctyp) = 0 then - RT_Subprg_Name := New_Occurrence_Of (RTE (RE_Get_Ceiling), Loc); + if Has_Entries (Prottyp) then + RT_Subprg := RO_PE_Get_Ceiling; else - RT_Subprg_Name := New_Occurrence_Of (RTE (RO_PE_Get_Ceiling), Loc); + RT_Subprg := RE_Get_Ceiling; end if; Call := Make_Function_Call (Loc, - Name => RT_Subprg_Name, + Name => + New_Occurrence_Of (RTE (RT_Subprg), Loc), Parameter_Associations => New_List (Object_Parm)); Rewrite (N, Call); diff --git a/gcc/ada/exp_ch5.adb b/gcc/ada/exp_ch5.adb --- a/gcc/ada/exp_ch5.adb +++ b/gcc/ada/exp_ch5.adb @@ -2392,11 +2392,10 @@ package body Exp_Ch5 is if Ada_Version >= Ada_2005 then declare - Call : Node_Id; - Conctyp : Entity_Id; - Ent : Entity_Id; - Subprg : Entity_Id; - RT_Subprg_Name : Node_Id; + Call : Node_Id; + Ent : Entity_Id; + Prottyp : Entity_Id; + RT_Subprg : RE_Id; begin -- Handle chains of renamings @@ -2418,36 +2417,25 @@ package body Exp_Ch5 is -- Look for the enclosing protected type - Conctyp := Current_Scope; - while not Is_Protected_Type (Conctyp) loop - Conctyp := Scope (Conctyp); + Prottyp := Current_Scope; + while not Is_Protected_Type (Prottyp) loop + Prottyp := Scope (Prottyp); end loop; - pragma Assert (Is_Protected_Type (Conctyp)); - - -- Generate the first actual of the call - - Subprg := Current_Scope; - while - not (Is_Subprogram_Or_Entry (Subprg) - and then Present (Protected_Body_Subprogram (Subprg))) - loop - Subprg := Scope (Subprg); - end loop; + pragma Assert (Is_Protected_Type (Prottyp)); -- Select the appropriate run-time call - if Number_Entries (Conctyp) = 0 then - RT_Subprg_Name := - New_Occurrence_Of (RTE (RE_Set_Ceiling), Loc); + if Has_Entries (Prottyp) then + RT_Subprg := RO_PE_Set_Ceiling; else - RT_Subprg_Name := - New_Occurrence_Of (RTE (RO_PE_Set_Ceiling), Loc); + RT_Subprg := RE_Set_Ceiling; end if; Call := Make_Procedure_Call_Statement (Loc, - Name => RT_Subprg_Name, + Name => + New_Occurrence_Of (RTE (RT_Subprg), Loc), Parameter_Associations => New_List ( New_Copy_Tree (First (Parameter_Associations (Ent))), Relocate_Node (Expression (N))));