From f500253d32a9051339ea6cb6e53aafa4fffdeb0a Mon Sep 17 00:00:00 2001 From: Richard Kenner Date: Sun, 14 Apr 1996 19:01:38 -0400 Subject: [PATCH] (finish_enum): Don't crash if no type can represent all enumeration values. From-SVN: r11771 --- gcc/c-decl.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 6ad09d94ba5..249992b23ba 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); -- 2.30.2