]> gcc.gnu.org Git - gcc.git/commitdiff
ada: Fix small inaccuracy in previous change
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 16 Feb 2024 09:30:17 +0000 (10:30 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 14 May 2024 08:19:59 +0000 (10:19 +0200)
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.

gcc/ada/exp_ch4.adb

index b1f7593de2ac109c2f858aa85c2f0ee50bc0049d..762e75616a7f1105ce9ee46110f26c6de0b04a28 100644 (file)
@@ -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);
 
This page took 0.078015 seconds and 5 git commands to generate.