This change fixes a regression that occurred on a Ravenscar test, where
gigi blew up because an itype inside the block created for a protected
entry procedure had its scope set incorrectly (designating the enclosing
package) so appeared to gigi not to be declared within the procedure.
The scope of the block is now set to designate the entry procedure's
entity.

Tested on x86_64-pc-linux-gnu, committed on trunk

2019-12-12  Gary Dismukes  <dismu...@adacore.com>

gcc/ada/

        * exp_ch9.adb (Build_Protected_Entry): Set the Scope of the new
        block to be the entity of the procedure created for the entry.
--- gcc/ada/exp_ch9.adb
+++ gcc/ada/exp_ch9.adb
@@ -3724,10 +3724,13 @@ package body Exp_Ch9 is
             Handled_Statement_Sequence => Handled_Statement_Sequence (N)));
 
       --  Analyze now and reset scopes for declarations so that Scope fields
-      --  currently denoting the entry will now denote the block scope.
+      --  currently denoting the entry will now denote the block scope, and
+      --  the block's scope will be set to the new procedure entity.
 
       Analyze_Statements (Bod_Stmts);
 
+      Set_Scope (Entity (Identifier (First (Bod_Stmts))), Bod_Id);
+
       Reset_Scopes_To
         (First (Bod_Stmts), Entity (Identifier (First (Bod_Stmts))));
 

Reply via email to