From: Richard Kenner Date: Sun, 14 Apr 1996 23:01:38 +0000 (-0400) Subject: (finish_enum): Don't crash if no type can represent all enumeration values. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f500253d32a9051339ea6cb6e53aafa4fffdeb0a;p=gcc.git (finish_enum): Don't crash if no type can represent all enumeration values. From-SVN: r11771 --- 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);