[COMMITTED,01/31] ada: Restrict previous change made to expansion of allocators

Message ID 20250107125350.619654-1-poulhies@adacore.com
State New
Headers
Series [COMMITTED,01/31] ada: Restrict previous change made to expansion of allocators |

Commit Message

Marc Poulhiès Jan. 7, 2025, 12:53 p.m. UTC
  From: Eric Botcazou <ebotcazou@adacore.com>

There is no need to build a cleanup if exceptions cannot be propagated.

gcc/ada/ChangeLog:

	* exp_ch4.adb (Expand_Allocator_Expression): Do not build a cleanup
	if restriction No_Exception_Propagation is active.
	* exp_ch6.adb (Make_Build_In_Place_Call_In_Allocator): Likewise.

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

---
 gcc/ada/exp_ch4.adb | 1 +
 gcc/ada/exp_ch6.adb | 1 +
 2 files changed, 2 insertions(+)
  

Patch

diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 75d79019f80..6e8c5c83da5 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -636,6 +636,7 @@  package body Exp_Ch4 is
           and then Nkind (Exp) = N_Function_Call
           and then not (Is_Entity_Name (Name (Exp))
                          and then No_Raise (Entity (Name (Exp))))
+          and then not Restriction_Active (No_Exception_Propagation)
           and then RTE_Available (RE_Free)
           and then not Debug_Flag_QQ);
       --  Return True if a cleanup needs to be built to deallocate the memory
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
index a339a223f09..37184fd28eb 100644
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -8505,6 +8505,7 @@  package body Exp_Ch6 is
            and then not For_Special_Return_Object (Allocator)
            and then not (Is_Entity_Name (Name (Func_Call))
                           and then No_Raise (Entity (Name (Func_Call))))
+           and then not Restriction_Active (No_Exception_Propagation)
            and then RTE_Available (RE_Free)
            and then not Debug_Flag_QQ
          then