public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Pierre-Marie de Rodat <pmderodat@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-5030] [Ada] Cleanup building of renamed equality
Date: Tue,  9 Nov 2021 09:46:41 +0000 (GMT)	[thread overview]
Message-ID: <20211109094641.0F3EA3858420@sourceware.org> (raw)

https://gcc.gnu.org/g:b064f139e3edfc7d9ed294ee8feccda2330d2ccb

commit r12-5030-gb064f139e3edfc7d9ed294ee8feccda2330d2ccb
Author: Piotr Trojanek <trojanek@adacore.com>
Date:   Wed Oct 27 20:43:24 2021 +0200

    [Ada] Cleanup building of renamed equality
    
    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:
---
 gcc/ada/exp_ch8.adb | 39 ++++++++++++++++++++++-----------------
 1 file changed, 22 insertions(+), 17 deletions(-)

diff --git a/gcc/ada/exp_ch8.adb b/gcc/ada/exp_ch8.adb
index dba21edc089..aa2c360704b 100644
--- 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


                 reply	other threads:[~2021-11-09  9:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211109094641.0F3EA3858420@sourceware.org \
    --to=pmderodat@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).