===================================================================
@@ -3864,10 +3864,14 @@
Set_Debug_Info_Needed (Id);
-- If the container does not have a variable indexing aspect,
- -- the element is a constant in the loop.
+ -- the element is a constant in the loop. The container itself
+ -- may be constant, in which case the element is a constant as
+ -- well. The container has been rewritten as a call to Iterate,
+ -- so examine original node.
if No (Find_Value_Of_Aspect
(Container_Typ, Aspect_Variable_Indexing))
+ or else not Is_Variable (Original_Node (Container))
then
Set_Ekind (Id, E_Constant);
end if;