diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index 75d79019f8078c79ecfde096af88e83d77ec4128..6e8c5c83da5fb30c6eb67d5e853614cae0afd55a 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 a339a223f09f81019c1ea8607aefc597c3d8ca51..37184fd28ebec9eba22fa85fc4b31379afa3b5be 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