]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Reduce scope in the analysis of access attributes
authorPiotr Trojanek <trojanek@adacore.com>
Tue, 16 Jan 2024 12:05:22 +0000 (13:05 +0100)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 7 May 2024 07:55:57 +0000 (09:55 +0200)
Code cleanup; semantics is unaffected.

gcc/ada/

* sem_attr.adb (Analyze_Access_Attribute): Move code to IF
branch where its result is used.

gcc/ada/sem_attr.adb

index c17f67356eff5a241c040152baae23ad45c5cbb4..6140cc0c0d63d62ed07f7142f04b267ac2ffb651 100644 (file)
@@ -982,15 +982,16 @@ package body Sem_Attr is
          if Is_Entity_Name (P) then
             Typ := Entity (P);
 
-            --  The reference may appear in an aggregate that has been expanded
-            --  into a loop. Locate scope of type definition, if any.
+            if Is_Type (Typ) then
 
-            Scop := Current_Scope;
-            while Ekind (Scop) = E_Loop loop
-               Scop := Scope (Scop);
-            end loop;
+               --  The reference may appear in an aggregate that has been
+               --  expanded into a loop. Locate scope of type definition,
+               --  if any.
 
-            if Is_Type (Typ) then
+               Scop := Current_Scope;
+               while Ekind (Scop) = E_Loop loop
+                  Scop := Scope (Scop);
+               end loop;
 
                --  OK if we are within the scope of a limited type
                --  let's mark the component as having per object constraint