aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1996-04-14 19:01:38 -0400
committerRichard Kenner <kenner@gcc.gnu.org>1996-04-14 19:01:38 -0400
commitf500253d32a9051339ea6cb6e53aafa4fffdeb0a (patch)
treea2e2acceef2effbca1fa1f23ebeb60b09e26acbf
parent4ea62d1a1e6975ff7a79175585b38292ccf7b4c9 (diff)
downloadgcc-f500253d32a9051339ea6cb6e53aafa4fffdeb0a.zip
gcc-f500253d32a9051339ea6cb6e53aafa4fffdeb0a.tar.gz
gcc-f500253d32a9051339ea6cb6e53aafa4fffdeb0a.tar.bz2
(finish_enum): Don't crash if no type can represent all enumeration values.
From-SVN: r11771
-rw-r--r--gcc/c-decl.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 6ad09d9..249992b 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -5894,8 +5894,16 @@ finish_enum (enumtype, values, attributes)
if (flag_short_enums || TYPE_PACKED (enumtype)
|| precision > TYPE_PRECISION (integer_type_node))
- /* Use the width of the narrowest normal C type which is wide enough. */
- TYPE_PRECISION (enumtype) = TYPE_PRECISION (type_for_size (precision, 1));
+ {
+ tree narrowest = type_for_size (precision, 1);
+ if (narrowest == 0)
+ {
+ warning ("enumeration values exceed range of largest integer");
+ narrowest = long_long_integer_type_node;
+ }
+
+ TYPE_PRECISION (enumtype) = TYPE_PRECISION (narrowest);
+ }
else
TYPE_PRECISION (enumtype) = TYPE_PRECISION (integer_type_node);