From: Ronan Desplanques Date: Mon, 3 Mar 2025 11:03:02 +0000 (+0100) Subject: ada: Add example in Current_Entity_In_Scope comment X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ab63499ac8a0883a53fbc85e7868d5f72f42571;p=thirdparty%2Fgcc.git ada: Add example in Current_Entity_In_Scope comment gcc/ada/ChangeLog: * sem_util.ads (Current_Entity_In_Scope): Add example in comment. --- diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads index 38e9676c5c4..29dbae8073e 100644 --- a/gcc/ada/sem_util.ads +++ b/gcc/ada/sem_util.ads @@ -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