https://gcc.gnu.org/g:75de817d88aade7fc5e8b4bebe3f179f1c5b6a87

commit r15-611-g75de817d88aade7fc5e8b4bebe3f179f1c5b6a87
Author: Piotr Trojanek <troja...@adacore.com>
Date:   Mon Mar 11 23:02:50 2024 +0100

    ada: Fix for validity checking and conditional evaluation of 'Old
    
    Detection of expression that are "known on entry" (as defined in Ada
    2022 RM 6.1.1(20/5)) was confused by validity checks when used from
    within expansion of attribute 'Old.
    
    gcc/ada/
    
            * sem_util.adb (Is_Known_On_Entry): Handle constants introduced
            by validity checks.

Diff:
---
 gcc/ada/sem_util.adb | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index be777d26e465..d512d462b443 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -30791,6 +30791,14 @@ package body Sem_Util is
                               return False;
                            end if;
 
+                           --  Handle constants introduced by side-effect
+                           --  removal, e.g. by validity checks.
+
+                           if not Comes_From_Source (Obj) then
+                              return
+                                Is_Known_On_Entry (Expression (Parent (Obj)));
+                           end if;
+
                            --  return False if not "all views are constant".
                            if Is_Immutably_Limited_Type (Obj_Typ)
                              or Needs_Finalization (Obj_Typ)

Reply via email to