[Ada] Avoid copy operation for returns involving function calls
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 12 Apr 2022 19:56:35 +0000 (21:56 +0200)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 19 May 2022 14:05:30 +0000 (14:05 +0000)
commit8be71a90b15916a966553c47857e1579ca22d507
treead3bac00daf7b04e370ceb3bcf73ea1ac1e28009
parentca03325fb3a5fbf9c8af853d4c7f199e1adb08e3
[Ada] Avoid copy operation for returns involving function calls

The underlying issue is that the front-end does not create transient scopes
for return statements, so objects copied for these statements can never be
finalized properly.

gcc/ada/

* exp_ch6.adb (Expand_Call_Helper): Adjust comment.
(Expand_Simple_Function_Return): For the case of a type which needs
finalization and is returned on the primary stack, do not create a
copy if the expression originates from a function call.
* exp_ch7.adb (Transient Scope Management): Adjust comment.
* exp_util.ads (Is_Related_To_Func_Return): Add WARNING line.
* fe.h (Is_Related_To_Func_Return): Declare.
gcc/ada/exp_ch6.adb
gcc/ada/exp_ch7.adb
gcc/ada/exp_util.ads
gcc/ada/fe.h