]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Add example in Current_Entity_In_Scope comment
authorRonan Desplanques <desplanques@adacore.com>
Mon, 3 Mar 2025 11:03:02 +0000 (12:03 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 9 Jun 2025 06:32:04 +0000 (08:32 +0200)
gcc/ada/ChangeLog:

* sem_util.ads (Current_Entity_In_Scope): Add example in comment.

gcc/ada/sem_util.ads

index 38e9676c5c4b12f86d9a206f47f1561003df31fc..29dbae8073efdaeb0ff4592e19322e63794d8382 100644 (file)
@@ -619,7 +619,21 @@ package Sem_Util is
    --  Find whether there is a previous definition for name or identifier N in
    --  the current scope. Because declarations for a scope are not necessarily
    --  contiguous (e.g. for packages) the first entry on the visibility chain
-   --  for N is not necessarily in the current scope.
+   --  for N is not necessarily in the current scope. Take, for example:
+   --
+   --  package P is
+   --     X : constant := 13;
+   --
+   --     package Q is
+   --        X : constant := 67;
+   --     end Q;
+   --
+   --     Y : constant := X;
+   --  end P;
+   --
+   --  When the declaration of Y is analyzed, the first entry on the visibility
+   --  chain is the X equal to 67, but Current_Entity_In_Scope returns the X
+   --  equal to 13.
 
    function Current_Scope return Entity_Id;
    --  Get entity representing current scope