Instead of using a dedicated block with a local variable, use the
Discard_Node function.

gcc/ada/ChangeLog:

        * exp_ch3.adb (Build_Implicit_Copy_Constructor)
        (Build_Implicit_Parameterless_Constructor): Refactor how node is
        discarded.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/exp_ch3.adb | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb
index 96374dcdb12..2f799b0a169 100644
--- a/gcc/ada/exp_ch3.adb
+++ b/gcc/ada/exp_ch3.adb
@@ -1974,16 +1974,12 @@ package body Exp_Ch3 is
       Set_Parameter_Specifications (Spec_Node, Parameters);
       Freeze_Extra_Formals (Copy_Id);
 
-      declare
-         Ignore : Node_Id;
-      begin
-         Ignore :=
-           Make_Subprogram_Body (Loc,
-             Specification => Spec_Node,
-             Aspect_Specifications => Aspect_Specs,
-             Handled_Statement_Sequence =>
-               Make_Handled_Sequence_Of_Statements (Loc, Body_Stmts));
-      end;
+      Discard_Node (
+        Make_Subprogram_Body (Loc,
+          Specification => Spec_Node,
+          Aspect_Specifications => Aspect_Specs,
+          Handled_Statement_Sequence =>
+               Make_Handled_Sequence_Of_Statements (Loc, Body_Stmts)));
 
       Set_Is_Public (Copy_Id, Is_Public (Typ));
       Set_Is_Internal (Copy_Id);
@@ -2047,7 +2043,6 @@ package body Exp_Ch3 is
       --  Aspect Initialize enables default initialization
 
       declare
-         Ignore             : Node_Id;
          Default_Initialize : constant Node_Id :=
            Make_Aspect_Specification (Loc,
              Identifier => Make_Identifier (Loc, Name_Initialize),
@@ -2059,12 +2054,12 @@ package body Exp_Ch3 is
                      Box_Present => True)),
                  Is_Parenthesis_Aggregate => True));
       begin
-         Ignore :=
+         Discard_Node (
            Make_Subprogram_Body (Loc,
              Specification => Spec_Node,
              Handled_Statement_Sequence =>
                Make_Handled_Sequence_Of_Statements (Loc),
-             Aspect_Specifications => New_List (Default_Initialize));
+             Aspect_Specifications => New_List (Default_Initialize)));
       end;
 
       Set_Is_Public (Constructor_Id, Is_Public (Typ));
-- 
2.53.0

Reply via email to