diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index 30e1aff37b2..c461acd6813 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -11382,6 +11382,26 @@ package body Exp_Util is end if; if Present (Init_Call) then + -- If restrictions have forbidden Aborts, the initialization call + -- for objects that require deep initialization has not been wrapped + -- into the following block (see Exp_Ch3, Default_Initialize_Object) + -- so if present remove it as well, and include the IP call in it, + -- in the rare case the caller may need to simply displace the + -- initialization, as is done for a later address specification. + + if Nkind (Next (Init_Call)) = N_Block_Statement + and then Is_Initialization_Block (Next (Init_Call)) + then + declare + IP_Call : constant Node_Id := Init_Call; + begin + Init_Call := Next (IP_Call); + Remove (IP_Call); + Prepend (IP_Call, + Statements (Handled_Statement_Sequence (Init_Call))); + end; + end if; + Remove (Init_Call); end if;