public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-7903] ada: Fix assertion failure on very peculiar enumeration type
@ 2023-09-27 8:28 Eric Botcazou
0 siblings, 0 replies; only message in thread
From: Eric Botcazou @ 2023-09-27 8:28 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:7b22fcd97ad770754b2e70e5f2c0cb2c32d16bdb
commit r13-7903-g7b22fcd97ad770754b2e70e5f2c0cb2c32d16bdb
Author: Eric Botcazou <ebotcazou@adacore.com>
Date: Mon Aug 21 18:23:46 2023 +0200
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.
Diff:
---
gcc/ada/freeze.adb | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index 7a4051fc2fa..d464eac13ad 100644
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -8003,6 +8003,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;
-----------------------
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-09-27 8:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-27 8:28 [gcc r13-7903] ada: Fix assertion failure on very peculiar enumeration type Eric Botcazou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).