aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEd Schonberg <schonberg@adacore.com>2021-02-01 13:12:57 -0500
committerPierre-Marie de Rodat <derodat@adacore.com>2021-05-07 05:29:00 -0400
commit4b0ba35687c2df12589cb197a4186e19f40def7f (patch)
tree35a50efdbfb78d6a3ca753ff6e5b61ee18b3a3fd /gcc
parent62acd2c453976165d2a6cd48d06a7341408b7e78 (diff)
downloadgcc-4b0ba35687c2df12589cb197a4186e19f40def7f.zip
gcc-4b0ba35687c2df12589cb197a4186e19f40def7f.tar.gz
gcc-4b0ba35687c2df12589cb197a4186e19f40def7f.tar.bz2
[Ada] Crash on imported object with deep initialization and No_Aborts
gcc/ada/ * exp_util.adb (Remove_Init_Call): If a simple initialization call is present, and the next statement is an initialization block (that contains a call to a Deep_ Initialize routine), remove the block as well, and insert the first initialization call in it, in case it is needed for later relocation.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/exp_util.adb20
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 30e1aff..c461acd 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;