]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Fix Constraint_Error on mutable assignment
authorBob Duff <duff@adacore.com>
Tue, 5 Mar 2024 23:35:25 +0000 (18:35 -0500)
committerMarc Poulhiès <poulhies@adacore.com>
Fri, 17 May 2024 08:21:01 +0000 (10:21 +0200)
commitcb71c251d846032cfb31e86c8e4d678c58a90ecc
treeaf9f0b4fde2de9146a2b0c006e5de8194746edff
parent376a8ea17dfb3dc1267dc88bd90e5f84b82aadaa
ada: Fix Constraint_Error on mutable assignment

For an assignment statement "X := Y;", where X is a formal parameter
of a "late overriding" subprogram (i.e. it has no spec, and the body
is overriding), and the subtype of X is an unconstrained record with
defaulted discriminants, if the actual parameter passed to X is
unconstrained, then X is unconstrained. This patch fixes a bug
where X was incorrectly considered constrained, so that if Y's
discriminants are different from X, Constraint_Error was raised.

The bug was caused by the fact that an extra "constrained" formal
parameter was missing in both caller and callee.

gcc/ada/

* sem_disp.adb (Check_Dispatching_Operation): Call
Create_Extra_Formals, so that the caller will have an extra
"constrained" parameter, which will be checked on assignment in
the callee, and will be passed in by the caller.
gcc/ada/sem_disp.adb