ada: Fix premature finalization of return temporary
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 9 Dec 2022 23:51:10 +0000 (00:51 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 3 Jan 2023 09:29:54 +0000 (10:29 +0100)
commitde77a81b2c974520183e6c2f205be54844f3d42e
treef2f542240a495e9d8495ada7fddc0e17ab16e7be
parentd3f50f75aa3e5054b28074c029d36c1cbce2d0cb
ada: Fix premature finalization of return temporary

Various parts of the expander and the code generator must have a consistent
view on which temporaries generated for return statements must be finalized
because they are regular temporaries, and which ones must not be since they
are allocated on the return stack directly.  The Is_Related_To_Func_Return
predicate is used for this purpose and needs to be tested consistently.

gcc/ada/

* exp_ch6.adb (Expand_Simple_Function_Return): Make sure that a
captured function call also verifies Is_Related_To_Func_Return.
Do not generate an actual subtype for special return objects.
* exp_util.ads (Is_Related_To_Func_Return): Add commentary.
gcc/ada/exp_ch6.adb
gcc/ada/exp_util.ads