From: Ronan Desplanques <desplanq...@adacore.com> 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. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/exp_aggr.adb | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index fcf57bf9c31..9ff69ec8130 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -2570,12 +2570,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; -- 2.43.0