]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Constraint check on tagged build-in-place object decls
authorBob Duff <duff@adacore.com>
Tue, 4 Mar 2025 19:47:41 +0000 (14:47 -0500)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 9 Jun 2025 06:32:06 +0000 (08:32 +0200)
commita23938b3a7d7dd7a3dcb3216ec0de4a24a1ff069
tree827811d2832a3b7bbe9beda5c7c38d1347d531ec
parent95da1ec42b9debc0c7c0ee1508dbc1493852b200
ada: Constraint check on tagged build-in-place object decls

In the case of "X : T := F (...);", where T is a constrained
discriminated tagged subtype, perform a constraint check
after F returns. The result of F is allocated by the callee
on the secondary stack in this case.
Note that there are still missing checks for some build-in-place
calls.

gcc/ada/ChangeLog:

* exp_ch6.adb: Remove a couple of "???" suggesting something that
we will likely never do.
(Make_Build_In_Place_Call_In_Object_Declaration):
When a constraint check is needed, do the check.
Do it at the call site for now.
The check is still missing in the untagged case,
because the caller allocates in that case.
* sem_ch8.adb (Analyze_Object_Renaming):
Remove obsolete transformation of a renaming into
an object declaration. Given that we also (sometimes) tranform
object declarations into renamings, this transformation was
adding complexity; the new code in
Make_Build_In_Place_Call_In_Object_Declaration above
would need to explicitly avoid the run-time check in the case of
renamings, because renamings are supposed to ignore the nominal
subtype. Anyway, it is no longer needed.
* exp_ch3.adb (Expand_N_Object_Declaration): Rewrite comment;
it IS clear how to do it, but we haven't done it right yet.
gcc/ada/exp_ch3.adb
gcc/ada/exp_ch6.adb
gcc/ada/sem_ch8.adb