https://gcc.gnu.org/g:e8c240bb2d3b00f587a4055761716d17ec3076a9
commit r17-783-ge8c240bb2d3b00f587a4055761716d17ec3076a9 Author: Javier Miranda <[email protected]> Date: Thu Feb 5 19:29:22 2026 +0000 ada: Fix recursion calls in Remove_Side_Effects This patch fixes a latent problem in the recursion calls performed by Remove_Side_Effects. The problem was introduced when the formal Renaming_Req was added in 2014/June/30. This fix does not introduce functional changes; it fixes the issue thus improving the behavior of this routine. gcc/ada/ChangeLog: * exp_util.adb (Remove_Side_Effects): Propagate actuals in recursion calls, unless this is a known side-effect free attribute whose expressions are also side-effect free. Diff: --- gcc/ada/exp_util.adb | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb index 35861d2ad29e..770d5d69b6a3 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -12880,7 +12880,16 @@ package body Exp_Util is or else Nkind (Prefix (Exp)) /= N_Aggregate) and then not Is_Name_Reference (Prefix (Exp)) then - Remove_Side_Effects (Prefix (Exp), Name_Req, Variable_Ref); + Remove_Side_Effects + (Exp => Prefix (Exp), + Name_Req => Name_Req, + Renaming_Req => Renaming_Req, + Variable_Ref => False, + Related_Id => Related_Id, + Is_Low_Bound => False, + Is_High_Bound => False, + Discr_Number => 0, + Check_Side_Effects => Check_Side_Effects); goto Leave; -- If this is an elementary or a small not-by-reference record type, and @@ -12982,7 +12991,16 @@ package body Exp_Util is elsif Nkind (Exp) = N_Unchecked_Type_Conversion and then Nkind (Expression (Exp)) = N_Explicit_Dereference then - Remove_Side_Effects (Expression (Exp), Name_Req, Variable_Ref); + Remove_Side_Effects + (Exp => Expression (Exp), + Name_Req => Name_Req, + Renaming_Req => Renaming_Req, + Variable_Ref => Variable_Ref, + Related_Id => Related_Id, + Is_Low_Bound => Is_Low_Bound, + Is_High_Bound => Is_High_Bound, + Discr_Number => Discr_Number, + Check_Side_Effects => Check_Side_Effects); goto Leave; -- If this is a type conversion, leave the type conversion and remove @@ -12995,7 +13013,16 @@ package body Exp_Util is elsif Nkind (Exp) = N_Type_Conversion and then Etype (Expression (Exp)) /= Universal_Integer then - Remove_Side_Effects (Expression (Exp), Name_Req, Variable_Ref); + Remove_Side_Effects + (Exp => Expression (Exp), + Name_Req => Name_Req, + Renaming_Req => Renaming_Req, + Variable_Ref => Variable_Ref, + Related_Id => Related_Id, + Is_Low_Bound => Is_Low_Bound, + Is_High_Bound => Is_High_Bound, + Discr_Number => Discr_Number, + Check_Side_Effects => Check_Side_Effects); goto Leave; -- If this is an unchecked conversion that Gigi can't handle, make @@ -13076,7 +13103,16 @@ package body Exp_Util is and then Nkind (Prefix (Exp)) = N_Function_Call and then Is_Array_Type (Und_Typ) then - Remove_Side_Effects (Prefix (Exp), Name_Req, Variable_Ref); + Remove_Side_Effects + (Exp => Prefix (Exp), + Name_Req => Name_Req, + Renaming_Req => Renaming_Req, + Variable_Ref => Variable_Ref, + Related_Id => Related_Id, + Is_Low_Bound => Is_Low_Bound, + Is_High_Bound => Is_High_Bound, + Discr_Number => Discr_Number, + Check_Side_Effects => Check_Side_Effects); goto Leave; -- Otherwise we generate a reference to the expression
