https://gcc.gnu.org/g:808c661e0293ae84c75973641f670ef4d8c1d1bc

commit r16-8995-g808c661e0293ae84c75973641f670ef4d8c1d1bc
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 6cdb4f21be1d..38fc751277ae 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -12753,7 +12753,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
@@ -12855,7 +12864,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
@@ -12868,7 +12886,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
@@ -12949,7 +12976,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

Reply via email to