diff options
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/c-decl.c | 17 | ||||
-rw-r--r-- | gcc/c/c-parser.c | 2 | ||||
-rw-r--r-- | gcc/c/c-typeck.c | 34 |
3 files changed, 27 insertions, 26 deletions
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index e30876cbd1b..90808eda618 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); diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 56f79f6a795..41ae77b541e 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -13603,7 +13603,7 @@ c_parser_cilk_clause_vectorlength (c_parser *parser, tree clauses, || !INTEGRAL_TYPE_P (TREE_TYPE (expr))) error_at (loc, "vectorlength must be an integer constant"); - else if (exact_log2 (TREE_INT_CST_LOW (expr)) == -1) + else if (wi::exact_log2 (expr) == -1) error_at (loc, "vectorlength must be a power of 2"); else { diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 62c72dfdd70..e4293104d7b 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -50,6 +50,7 @@ along with GCC; see the file COPYING3. If not see #include "c-family/c-common.h" #include "c-family/c-ubsan.h" #include "cilk.h" +#include "wide-int.h" /* Possible cases of implicit bad conversions. Used to select diagnostic messages in convert_for_assignment. */ @@ -5125,9 +5126,7 @@ build_c_cast (location_t loc, tree type, tree expr) } else if (TREE_OVERFLOW (value)) /* Reset VALUE's overflow flags, ensuring constant sharing. */ - value = build_int_cst_wide (TREE_TYPE (value), - TREE_INT_CST_LOW (value), - TREE_INT_CST_HIGH (value)); + value = wide_int_to_tree (TREE_TYPE (value), value); } } @@ -8069,20 +8068,20 @@ set_nonincremental_init_from_string (tree str, { if (wchar_bytes == 1) { - val[1] = (unsigned char) *p++; - val[0] = 0; + val[0] = (unsigned char) *p++; + val[1] = 0; } else { - val[0] = 0; val[1] = 0; + val[0] = 0; for (byte = 0; byte < wchar_bytes; byte++) { if (BYTES_BIG_ENDIAN) bitpos = (wchar_bytes - byte - 1) * charwidth; else bitpos = byte * charwidth; - val[bitpos < HOST_BITS_PER_WIDE_INT] + val[bitpos % HOST_BITS_PER_WIDE_INT] |= ((unsigned HOST_WIDE_INT) ((unsigned char) *p++)) << (bitpos % HOST_BITS_PER_WIDE_INT); } @@ -8093,24 +8092,26 @@ set_nonincremental_init_from_string (tree str, bitpos = ((wchar_bytes - 1) * charwidth) + HOST_BITS_PER_CHAR; if (bitpos < HOST_BITS_PER_WIDE_INT) { - if (val[1] & (((HOST_WIDE_INT) 1) << (bitpos - 1))) + if (val[0] & (((HOST_WIDE_INT) 1) << (bitpos - 1))) { - val[1] |= ((HOST_WIDE_INT) -1) << bitpos; - val[0] = -1; + val[0] |= ((HOST_WIDE_INT) -1) << bitpos; + val[1] = -1; } } else if (bitpos == HOST_BITS_PER_WIDE_INT) { - if (val[1] < 0) - val[0] = -1; + if (val[0] < 0) + val[1] = -1; } - else if (val[0] & (((HOST_WIDE_INT) 1) + else if (val[1] & (((HOST_WIDE_INT) 1) << (bitpos - 1 - HOST_BITS_PER_WIDE_INT))) - val[0] |= ((HOST_WIDE_INT) -1) + val[1] |= ((HOST_WIDE_INT) -1) << (bitpos - HOST_BITS_PER_WIDE_INT); } - value = build_int_cst_wide (type, val[1], val[0]); + value = wide_int_to_tree (type, + wide_int::from_array (val, 2, + HOST_BITS_PER_WIDE_INT * 2)); add_pending_init (purpose, value, NULL_TREE, true, braced_init_obstack); } @@ -12346,8 +12347,7 @@ c_tree_equal (tree t1, tree t2) switch (code1) { case INTEGER_CST: - return TREE_INT_CST_LOW (t1) == TREE_INT_CST_LOW (t2) - && TREE_INT_CST_HIGH (t1) == TREE_INT_CST_HIGH (t2); + return wi::eq_p (t1, t2); case REAL_CST: return REAL_VALUES_EQUAL (TREE_REAL_CST (t1), TREE_REAL_CST (t2)); |