diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2023-08-21 18:23:46 +0200 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2023-09-05 13:05:15 +0200 |
commit | 2f1cde4d511b9da6081b785f1c50b7e7aa271b4f (patch) | |
tree | 6ad42ed96d7646bd6445b7e5c1cbdf1cf9e7729c | |
parent | ea271bd907d91f6b417918677bd286b4c16d3440 (diff) | |
download | gcc-2f1cde4d511b9da6081b785f1c50b7e7aa271b4f.zip gcc-2f1cde4d511b9da6081b785f1c50b7e7aa271b4f.tar.gz gcc-2f1cde4d511b9da6081b785f1c50b7e7aa271b4f.tar.bz2 |
ada: Fix assertion failure on very peculiar enumeration type
The compiler currently does not support the combination of a representation
clause on an enumeration type with a size clause whose value is greater than
the size of the largest machine scalar supported by the target.
Given that such a type would have little practical value, this change causes
the compiler to give a proper error message instead of aborting.
gcc/ada/
* freeze.adb (Freeze_Enumeration_Type): Give an error on a type with
both representation clause and too large size.
-rw-r--r-- | gcc/ada/freeze.adb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index 38aeb24..0fc33a4 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -8023,6 +8023,20 @@ package body Freeze is Adjust_Esize_For_Alignment (Typ); end if; + + -- Reject a very large size on a type with a non-standard representation + -- because Expand_Freeze_Enumeration_Type cannot deal with it. + + if Has_Non_Standard_Rep (Typ) + and then Known_Esize (Typ) + and then Esize (Typ) > System_Max_Integer_Size + then + Error_Msg_N + ("enumeration type with representation clause too large", Typ); + Error_Msg_Uint_1 := UI_From_Int (System_Max_Integer_Size); + Error_Msg_N + ("\the size of such a type cannot exceed ^ bits", Typ); + end if; end Freeze_Enumeration_Type; ----------------------- |