]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Fix premature finalization of anonymous access result from library function
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 28 Oct 2024 07:33:49 +0000 (08:33 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Tue, 12 Nov 2024 13:00:53 +0000 (14:00 +0100)
commitbb4a081156175cf7ac7a818c6a669d3f63ea0ad8
tree83c09e549bac49295bf396c5cfdb1513865d2583
parentc74c88a3e17aa26f57e01dbcce8b4e782a05bfca
ada: Fix premature finalization of anonymous access result from library function

In GNAT's implementation, the finalization of controlled objects created
through anonymous access types occurs when the enclosing library unit goes
out of scope if this is safe, and never occurs otherwise.

The case of a function that is a library unit with an anonymous access
result type falls in the second category for the anonymous access result
type itself and, therefore, finalization cannot take place for it.

gcc/ada/ChangeLog:

PR ada/55725
* exp_ch6.adb (Add_Collection_Actual_To_Build_In_Place_Call): Be
prepared for no collection if the access type is anonymous.
* exp_ch7.adb (Build_Anonymous_Collection): Return early for the
anonymous access result type of a library function.
gcc/ada/exp_ch6.adb
gcc/ada/exp_ch7.adb