From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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-x431.google.com with SMTP id w5so10048926wrn.12 for ; Mon, 05 Sep 2022 00:25:55 -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=WFxOMjZK3/6R4kyQksM2iRU+J+CpOE5FmmWkkxvTr04=; b=Pa0GZlKQg3PM+Y1zBzMW4XLUtUPaNZb4ahHhk8smQSRJuJQKzS2pN2zoNRSbenRG1/ V9a6hRR2n8M+adiMek38yjzNidd0y++Wb/pqa8yHrMLB1yH1/UKro22h7M4LXfQm0skE n5Z/nnZvtqtukRk12TXKhu6oAQSKsvRp2tYlfALe93BOSMTO8q4J843RfWL9oDdXK6fS axfX7ta8kVQQKuvj7G6ztZ+T0agNq1PEsCLovPdWU69QKrEsadBYlAi7aEFVMP4lqQr4 +TXLUou9Br9ZMClPjbZq0eUTEJTQTccO4UQo+WpvUDSgx3E0hL8nVvKduFUle0vMsxrs uxHw== 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-Google-Smtp-Source: AA6agR4yGqZgopw8AesIodgz6NgItA9WdzNI+eRhwf7BZuDdNAVJkyA/LFrqwyNcjUHfsSGrYdMvlA== 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 From: Marc =?iso-8859-1?Q?Poulhi=E8s?= To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [Ada] Cleanup expansion of attribute Priority Message-ID: <20220905072553.GA1174527@poulhies-Precision-5550> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="k1lZvvs/B4yU6o8G" 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 List-Id: --k1lZvvs/B4yU6o8G Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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). --k1lZvvs/B4yU6o8G Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="patch.diff" 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)))); --k1lZvvs/B4yU6o8G--