diff options
author | Richard Kenner <kenner@adacore.com> | 2021-04-21 08:35:24 -0400 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-06-29 14:23:49 +0000 |
commit | 9a2c557b8ba4e33452a27219af1db83ec0cb7e0a (patch) | |
tree | 1bb7aff00007c8073685ecd80992ba57abb40430 | |
parent | ba4b83c3e3bd44448a85e3771b91ae39421d9dd7 (diff) | |
download | gcc-9a2c557b8ba4e33452a27219af1db83ec0cb7e0a.zip gcc-9a2c557b8ba4e33452a27219af1db83ec0cb7e0a.tar.gz gcc-9a2c557b8ba4e33452a27219af1db83ec0cb7e0a.tar.bz2 |
[Ada] Make copies of entities being declared when copying block
gcc/ada/
* sem_util.adb (Visit_Node): Add handling for N_Block_Statement
with declarations.
-rw-r--r-- | gcc/ada/sem_util.adb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 0d50952..a543268 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -24344,6 +24344,26 @@ package body Sem_Util is EWA_Inner_Scope_Level := EWA_Inner_Scope_Level + 1; end if; + -- If the node is a block, we need to process all declarations + -- in the block and make new entities for each. + + if Nkind (N) = N_Block_Statement and then Present (Declarations (N)) + then + declare + Decl : Node_Id := First (Declarations (N)); + + begin + while Present (Decl) loop + if Nkind (Decl) = N_Object_Declaration then + Add_New_Entity (Defining_Identifier (Decl), + New_Copy (Defining_Identifier (Decl))); + end if; + + Next (Decl); + end loop; + end; + end if; + declare procedure Action (U : Union_Id); procedure Action (U : Union_Id) is |