Index: exp_ch5.adb =================================================================== --- exp_ch5.adb (revision 255408) +++ exp_ch5.adb (working copy) @@ -3135,6 +3135,7 @@ Advance : Node_Id; Init_Decl : Node_Id; + Init_Name : Entity_Id; New_Loop : Node_Id; begin @@ -3169,7 +3170,8 @@ -- the loop. Analyze (Init_Decl); - Set_Ekind (Defining_Identifier (Init_Decl), E_Loop_Parameter); + Init_Name := Defining_Identifier (Init_Decl); + Set_Ekind (Init_Name, E_Loop_Parameter); -- The cursor was marked as a loop parameter to prevent user assignments -- to it, however this renders the advancement step illegal as it is not @@ -3182,9 +3184,11 @@ -- Because we have to analyze the initial declaration of the loop -- parameter multiple times its scope is incorrectly set at this point -- to the one surrounding the block statement - so set the scope - -- manually to be the actual block statement. + -- manually to be the actual block statement, and indicate that it is + -- not visible after the block has been analyzed. - Set_Scope (Defining_Identifier (Init_Decl), Entity (Identifier (N))); + Set_Scope (Init_Name, Entity (Identifier (N))); + Set_Is_Immediately_Visible (Init_Name, False); end Expand_Formal_Container_Loop; ------------------------------------------