ada: Fix finalization issues in extended return statements
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 14 Dec 2022 14:16:21 +0000 (15:16 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Thu, 5 Jan 2023 14:29:57 +0000 (15:29 +0100)
commitd990f34e93172b040de29c65e6d72572e73d00f0
tree3490300fc2b7f62e0c2329ab1f93c43e93132241
parent46924ad780665721a51306a646f7f601c359ba4c
ada: Fix finalization issues in extended return statements

The first issue pertains to return objects of (class-wide) interface types,
which need to be adjusted if the type is not inherently limited.  The second
issue is for return objects of non-class-wide types that are initialized by
a function call, which can use a direct renaming only if the object doing
the capture of the function call is flagged by Is_Related_To_Func_Return.
The third one is that, in the second case, we may need to reassign the tag.

gcc/ada/

* exp_ch3.adb (Expand_N_Object_Declaration): For a special return
object of an interface type that is not inherently limited, make
a call to the Adjust primitive after doing the copy.  For a special
return object of a non-class-wide type initialized by a function
call, use a direct renaming only if the object doing the capture
is flagged by Is_Related_To_Func_Return.  For a special return
object using a direct renaming, reassign the tag, if need be.
* exp_ch6.adb (Expand_Simple_Function_Return): Fix comment.
* exp_util.adb (Is_Related_To_Func_Return): Accept both regular and
renaming object declarations for return objects.
gcc/ada/exp_ch3.adb
gcc/ada/exp_ch6.adb
gcc/ada/exp_util.adb