@@ -382,12 +382,24 @@ package body Arrays is
382382 -- is pure
383383
384384 function Make_Array_Default_Initialiser (E : Entity_Id) return Irep is
385+ -- Note this function only works for one dimensional arrays at present.
385386 Idx : constant Node_Id := First_Index (E);
387+ -- The Entity is an array object
388+ -- The first index is a discrete_subtype_definition which
389+ -- may be a subtype_indication or a range.
390+ -- For determining the upper bounds and lower bounds a range is required
391+ -- and if the first index is a subtype_indication, the constraints
392+ -- of the subtype have to be obtained - which should be a range.
393+ Bound_Range : constant Node_Id :=
394+ (if Nkind (Idx) = N_Range
395+ then Idx
396+ else Scalar_Range (Entity (Idx)));
397+
386398 Lbound : constant Irep :=
387- Typecast_If_Necessary (Do_Expression (Low_Bound (Idx )),
399+ Typecast_If_Necessary (Do_Expression (Low_Bound (Bound_Range )),
388400 CProver_Size_T, Global_Symbol_Table);
389401 Hbound : constant Irep :=
390- Typecast_If_Necessary (Do_Expression (High_Bound (Idx )),
402+ Typecast_If_Necessary (Do_Expression (High_Bound (Bound_Range )),
391403 CProver_Size_T, Global_Symbol_Table);
392404 Source_Loc : constant Source_Ptr := Sloc (E);
393405 Len : constant Irep :=
0 commit comments