From cf2ac46f182c35397fca39c0dbe392fa0c6df011 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sat, 15 Oct 1994 00:32:58 +0000 Subject: [PATCH] (type_promotes_to): Also promote enums to long if appropriate. From-SVN: r8277 --- gcc/cp/cvt.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index d804ff2..7777350 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -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. -- 2.7.4