diff options
author | squirek <squirek@adacore.com> | 2024-11-01 16:33:02 +0000 |
---|---|---|
committer | Marc Poulhiès <dkm@gcc.gnu.org> | 2025-01-10 10:39:56 +0100 |
commit | 3ff216b7121f832c87eaa03ece327c1e113e155a (patch) | |
tree | 203894cf7b0edf51d0dfc69925f6e7acf7852a02 | |
parent | c92f9f0d949c5c36fbd257a80644ae7231e396fd (diff) | |
download | gcc-3ff216b7121f832c87eaa03ece327c1e113e155a.zip gcc-3ff216b7121f832c87eaa03ece327c1e113e155a.tar.gz gcc-3ff216b7121f832c87eaa03ece327c1e113e155a.tar.bz2 |
ada: Incorrect accessibilty level for library level subprograms
The patch fixes an issue in the compiler whereby accessibility level
calculations for objects declared witihin library-level subprograms
were done incorrectly - potentially allowing runtime accessibility
checks to spuriously pass.
gcc/ada/ChangeLog:
* accessibility.adb:
(Innermost_master_Scope_Depth): Add special case for expressions
within library level subprograms.
-rw-r--r-- | gcc/ada/accessibility.adb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/ada/accessibility.adb b/gcc/ada/accessibility.adb index b808e88..8c85173 100644 --- a/gcc/ada/accessibility.adb +++ b/gcc/ada/accessibility.adb @@ -187,6 +187,15 @@ package body Accessibility is or else (Nkind (Node_Par) = N_Object_Renaming_Declaration and then Comes_From_Iterator (Node_Par)) then + -- Handle the case of expressions within library level + -- subprograms here by adding one to the level modifier. + + if Encl_Scop = Standard_Standard + and then Nkind (Node_Par) = N_Subprogram_Body + then + Master_Lvl_Modifier := Master_Lvl_Modifier + 1; + end if; + -- Note that in some rare cases the scope depth may not be -- set, for example, when we are in the middle of analyzing -- a type and the enclosing scope is said type. In that case |