In the case of a call to a subprogram that has an out (or in-out) parameter
that is passed by copy, the caller performs copy-back after the call returns.
If the actual parameter is a view conversion to a subtype that has an enabled
predicate, then the predicate check performed at that point should be
performed before, not after, the operand of the view conversion is updated.
gcc/ada/ChangeLog:
* exp_ch6.adb (Expand_Actuals): After building the tree for a
predicate check, call Prepend_To instead of Append_To so that the
check is performed before, instead of after, the corresponding
parameter copy-back.
and then Predicate_Tests_On_Arguments (Subp)
then
- Append_To (Post_Call,
+ -- If Actual is a view conversion to a by-copy subtype
+ -- that is subject to a predicate, then the predicate
+ -- check must precede copy-back. So Prepend.
+
+ Prepend_To (Post_Call,
Make_Predicate_Check (Atyp, Actual));
end if;
end By_Ref_Predicate_Check;