From patchwork Tue Nov 9 09:46:04 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: 47256 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 6C4053858405 for ; Tue, 9 Nov 2021 10:00:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6C4053858405 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636452043; bh=5VHe5V5QOsL/vEuuuUaYc4LapU9W81rw25lrW9dI8Hc=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=CLByUKN/XvCEH4sB+rKnWk3HyIZZbGAMwLWIMISPI0Se+DtEzPwRc3yRQNHrxrPNj cv/Y7KVptEmGKIUlC02oB28s7BeiTS78h0JwEllpomfgU4Ai76dJfyarfx6jLZ88nF F977v+auqNbNT8LktO1pmFyGIdxuHCVe13eFsY1w= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by sourceware.org (Postfix) with ESMTPS id 7B33A3858001 for ; Tue, 9 Nov 2021 09:46:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7B33A3858001 Received: by mail-lf1-x12c.google.com with SMTP id u11so43106141lfs.1 for ; Tue, 09 Nov 2021 01:46:07 -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=5VHe5V5QOsL/vEuuuUaYc4LapU9W81rw25lrW9dI8Hc=; b=zQQGw9xUsA7EuqxRXZU+UsZQMBweCCzRgM1GszarWztr3KmHUjZ2oHC09tGSJZSs3b qOt+ee+9cHFiuMLruF4xdEfEjaMeqycdHrSc5wgEO0WFe95AVgZyDhvDVz8DqsxbusRV SbbvJzULYbiK/S9vnxOffS81RbM+GBbzKwFQiURlqV/SM6UBYG9kGUBy/XNgJEBTdNRh u7NkONee0Pudv4EJ3ugfrp+BDEOx3pCvobfFipqrWvEIVvet+2itoE++8znsPcwFH6mR CROX494DrLfj4jrovEBVQjVS7D1YZRTok2C1VrSkUnv3MdFNnkGKbKcPteXl2XJaIJhl xOcQ== X-Gm-Message-State: AOAM532naVYk3PBxjashWLkuj3uO9khqhMJVGa2HoRAEamx5iQ/vsOJl dIbkrUrHQ1u0EsWU14zcxdVvEH5cB0gr1wFs X-Google-Smtp-Source: ABdhPJwZiqjFvKx2HNFZmxCrnH+OH7qNw9/43HFmN3vcJQ8Lc7+tx5GgrVtJuQZ7Ptdsbv9aPgsUmg== X-Received: by 2002:ac2:5f0d:: with SMTP id 13mr5788262lfq.627.1636451166366; Tue, 09 Nov 2021 01:46:06 -0800 (PST) Received: from adacore.com ([2a02:2ab8:224:2ce:72b5:e8ff:feef:ee60]) by smtp.gmail.com with ESMTPSA id w6sm2095750lfk.242.2021.11.09.01.46.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Nov 2021 01:46:05 -0800 (PST) Date: Tue, 9 Nov 2021 09:46:04 +0000 To: gcc-patches@gcc.gnu.org Subject: [Ada] Cleanup building of renamed equality Message-ID: <20211109094604.GA830447@adacore.com> MIME-Version: 1.0 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 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" Cleanup related to expansion of predefined equality for GNATprove; semantics is unaffected. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * exp_ch8.adb (Build_Body_For_Renaming): Remove unnecessary calls to Sloc; set Handled_Statement_Sequence when building subprogram body; whitespace cleanup. diff --git a/gcc/ada/exp_ch8.adb b/gcc/ada/exp_ch8.adb --- a/gcc/ada/exp_ch8.adb +++ b/gcc/ada/exp_ch8.adb @@ -288,6 +288,7 @@ package body Exp_Ch8 is function Build_Body_For_Renaming (Typ : Entity_Id) return Node_Id is Left : constant Entity_Id := First_Formal (Id); Right : constant Entity_Id := Next_Formal (Left); + Bodies : List_Id; Body_Id : Entity_Id; Decl : Node_Id; @@ -295,11 +296,11 @@ package body Exp_Ch8 is Set_Alias (Id, Empty); Set_Has_Completion (Id, False); Rewrite (N, - Make_Subprogram_Declaration (Sloc (N), + Make_Subprogram_Declaration (Loc, Specification => Specification (N))); Set_Has_Delayed_Freeze (Id); - Body_Id := Make_Defining_Identifier (Sloc (N), Chars (Id)); + Body_Id := Make_Defining_Identifier (Loc, Chars (Id)); Set_Debug_Info_Needed (Body_Id); if Has_Variant_Part (Typ) then @@ -317,6 +318,12 @@ package body Exp_Ch8 is -- subprogram. else + -- While expanding record equality we might create auxiliary + -- subprograms that will be placed in the declaration list of the + -- equality subprogram itself. + + Bodies := Empty_List; + Decl := Make_Subprogram_Body (Loc, Specification => @@ -325,20 +332,18 @@ package body Exp_Ch8 is Parameter_Specifications => Copy_Parameter_List (Id), Result_Definition => New_Occurrence_Of (Standard_Boolean, Loc)), - Declarations => Empty_List, - Handled_Statement_Sequence => Empty); - - Set_Handled_Statement_Sequence (Decl, - Make_Handled_Sequence_Of_Statements (Loc, - Statements => New_List ( - Make_Simple_Return_Statement (Loc, - Expression => - Expand_Record_Equality - (Id, - Typ => Typ, - Lhs => Make_Identifier (Loc, Chars (Left)), - Rhs => Make_Identifier (Loc, Chars (Right)), - Bodies => Declarations (Decl)))))); + Declarations => Bodies, + Handled_Statement_Sequence => + Make_Handled_Sequence_Of_Statements (Loc, + Statements => New_List ( + Make_Simple_Return_Statement (Loc, + Expression => + Expand_Record_Equality + (Id, + Typ => Typ, + Lhs => Make_Identifier (Loc, Chars (Left)), + Rhs => Make_Identifier (Loc, Chars (Right)), + Bodies => Bodies))))); end if; return Decl; @@ -375,7 +380,7 @@ package body Exp_Ch8 is and then Scope (Entity (Nam)) = Standard_Standard then declare - Typ : constant Entity_Id := Etype (First_Formal (Id)); + Typ : constant Entity_Id := Etype (First_Formal (Id)); begin -- Check whether this is a renaming of a predefined equality on an