===================================================================
@@ -3128,6 +3128,15 @@
Set_Debug_Info_Needed (Id);
+ -- If the container does not have a variable indexing aspect,
+ -- the element is a constant in the loop.
+
+ if No (Find_Value_Of_Aspect
+ (Container_Typ, Aspect_Variable_Indexing))
+ then
+ Set_Ekind (Id, E_Constant);
+ end if;
+
-- If the container holds controlled objects, wrap the loop
-- statements and element renaming declaration with a block.
-- This ensures that the result of Element (Cusor) is
===================================================================
@@ -1193,8 +1193,14 @@
end;
end if;
- Set_Ekind (Id, E_Variable);
+ -- Set the Ekind of the entity, unless it has been set already, as is
+ -- the case for the iteration object over a container with no variable
+ -- indexing.
+ if Ekind (Id) /= E_Constant then
+ Set_Ekind (Id, E_Variable);
+ end if;
+
-- Initialize the object size and alignment. Note that we used to call
-- Init_Size_Align here, but that's wrong for objects which have only
-- an Esize, not an RM_Size field.