From: Steve Baird Date: Thu, 21 Aug 2025 21:20:51 +0000 (-0700) Subject: ada: Perform predicate check before, not after, parameter copy back. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=571088f4d662d807eaa09bd4b03570e0ebb50495;p=thirdparty%2Fgcc.git ada: Perform predicate check before, not after, parameter copy back. 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. --- diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 18551d4899e..1a9002ce3a8 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -2946,7 +2946,11 @@ package body Exp_Ch6 is 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;