aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEtienne Servais <servais@adacore.com>2021-12-16 14:17:40 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2022-01-07 16:24:15 +0000
commit9b573d421a457852da09253f966246fcc0e16a27 (patch)
treebf408841def5a20116b4923828d8a79eece4fa9a
parent657fc14ca71385385f8fcb77883c4e9d4eedafb0 (diff)
downloadgcc-9b573d421a457852da09253f966246fcc0e16a27.zip
gcc-9b573d421a457852da09253f966246fcc0e16a27.tar.gz
gcc-9b573d421a457852da09253f966246fcc0e16a27.tar.bz2
[Ada] Fix the check of the 'Old prefix
gcc/ada/ * sem_attr.adb (Check_Reference): Fix condition.
-rw-r--r--gcc/ada/sem_attr.adb5
1 files changed, 4 insertions, 1 deletions
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index 017df8d..aa9ae3a 100644
--- a/gcc/ada/sem_attr.adb
+++ b/gcc/ada/sem_attr.adb
@@ -5151,11 +5151,14 @@ package body Sem_Attr is
-- Entities mentioned within the prefix of attribute 'Old must
-- be global to the related postcondition. If this is not the
-- case, then the scope of the local entity is nested within
- -- that of the subprogram.
+ -- that of the subprogram. Moreover, we need to know whether
+ -- Entity (Nod) occurs in the tree rooted at the prefix to
+ -- ensure the entity is not declared within then prefix itself.
elsif Is_Entity_Name (Nod)
and then Present (Entity (Nod))
and then Scope_Within (Scope (Entity (Nod)), Subp_Id)
+ and then not In_Subtree (Entity (Nod), P)
then
Error_Attr
("prefix of attribute % cannot reference local entities",