aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2024-03-11 23:02:50 +0100
committerMarc Poulhiès <poulhies@adacore.com>2024-05-17 10:21:04 +0200
commit75de817d88aade7fc5e8b4bebe3f179f1c5b6a87 (patch)
tree57e3e8b54e6c85bc11923130fc29120280c6e180
parent615c29a8c5d47a28887087d3ff49b9df7f74fe9e (diff)
downloadgcc-75de817d88aade7fc5e8b4bebe3f179f1c5b6a87.zip
gcc-75de817d88aade7fc5e8b4bebe3f179f1c5b6a87.tar.gz
gcc-75de817d88aade7fc5e8b4bebe3f179f1c5b6a87.tar.bz2
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.
-rw-r--r--gcc/ada/sem_util.adb8
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index be777d2..d512d46 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)