(type_promotes_to): Also promote enums to long if
authorJason Merrill <merrill@gnu.org>
Sat, 15 Oct 1994 00:32:58 +0000 (00:32 +0000)
committerJason Merrill <merrill@gnu.org>
Sat, 15 Oct 1994 00:32:58 +0000 (00:32 +0000)
        appropriate.

From-SVN: r8277

gcc/cp/cvt.c

index d804ff28f906ecbd3bfd6a06fde8e5456b493a06..7777350d925a09359c324c31ea4839eafd9b5aa5 100644 (file)
@@ -2024,11 +2024,16 @@ type_promotes_to (type)
      wider.  */
   else if (TREE_CODE (type) == ENUMERAL_TYPE
           || type == wchar_type_node)
-    type = type_for_size
-      (MAX (TYPE_PRECISION (type), TYPE_PRECISION (integer_type_node)),
-       (flag_traditional
-       || (TYPE_PRECISION (type) >= TYPE_PRECISION (integer_type_node)))
-       && TREE_UNSIGNED (type));
+    {
+      int precision = MAX (TYPE_PRECISION (type),
+                          TYPE_PRECISION (integer_type_node));
+      tree totype = type_for_size (precision, 0);
+      if (TREE_UNSIGNED (type)
+         && ! int_fits_type_p (TYPE_MAX_VALUE (type), totype))
+       type = type_for_size (precision, 1);
+      else
+       type = totype;
+    }
   else if (C_PROMOTING_INTEGER_TYPE_P (type))
     {
       /* Traditionally, unsignedness is preserved in default promotions.