]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Further cleanup in finalization machinery
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 24 Oct 2023 07:50:25 +0000 (09:50 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 21 Nov 2023 09:57:41 +0000 (10:57 +0100)
This removes the specific treatment of transient scopes in initialization
procedures, which is obsolete.

gcc/ada/

* exp_aggr.adb (Convert_To_Assignments): Do not treat initialization
procedures specially when it comes to creating a transient scope.
* exp_ch7.adb (Build_Finalizer.Process_Declarations): Likewise.
* exp_util.adb (Requires_Cleanup_Actions): Likewise.

gcc/ada/exp_aggr.adb
gcc/ada/exp_ch7.adb
gcc/ada/exp_util.adb

index a6a54e892e2900fe8a08778852a1eb4494fc9184..691430a3e5222c9d5fad5d51bb9b92917548a6f2 100644 (file)
@@ -4294,15 +4294,9 @@ package body Exp_Aggr is
          return;
       end if;
 
-      --  Otherwise, if a transient scope is required, create it now. If we
-      --  are within an initialization procedure do not create such, because
-      --  the target of the assignment must not be declared within a local
-      --  block, and because cleanup will take place on return from the
-      --  initialization procedure.
+      --  Otherwise, if a transient scope is required, create it now
 
-      --  Should the condition be more restrictive ???
-
-      if Requires_Transient_Scope (Typ) and then not Inside_Init_Proc then
+      if Requires_Transient_Scope (Typ) then
          Establish_Transient_Scope (N, Manage_Sec_Stack => False);
       end if;
 
index 2e3da4cfaeda06b8f8f6f279bf7df6515b8367c2..ef3b5c95d644446f7c2e43102144c0bb03924391 100644 (file)
@@ -2479,35 +2479,6 @@ package body Exp_Ch7 is
               and then Present (Library_Unit (Decl))
             then
                Process_Package_Body (Proper_Body (Unit (Library_Unit (Decl))));
-
-            --  Handle a rare case caused by a controlled transient object
-            --  created as part of a record init proc. The variable is wrapped
-            --  in a block, but the block is not associated with a transient
-            --  scope.
-
-            elsif Nkind (Decl) = N_Block_Statement
-              and then Inside_Init_Proc
-            then
-               Old_Counter_Val := Counter_Val;
-
-               if Present (Handled_Statement_Sequence (Decl)) then
-                  Process_Declarations
-                    (Statements (Handled_Statement_Sequence (Decl)),
-                     Preprocess);
-               end if;
-
-               Process_Declarations (Declarations (Decl), Preprocess);
-
-               --  Either the declaration or statement list of the block has a
-               --  controlled object.
-
-               if Preprocess
-                 and then Top_Level
-                 and then No (Last_Top_Level_Ctrl_Construct)
-                 and then Counter_Val > Old_Counter_Val
-               then
-                  Last_Top_Level_Ctrl_Construct := Decl;
-               end if;
             end if;
 
             Prev_Non_Pragma (Decl);
index 3b34e4659f165ebf6e04609f80564429ef5f7bd3..3952a161bd72eba0b8bc1afad096f228b243888c 100644 (file)
@@ -13233,15 +13233,6 @@ package body Exp_Util is
             then
                return True;
             end if;
-
-        --  Handle a rare case caused by a controlled transient object created
-        --  as part of a record init proc. The variable is wrapped in a block,
-        --  but the block is not associated with a transient scope.
-
-         elsif Nkind (Decl) = N_Block_Statement and then Inside_Init_Proc then
-            if Requires_Cleanup_Actions (Decl, Lib_Level) then
-               return True;
-            end if;
          end if;
 
          Next (Decl);