From patchwork Thu Dec 2 16:28:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 48411 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0C6733857825 for ; Thu, 2 Dec 2021 16:49:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0C6733857825 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1638463760; bh=QkDTRNe1ODrQiDOakgJTimlgf1FhstHZ6C/kZVdcX+k=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=E4Ch96JgzixmIRDLJhtYI3hi58aAqpYSJnXYJb/G1o44zUxPaxZ1A1cmDKNVorlxf LaiB0F7djUrmhPz2lG8xPtXBzK7P91MggxqKze6ZPwPFL2tyAqa93wB524kKIQGqpp Yia6dzwSRbML+E7TcMgGl1AonnAtUf4LkzjAoNGY= 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 778F0385AC36 for ; Thu, 2 Dec 2021 16:29:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 778F0385AC36 Received: by mail-wr1-x431.google.com with SMTP id j3so60842841wrp.1 for ; Thu, 02 Dec 2021 08:29:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=QkDTRNe1ODrQiDOakgJTimlgf1FhstHZ6C/kZVdcX+k=; b=4AmY4rN0GzviITaxVn+rYW0QPaH/cAKw4UpSlmtpk4vb6c9aaHJI3TyCFV0EPZTthh zZtRXExQmV+tOpIqWWh8FMrSOpnOslUPBovv1c1jh4sCQg4iFpCclY2gwd4hODZCnPZa a9P/3/rFAdC+QNi1vfz9tFx2p1xCMlxb/T3LW8OJt4rZJ3zjUCZgrBxFs1hp7FjV27uQ 3bBeEVWAJ+HDNUegmaDf0DeeA0cwVbbIuLzS6aovZTc5kCtQA6YEkZYhBgwGmKb8Gm/r yWY9qFOyp5bHOwhiLIdpLrI6cMbFuTfDTdaEQX5AuL3VuhtYAHVMPCBRit3DDu++wiV/ NaCQ== X-Gm-Message-State: AOAM531PuUFwbzys9Ma3oV1pUG9tREl2M596b4tslWInxrbJJiprLf1U pluZhjJRtI3sLCAPivlEcaGuQ+vnBV0KIA== X-Google-Smtp-Source: ABdhPJwTlpm2JJuCqgeYgumJBB/dQvPd4q92iDOk46+EExaVT3IDHZVSwtB3BV5PszoGIBdXBf7hpA== X-Received: by 2002:adf:e38d:: with SMTP id e13mr14750190wrm.402.1638462541576; Thu, 02 Dec 2021 08:29:01 -0800 (PST) Received: from adacore.com ([45.147.211.82]) by smtp.gmail.com with ESMTPSA id m7sm118613wml.38.2021.12.02.08.29.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Dec 2021 08:29:00 -0800 (PST) Date: Thu, 2 Dec 2021 16:28:59 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Cleanup insertion of single freezing actions Message-ID: <20211202162859.GA2159614@adacore.com> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-13.1 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 autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Pierre-Marie de Rodat via Gcc-patches From: Pierre-Marie de Rodat Reply-To: Pierre-Marie de Rodat Cc: Piotr Trojanek Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Replace calls to Ensure_Freeze_Node & Append_Freeze_Actions (plural) with a simple call to Append_Freeze_Action (singular), which calls Ensure_Freeze_Node itself. Cleanup related to expansion of dispatching primitives for GNATprove; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_util.adb (Append_Freeze_Action): Tune whitespace to make the code look similar to Append_Freeze_Actions, which takes a List_Id. * sem_ch6.adb (Analyze_Return_Type): Cleanup with Append_Freeze_Action. * exp_ch3.adb (Build_Access_Subprogram_Wrapper_Body): Likewise. * sem_ch3.adb (Build_Access_Subprogram_Wrapper): Likewise. * contracts.adb (Add_Indirect_Call_Wrapper): Remove extra call to Ensure_Freeze_Node. (Add_Call_Helper): Likewise. * freeze.adb (Check_Inherited_Conditions): Likewise. (Attribute_Renaming): Likewise. * sem_ch8.adb: Likewise. diff --git a/gcc/ada/contracts.adb b/gcc/ada/contracts.adb --- a/gcc/ada/contracts.adb +++ b/gcc/ada/contracts.adb @@ -3761,7 +3761,6 @@ package body Contracts is ICW_Decl := Build_ICW_Decl; - Ensure_Freeze_Node (Tagged_Type); Append_Freeze_Action (Tagged_Type, ICW_Decl); Analyze (ICW_Decl); @@ -4034,7 +4033,6 @@ package body Contracts is -- Add the helper to the freezing actions of the tagged type - Ensure_Freeze_Node (Tagged_Type); Append_Freeze_Action (Tagged_Type, Helper_Decl); Analyze (Helper_Decl); diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb --- a/gcc/ada/exp_ch3.adb +++ b/gcc/ada/exp_ch3.adb @@ -580,8 +580,7 @@ package body Exp_Ch3 is -- Place body in list of freeze actions for the type. - Ensure_Freeze_Node (Type_Id); - Append_Freeze_Actions (Type_Id, New_List (Body_Node)); + Append_Freeze_Action (Type_Id, Body_Node); end Build_Access_Subprogram_Wrapper_Body; --------------------------- diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -458,7 +458,6 @@ package body Exp_Util is else Append (N, Actions (Fnode)); end if; - end Append_Freeze_Action; --------------------------- diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -2044,9 +2044,8 @@ package body Freeze is -- node of the record type declaration to ensure that it will -- override the internal primitive built by Derive_Subprogram. - Ensure_Freeze_Node (R); - if Late_Overriding then + Ensure_Freeze_Node (R); Insert_Before_And_Analyze (Freeze_Node (R), DTW_Decl); else Append_Freeze_Action (R, DTW_Decl); diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -6815,8 +6815,7 @@ package body Sem_Ch3 is -- in a dispatch table. if not GNATprove_Mode then - Ensure_Freeze_Node (Id); - Append_Freeze_Actions (Id, New_List (New_Decl)); + Append_Freeze_Action (Id, New_Decl); -- Under GNATprove mode there is no such problem but we do not declare -- it in the freezing actions since they are not analyzed under this 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 @@ -2715,13 +2715,11 @@ package body Sem_Ch6 is end if; else - Ensure_Freeze_Node (Typ); - declare IR : constant Node_Id := Make_Itype_Reference (Sloc (N)); begin Set_Itype (IR, Etype (Designator)); - Append_Freeze_Actions (Typ, New_List (IR)); + Append_Freeze_Action (Typ, IR); end; end if; diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -4689,7 +4689,6 @@ package body Sem_Ch8 is if Is_Tagged_Type (Etype (P)) and then In_Open_Scopes (Scope (Etype (P))) then - Ensure_Freeze_Node (Etype (P)); Append_Freeze_Action (Etype (P), Body_Node); else Rewrite (N, Body_Node);