https://gcc.gnu.org/g:64efbc69e93e7c052300131f64b3ea5134a88d71

commit r16-1877-g64efbc69e93e7c052300131f64b3ea5134a88d71
Author: Gary Dismukes <dismu...@adacore.com>
Date:   Tue May 20 00:16:25 2025 +0000

    ada: Fix for compiler crash on function return with Relaxed_Finalization 
parts
    
    The compiler crashes on compiling a return statement of a function whose 
result
    type has a component whose type is specified with Relaxed_Finalization. The
    compiler was attempting to retrieve a nonexistent BIP_Collection extra 
formal
    from the enclosing function, which may not exist in the case of result types
    with Relaxed_Finalization.
    
    gcc/ada/ChangeLog:
    
            * exp_ch3.adb (Build_Heap_Or_Pool_Allocator): Test not 
Has_Relaxed_Finalization
            as a guard against retrieving BIP_Collection formal (and related 
code).

Diff:
---
 gcc/ada/exp_ch3.adb | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/exp_ch3.adb b/gcc/ada/exp_ch3.adb
index 4e2bef32a353..7c18f81cb07e 100644
--- a/gcc/ada/exp_ch3.adb
+++ b/gcc/ada/exp_ch3.adb
@@ -6981,7 +6981,9 @@ package body Exp_Ch3 is
 
          --  Processing for objects that require finalization actions
 
-         if Needs_Finalization (Ret_Typ) then
+         if Needs_Finalization (Ret_Typ)
+           and then not Has_Relaxed_Finalization (Ret_Typ)
+         then
             declare
                Decls       : constant List_Id := New_List;
                Fin_Coll_Id : constant Entity_Id :=

Reply via email to