diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-09-05 07:54:12 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-09-05 07:54:12 +0000 |
commit | 7660825186b57177db3fb74c871a31ea1c0ffbfb (patch) | |
tree | 43230c004e365d01ca439bdb0c57f4aea1a4e174 /gcc/ada/exp_pakd.adb | |
parent | dbe7d6a179f1468d4b2cd198fde7f88329356bbb (diff) | |
download | gcc-7660825186b57177db3fb74c871a31ea1c0ffbfb.tar.gz |
2005-09-01 Robert Dewar <dewar@adacore.com>
* exp_pakd.adb (Create_Packed_Array_Type): Properly handle very large
packed arrays.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@103865 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/exp_pakd.adb')
-rw-r--r-- | gcc/ada/exp_pakd.adb | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/gcc/ada/exp_pakd.adb b/gcc/ada/exp_pakd.adb index bc5692b8612..d27915db961 100644 --- a/gcc/ada/exp_pakd.adb +++ b/gcc/ada/exp_pakd.adb @@ -27,6 +27,7 @@ with Atree; use Atree; with Checks; use Checks; with Einfo; use Einfo; +with Errout; use Errout; with Exp_Dbug; use Exp_Dbug; with Exp_Util; use Exp_Util; with Nlists; use Nlists; @@ -1084,7 +1085,7 @@ package body Exp_Pakd is -- discriminants, so we treat it as a default/per-object expression. Set_Parent (Len_Expr, Typ); - Analyze_Per_Use_Expression (Len_Expr, Standard_Integer); + Analyze_Per_Use_Expression (Len_Expr, Standard_Long_Long_Integer); -- Use a modular type if possible. We can do this if we have -- static bounds, and the length is small enough, and the length @@ -1095,6 +1096,27 @@ package body Exp_Pakd is if Compile_Time_Known_Value (Len_Expr) then Len_Bits := Expr_Value (Len_Expr) * Csize; + -- Check for size known to be too large + + if Len_Bits > + Uint_2 ** (Standard_Integer_Size - 1) * System_Storage_Unit + then + if System_Storage_Unit = 8 then + Error_Msg_N + ("packed array size cannot exceed " & + "Integer''Last bytes", Typ); + else + Error_Msg_N + ("packed array size cannot exceed " & + "Integer''Last storage units", Typ); + end if; + + -- Reset length to arbitrary not too high value to continue + + Len_Expr := Make_Integer_Literal (Loc, 65535); + Analyze_And_Resolve (Len_Expr, Standard_Long_Long_Integer); + end if; + -- We normally consider small enough to mean no larger than the -- value of System_Max_Binary_Modulus_Power, checking that in the -- case of values longer than word size, we have long shifts. @@ -1207,13 +1229,13 @@ package body Exp_Pakd is Make_Subtype_Indication (Loc, Subtype_Mark => New_Occurrence_Of (PB_Type, Loc), Constraint => - Make_Index_Or_Discriminant_Constraint (Loc, Constraints => New_List ( Make_Range (Loc, Low_Bound => Make_Integer_Literal (Loc, 0), - High_Bound => PAT_High))))); + High_Bound => + Convert_To (Standard_Integer, PAT_High)))))); Install_PAT; |