procedure Check_Large_Modular_Array (Typ : Entity_Id);
-- Check that the size of array type Typ can be computed without
-- overflow, and generates a Storage_Error otherwise. This is only
- -- relevant for array types whose index has System_Max_Integer_Size
- -- bits, where wrap-around arithmetic might yield a meaningless value
- -- for the length of the array, or its corresponding attribute.
+ -- relevant for array types whose index is a modular type with
+ -- Standard_Long_Long_Integer_Size bits: wrap-around arithmetic
+ -- might yield a meaningless value for the length of the array,
+ -- or its corresponding attribute.
procedure Check_Pragma_Thread_Local_Storage (Var_Id : Entity_Id);
-- Ensure that the initialization state of variable Var_Id subject
-- Storage_Error.
if Is_Modular_Integer_Type (Idx_Typ)
- and then RM_Size (Idx_Typ) = RM_Size (Standard_Long_Long_Integer)
+ and then RM_Size (Idx_Typ) = Standard_Long_Long_Integer_Size
then
+ -- Ensure that the type of the object is elaborated before
+ -- the check itself is emitted to avoid elaboration issues
+ -- in the code generator at the library level.
+
+ if Is_Itype (Etype (E))
+ and then In_Open_Scopes (Scope (Etype (E)))
+ then
+ declare
+ Ref_Node : constant Node_Id :=
+ Make_Itype_Reference (Obj_Loc);
+ begin
+ Set_Itype (Ref_Node, Etype (E));
+ Insert_Action (Declaration_Node (E), Ref_Node);
+ end;
+ end if;
+
Insert_Action (Declaration_Node (E),
Make_Raise_Storage_Error (Obj_Loc,
Condition =>