public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-6371] [Ada] Fix the check of the 'Old prefix
@ 2022-01-07 16:29 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2022-01-07 16:29 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:9b573d421a457852da09253f966246fcc0e16a27

commit r12-6371-g9b573d421a457852da09253f966246fcc0e16a27
Author: Etienne Servais <servais@adacore.com>
Date:   Thu Dec 16 14:17:40 2021 +0100

    [Ada] Fix the check of the 'Old prefix
    
    gcc/ada/
    
            * sem_attr.adb (Check_Reference): Fix condition.

Diff:
---
 gcc/ada/sem_attr.adb | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb
index 017df8d050b..aa9ae3abfd0 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",


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-01-07 16:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-07 16:29 [gcc r12-6371] [Ada] Fix the check of the 'Old prefix Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).