summaryrefslogtreecommitdiff
path: root/gcc/c/c-decl.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c/c-decl.c')
-rw-r--r--gcc/c/c-decl.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 6e7c5895ec6..3abf6b98574 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -4880,8 +4880,8 @@ check_bitfield_type_and_width (tree *type, tree *width, tree orig_name)
{
struct lang_type *lt = TYPE_LANG_SPECIFIC (*type);
if (!lt
- || w < tree_int_cst_min_precision (lt->enum_min, TYPE_UNSIGNED (*type))
- || w < tree_int_cst_min_precision (lt->enum_max, TYPE_UNSIGNED (*type)))
+ || w < tree_int_cst_min_precision (lt->enum_min, TYPE_SIGN (*type))
+ || w < tree_int_cst_min_precision (lt->enum_max, TYPE_SIGN (*type)))
warning (0, "%qs is narrower than values of its type", name);
}
}
@@ -7605,7 +7605,8 @@ finish_enum (tree enumtype, tree values, tree attributes)
{
tree pair, tem;
tree minnode = 0, maxnode = 0;
- int precision, unsign;
+ int precision;
+ signop sign;
bool toplevel = (file_scope == current_scope);
struct lang_type *lt;
@@ -7632,13 +7633,13 @@ finish_enum (tree enumtype, tree values, tree attributes)
as one of the integral types - the narrowest one that fits, except
that normally we only go as narrow as int - and signed iff any of
the values are negative. */
- unsign = (tree_int_cst_sgn (minnode) >= 0);
- precision = MAX (tree_int_cst_min_precision (minnode, unsign),
- tree_int_cst_min_precision (maxnode, unsign));
+ sign = (tree_int_cst_sgn (minnode) >= 0) ? UNSIGNED : SIGNED;
+ precision = MAX (tree_int_cst_min_precision (minnode, sign),
+ tree_int_cst_min_precision (maxnode, sign));
if (TYPE_PACKED (enumtype) || precision > TYPE_PRECISION (integer_type_node))
{
- tem = c_common_type_for_size (precision, unsign);
+ tem = c_common_type_for_size (precision, sign == UNSIGNED ? 1 : 0);
if (tem == NULL)
{
warning (0, "enumeration values exceed range of largest integer");
@@ -7646,7 +7647,7 @@ finish_enum (tree enumtype, tree values, tree attributes)
}
}
else
- tem = unsign ? unsigned_type_node : integer_type_node;
+ tem = sign == UNSIGNED ? unsigned_type_node : integer_type_node;
TYPE_MIN_VALUE (enumtype) = TYPE_MIN_VALUE (tem);
TYPE_MAX_VALUE (enumtype) = TYPE_MAX_VALUE (tem);