[COMMITTED] ada: Small cleanup in finalization machinery

Message ID 20231121100025.1964259-1-poulhies@adacore.com
State Committed
Headers
Series [COMMITTED] ada: Small cleanup in finalization machinery |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gcc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gcc_build--master-arm fail Patch failed to apply

Commit Message

Marc Poulhiès Nov. 21, 2023, 10 a.m. UTC
  From: Eric Botcazou <ebotcazou@adacore.com>

This removes an obsolete flag and adjusts a couple of obsolete comments.

gcc/ada/

	* gen_il-fields.ads (Opt_Field_Enum): Remove Is_Finalization_Wrapper
	* gen_il-gen-gen_nodes.adb (N_Block_Statement): Likewise.
	* sinfo.ads (Is_Finalization_Wrapper): Delete.
	* exp_ch7.adb (Build_Finalizer.Process_Declarations): Adjust comment
	and remove obsolete code testing the Is_Finalization_Wrapper flag.
	* exp_util.adb (Requires_Cleanup_Actions): Likewise.

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

---
 gcc/ada/exp_ch7.adb              | 20 ++------------------
 gcc/ada/exp_util.adb             | 24 ++++++------------------
 gcc/ada/gen_il-fields.ads        |  1 -
 gcc/ada/gen_il-gen-gen_nodes.adb |  1 -
 gcc/ada/sinfo.ads                |  7 -------
 5 files changed, 8 insertions(+), 45 deletions(-)
  

Patch

diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
index 369f0b07999..2e3da4cfaed 100644
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -2248,8 +2248,8 @@  package body Exp_Ch7 is
                --  Finalization of transient objects are treated separately in
                --  order to handle sensitive cases. These include:
 
-               --    * Aggregate expansion
-               --    * If, case, and expression with actions expansion
+               --    * Conditional expressions
+               --    * Expressions with actions
                --    * Transient scopes
 
                --  If one of those contexts has marked the transient object as
@@ -2508,22 +2508,6 @@  package body Exp_Ch7 is
                then
                   Last_Top_Level_Ctrl_Construct := Decl;
                end if;
-
-            --  Handle the case where the original context has been wrapped in
-            --  a block to avoid interference between exception handlers and
-            --  At_End handlers. Treat the block as transparent and process its
-            --  contents.
-
-            elsif Nkind (Decl) = N_Block_Statement
-              and then Is_Finalization_Wrapper (Decl)
-            then
-               if Present (Handled_Statement_Sequence (Decl)) then
-                  Process_Declarations
-                    (Statements (Handled_Statement_Sequence (Decl)),
-                     Preprocess);
-               end if;
-
-               Process_Declarations (Declarations (Decl), Preprocess);
             end if;
 
             Prev_Non_Pragma (Decl);
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 730889cae3e..3b34e4659f1 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -13023,8 +13023,8 @@  package body Exp_Util is
             --  Finalization of transient objects are treated separately in
             --  order to handle sensitive cases. These include:
 
-            --    * Aggregate expansion
-            --    * If, case, and expression with actions expansion
+            --    * Conditional expressions
+            --    * Expressions with actions
             --    * Transient scopes
 
             --  If one of those contexts has marked the transient object as
@@ -13234,23 +13234,11 @@  package body Exp_Util is
                return True;
             end if;
 
-         elsif Nkind (Decl) = N_Block_Statement
-           and then
-
-           --  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.
-
-           (Inside_Init_Proc
+        --  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.
 
-           --  Handle the case where the original context has been wrapped in
-           --  a block to avoid interference between exception handlers and
-           --  At_End handlers. Treat the block as transparent and process its
-           --  contents.
-
-             or else Is_Finalization_Wrapper (Decl))
-         then
+         elsif Nkind (Decl) = N_Block_Statement and then Inside_Init_Proc then
             if Requires_Cleanup_Actions (Decl, Lib_Level) then
                return True;
             end if;
diff --git a/gcc/ada/gen_il-fields.ads b/gcc/ada/gen_il-fields.ads
index a0bfb398ebb..c565e19701d 100644
--- a/gcc/ada/gen_il-fields.ads
+++ b/gcc/ada/gen_il-fields.ads
@@ -255,7 +255,6 @@  package Gen_IL.Fields is
       Is_Entry_Barrier_Function,
       Is_Expanded_Build_In_Place_Call,
       Is_Expanded_Contract,
-      Is_Finalization_Wrapper,
       Is_Folded_In_Parser,
       Is_Generic_Contract_Pragma,
       Is_Homogeneous_Aggregate,
diff --git a/gcc/ada/gen_il-gen-gen_nodes.adb b/gcc/ada/gen_il-gen-gen_nodes.adb
index 996d8d78aea..087f78567f4 100644
--- a/gcc/ada/gen_il-gen-gen_nodes.adb
+++ b/gcc/ada/gen_il-gen-gen_nodes.adb
@@ -1029,7 +1029,6 @@  begin -- Gen_IL.Gen.Gen_Nodes
         Sm (Cleanup_Actions, List_Id),
         Sm (Exception_Junk, Flag),
         Sm (Is_Abort_Block, Flag),
-        Sm (Is_Finalization_Wrapper, Flag),
         Sm (Is_Initialization_Block, Flag),
         Sm (Is_Task_Master, Flag)));
 
diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads
index 8f962601985..1a6317054cf 100644
--- a/gcc/ada/sinfo.ads
+++ b/gcc/ada/sinfo.ads
@@ -1723,12 +1723,6 @@  package Sinfo is
    --    Present in N_Contract nodes. Set if the contract has already undergone
    --    expansion activities.
 
-   --  Is_Finalization_Wrapper
-   --    This flag is present in N_Block_Statement nodes. It is set when the
-   --    block acts as a wrapper of a handled construct which has controlled
-   --    objects. The wrapper prevents interference between exception handlers
-   --    and At_End handlers.
-
    --  Is_Generic_Contract_Pragma
    --    This flag is present in N_Pragma nodes. It is set when the pragma is
    --    a source construct, applies to a generic unit or its body, and denotes
@@ -5238,7 +5232,6 @@  package Sinfo is
       --  Is_Task_Allocation_Block
       --  Exception_Junk
       --  Is_Abort_Block
-      --  Is_Finalization_Wrapper
       --  Is_Initialization_Block
       --  Is_Task_Master
       --  At_End_Proc (set to Empty if no clean up procedure)