From bd1df4e8f6cef63934640480b67b92494a735737 Mon Sep 17 00:00:00 2001
From: Eric Botcazou <ebotcazou@adacore.com>
Date: Mon, 16 Dec 2024 08:59:26 +0100
Subject: [PATCH] ada: Restrict previous change made to expansion of allocators

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.
---
 gcc/ada/exp_ch4.adb | 1 +
 gcc/ada/exp_ch6.adb | 1 +
 2 files changed, 2 insertions(+)

diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 75d79019f807..6e8c5c83da5f 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 a339a223f09f..37184fd28ebe 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
-- 
GitLab