From: Ronan Desplanques Date: Thu, 5 Jun 2025 07:48:22 +0000 (+0200) Subject: ada: Fix crash with Finalizable in corner case X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=181d76171ccf77be4aea37d290179130af8e0562;p=thirdparty%2Fgcc.git ada: Fix crash with Finalizable in corner case Since the introduction of the Finalizable aspect, there can be types for which Is_Controlled returns True but that don't have all three finalization primitives. The Generate_Finalization_Actions raised an exception in that case before this patch, which fixes the problem. gcc/ada/ChangeLog: * exp_aggr.adb (Generate_Finalization_Actions): Stop assuming that initialize primitive exists. --- diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index b6c16052ee0..29db1cd2fb1 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -2490,12 +2490,21 @@ package body Exp_Aggr is Ref := Convert_To (Init_Typ, New_Copy_Tree (Target)); Set_Assignment_OK (Ref); - Append_To (L, - Make_Procedure_Call_Statement (Loc, - Name => - New_Occurrence_Of - (Find_Controlled_Prim_Op (Init_Typ, Name_Initialize), Loc), - Parameter_Associations => New_List (New_Copy_Tree (Ref)))); + declare + Intlz : constant Entity_Id := + Find_Controlled_Prim_Op (Init_Typ, Name_Initialize); + begin + if Present (Intlz) then + Append_To + (L, + Make_Procedure_Call_Statement + (Loc, + Name => + New_Occurrence_Of (Intlz, Loc), + Parameter_Associations => + New_List (New_Copy_Tree (Ref)))); + end if; + end; end if; end Generate_Finalization_Actions;