diff options
author | Steve Baird <baird@adacore.com> | 2024-03-11 17:45:58 -0700 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2024-05-17 10:21:05 +0200 |
commit | 7b5b67dc1960b4b2f72c003e747b34049a5e04a7 (patch) | |
tree | 5779cf86b16bfdf9b93ede303ef1faf0e68da76a | |
parent | 3a5c4f926676bada86b7862ec0257ac5170b7976 (diff) | |
download | gcc-7b5b67dc1960b4b2f72c003e747b34049a5e04a7.zip gcc-7b5b67dc1960b4b2f72c003e747b34049a5e04a7.tar.gz gcc-7b5b67dc1960b4b2f72c003e747b34049a5e04a7.tar.bz2 |
ada: Bug in computing local restrictions inherited from enclosing scopes.
In the function Local_Restrict.Active_Restriction, we traverse enclosing
scopes looking for a relevant Local_Restrictions aspect specification.
Fix a bug in this traversal.
gcc/ada/
* local_restrict.adb (Active_Restriction): When traversing scopes,
do not skip over a subprogram body.
-rw-r--r-- | gcc/ada/local_restrict.adb | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/gcc/ada/local_restrict.adb b/gcc/ada/local_restrict.adb index 6e91c8a..3be9404 100644 --- a/gcc/ada/local_restrict.adb +++ b/gcc/ada/local_restrict.adb @@ -90,22 +90,28 @@ package body Local_Restrict is return Result; end if; - Scop := Enclosing_Declaration (Scop); - if Present (Scop) then - Scop := Parent (Scop); + declare + Saved_Scope : constant Node_Id := Scop; + begin + Scop := Enclosing_Declaration (Scop); if Present (Scop) then - -- For a subprogram associated with a type, we don't care - -- where the type was frozen; continue from the type. - - if Nkind (Scop) = N_Freeze_Entity then - Scop := Scope (Entity (Scop)); - elsif Nkind (Parent (Scop)) = N_Freeze_Entity then - Scop := Scope (Entity (Parent (Scop))); - else - Scop := Find_Enclosing_Scope (Scop); + Scop := Parent (Scop); + if Present (Scop) then + -- For a subprogram associated with a type, we don't care + -- where the type was frozen; continue from the type. + + if Nkind (Scop) = N_Freeze_Entity then + Scop := Scope (Entity (Scop)); + elsif Nkind (Parent (Scop)) = N_Freeze_Entity then + Scop := Scope (Entity (Parent (Scop))); + elsif Present (Scope (Saved_Scope)) then + Scop := Scope (Saved_Scope); + else + Scop := Find_Enclosing_Scope (Scop); + end if; end if; end if; - end if; + end; end loop; return Empty; |