diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2024-02-16 10:30:17 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-05-14 10:19:59 +0200 |
commit | a252022d9a1f285e471d8b3b37fe645244919ab5 (patch) | |
tree | 8d5eb8623a15c12e1081be1f7d4e69c900fd5277 | |
parent | 13d8374188eea21d56603135b6af254599c9e4b3 (diff) | |
download | gcc-a252022d9a1f285e471d8b3b37fe645244919ab5.zip gcc-a252022d9a1f285e471d8b3b37fe645244919ab5.tar.gz gcc-a252022d9a1f285e471d8b3b37fe645244919ab5.tar.bz2 |
ada: Fix small inaccuracy in previous change
The call to Build_Allocate_Deallocate_Proc must occur before the special
accessibility check for class-wide allocation is generated, because this
check comes with cleanup code.
gcc/ada/
* exp_ch4.adb (Expand_Allocator_Expression): Move the first call to
Build_Allocate_Deallocate_Proc up to before the accessibility check.
-rw-r--r-- | gcc/ada/exp_ch4.adb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb index b1f7593..762e756 100644 --- a/gcc/ada/exp_ch4.adb +++ b/gcc/ada/exp_ch4.adb @@ -960,12 +960,18 @@ package body Exp_Ch4 is end if; end if; + -- This needs to done before generating the accessibility check below + -- because the check comes with cleanup code that invokes Free on the + -- temporary and, therefore, expects the object to be attached to its + -- finalization collection if it is controlled. + + Build_Allocate_Deallocate_Proc (Declaration_Node (Temp), Mark => N); + -- Note: the accessibility check must be inserted after the call to -- [Deep_]Adjust to ensure proper completion of the assignment. Apply_Accessibility_Check_For_Allocator (N, Exp, Temp); - Build_Allocate_Deallocate_Proc (Declaration_Node (Temp), Mark => N); Rewrite (N, New_Occurrence_Of (Temp, Loc)); Analyze_And_Resolve (N, PtrT); |