diff options
Diffstat (limited to 'gcc/c/c-decl.c')
-rw-r--r-- | gcc/c/c-decl.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index f7ae648f024..321ae0bf53c 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -4790,14 +4790,14 @@ check_bitfield_type_and_width (tree *type, tree *width, tree orig_name) *width = build_int_cst (integer_type_node, w); } else - w = tree_low_cst (*width, 1); + w = tree_to_uhwi (*width); if (TREE_CODE (*type) == ENUMERAL_TYPE) { 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); } } @@ -5827,7 +5827,7 @@ grokdeclarator (const struct c_declarator *declarator, else error_at (loc, "size of unnamed array is too large"); /* If we proceed with the array type as it is, we'll eventually - crash in tree_low_cst(). */ + crash in tree_to_uhwi (). */ type = error_mark_node; } @@ -7153,7 +7153,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, if (DECL_INITIAL (x)) { - unsigned HOST_WIDE_INT width = tree_low_cst (DECL_INITIAL (x), 1); + unsigned HOST_WIDE_INT width = tree_to_uhwi (DECL_INITIAL (x)); DECL_SIZE (x) = bitsize_int (width); DECL_BIT_FIELD (x) = 1; SET_DECL_C_BIT_FIELD (x); @@ -7224,7 +7224,7 @@ finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, && TREE_TYPE (*fieldlistp) != error_mark_node) { unsigned HOST_WIDE_INT width - = tree_low_cst (DECL_INITIAL (*fieldlistp), 1); + = tree_to_uhwi (DECL_INITIAL (*fieldlistp)); tree type = TREE_TYPE (*fieldlistp); if (width != TYPE_PRECISION (type)) { @@ -7450,7 +7450,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; @@ -7477,13 +7478,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"); @@ -7491,7 +7492,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); |