public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r15-613] ada: Bug in computing local restrictions inherited from enclosing scopes.
@ 2024-05-17  8:26 Marc Poulhi?s
  0 siblings, 0 replies; only message in thread
From: Marc Poulhi?s @ 2024-05-17  8:26 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:7b5b67dc1960b4b2f72c003e747b34049a5e04a7

commit r15-613-g7b5b67dc1960b4b2f72c003e747b34049a5e04a7
Author: Steve Baird <baird@adacore.com>
Date:   Mon Mar 11 17:45:58 2024 -0700

    ada: Bug in computing local restrictions inherited from enclosing scopes.
    
    In the function Local_Restrict.Active_Restriction, we traverse enclosing
    scopes looking for a relevant Local_Restrictions aspect specification.
    Fix a bug in this traversal.
    
    gcc/ada/
    
            * local_restrict.adb (Active_Restriction): When traversing scopes,
            do not skip over a subprogram body.

Diff:
---
 gcc/ada/local_restrict.adb | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/gcc/ada/local_restrict.adb b/gcc/ada/local_restrict.adb
index 6e91c8a2e2a2..3be940499283 100644
--- a/gcc/ada/local_restrict.adb
+++ b/gcc/ada/local_restrict.adb
@@ -90,22 +90,28 @@ package body Local_Restrict is
             return Result;
          end if;
 
-         Scop := Enclosing_Declaration (Scop);
-         if Present (Scop) then
-            Scop := Parent (Scop);
+         declare
+            Saved_Scope : constant Node_Id := Scop;
+         begin
+            Scop := Enclosing_Declaration (Scop);
             if Present (Scop) then
-               --  For a subprogram associated with a type, we don't care
-               --  where the type was frozen; continue from the type.
-
-               if Nkind (Scop) = N_Freeze_Entity then
-                  Scop := Scope (Entity (Scop));
-               elsif Nkind (Parent (Scop)) = N_Freeze_Entity then
-                  Scop := Scope (Entity (Parent (Scop)));
-               else
-                  Scop := Find_Enclosing_Scope (Scop);
+               Scop := Parent (Scop);
+               if Present (Scop) then
+                  --  For a subprogram associated with a type, we don't care
+                  --  where the type was frozen; continue from the type.
+
+                  if Nkind (Scop) = N_Freeze_Entity then
+                     Scop := Scope (Entity (Scop));
+                  elsif Nkind (Parent (Scop)) = N_Freeze_Entity then
+                     Scop := Scope (Entity (Parent (Scop)));
+                  elsif Present (Scope (Saved_Scope)) then
+                     Scop := Scope (Saved_Scope);
+                  else
+                     Scop := Find_Enclosing_Scope (Scop);
+                  end if;
                end if;
             end if;
-         end if;
+         end;
       end loop;
 
       return Empty;

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

only message in thread, other threads:[~2024-05-17  8:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-17  8:26 [gcc r15-613] ada: Bug in computing local restrictions inherited from enclosing scopes Marc Poulhi?s

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).