From: Richard Kenner Date: Wed, 21 Apr 2021 12:35:24 +0000 (-0400) Subject: [Ada] Make copies of entities being declared when copying block X-Git-Tag: basepoints/gcc-13~6411 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a2c557b8ba4e33452a27219af1db83ec0cb7e0a;p=thirdparty%2Fgcc.git [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. --- diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index 0d5095263141..a54326805e5b 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