aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@adacore.com>2020-06-28 06:24:26 -0400
committerPierre-Marie de Rodat <derodat@adacore.com>2020-10-16 03:31:29 -0400
commit7e8e3cb479dcfdd58dd42825ad7b6c8d39c5ac0e (patch)
treeac5dea861317ab57503b83042726bbc5cc0c0ddd
parentb87042ccc5d066af9de71e215364d40959e11849 (diff)
downloadgcc-7e8e3cb479dcfdd58dd42825ad7b6c8d39c5ac0e.zip
gcc-7e8e3cb479dcfdd58dd42825ad7b6c8d39c5ac0e.tar.gz
gcc-7e8e3cb479dcfdd58dd42825ad7b6c8d39c5ac0e.tar.bz2
[Ada] Finalization of uninitialized object with build in place call
gcc/ada/ * exp_ch6.adb (Make_Build_In_Place_Call_In_Object_Declaration): Call Set_BIP_Initialization_Call systematically. * exp_ch7.adb (Process_Transient_In_Scope): Take BIP_Initialization_Call into account to decide where to insert the Hook.
-rw-r--r--gcc/ada/exp_ch6.adb2
-rw-r--r--gcc/ada/exp_ch7.adb16
2 files changed, 13 insertions, 5 deletions
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
index c78ff0b..1059459 100644
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -9593,7 +9593,7 @@ package body Exp_Ch6 is
-- which prompted the generation of the transient block. To resolve
-- this scenario, store the build-in-place call.
- if Scope_Is_Transient and then Node_To_Be_Wrapped = Obj_Decl then
+ if Scope_Is_Transient then
Set_BIP_Initialization_Call (Obj_Def_Id, Res_Decl);
end if;
diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
index 0ff0a15..1264eeb 100644
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -5668,10 +5668,18 @@ package body Exp_Ch7 is
-- <or>
-- Hook := Obj_Id'Unrestricted_Access;
- if Ekind (Obj_Id) in E_Constant | E_Variable
- and then Present (Last_Aggregate_Assignment (Obj_Id))
- then
- Hook_Insert := Last_Aggregate_Assignment (Obj_Id);
+ -- Similarly if we have a build in place call: we must
+ -- initialize Hook only after the call has happened, otherwise
+ -- Obj_Id will not be initialized yet.
+
+ if Ekind (Obj_Id) in E_Constant | E_Variable then
+ if Present (Last_Aggregate_Assignment (Obj_Id)) then
+ Hook_Insert := Last_Aggregate_Assignment (Obj_Id);
+ elsif Present (BIP_Initialization_Call (Obj_Id)) then
+ Hook_Insert := BIP_Initialization_Call (Obj_Id);
+ else
+ Hook_Insert := Obj_Decl;
+ end if;
-- Otherwise the hook seizes the related object immediately