[gcc r16-1311] ada: Add example in Current_Entity_In_Scope comment
Marc Poulhies
dkm@gcc.gnu.org
Mon Jun 9 06:38:50 GMT 2025
https://gcc.gnu.org/g:7ab63499ac8a0883a53fbc85e7868d5f72f42571
commit r16-1311-g7ab63499ac8a0883a53fbc85e7868d5f72f42571
Author: Ronan Desplanques <desplanques@adacore.com>
Date: Mon Mar 3 12:03:02 2025 +0100
ada: Add example in Current_Entity_In_Scope comment
gcc/ada/ChangeLog:
* sem_util.ads (Current_Entity_In_Scope): Add example in comment.
Diff:
---
gcc/ada/sem_util.ads | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads
index 38e9676c5c4b..29dbae8073ef 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
More information about the Gcc-cvs
mailing list