When resolving iterated_component_association that occurs within
delta_aggregate, we create an implicit loop which should act as a scope
for the index parameter entity. However, the name of this entity was
entered before pushing the scope of the implicit loop, so the index
parameter was visible outside of the delta_aggregate.

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

gcc/ada/

        * sem_aggr.adb (Resolve_Delta_Array_Aggregate): Push scope of
        the implicit loop before entering name of the index parameter,
        not after; enter name no matter if the identifier has been
        decorated before.
diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -3052,15 +3052,15 @@ package body Sem_Aggr is
             begin
                Set_Etype  (Ent, Standard_Void_Type);
                Set_Parent (Ent, Assoc);
+               Push_Scope (Ent);
 
                if No (Scope (Id)) then
-                  Enter_Name (Id);
                   Set_Etype (Id, Index_Type);
                   Set_Ekind (Id, E_Variable);
                   Set_Scope (Id, Ent);
                end if;
+               Enter_Name (Id);
 
-               Push_Scope (Ent);
                Analyze_And_Resolve
                  (New_Copy_Tree (Expression (Assoc)), Component_Type (Typ));
                End_Scope;


Reply via email to