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 3ebc002560e..d31361b33a3 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -4859,8 +4859,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); } } @@ -7584,7 +7584,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; @@ -7611,13 +7612,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"); @@ -7625,7 +7626,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 141c4ce9cf6..fb3b01cd4a2 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -13379,7 +13379,7 @@ c_parser_cilk_clause_vectorlength (c_parser *parser, tree clauses) || !TREE_CONSTANT (expr) || !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 672a564d2ce..d3753fbcca6 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -49,6 +49,7 @@ along with GCC; see the file COPYING3. If not see #include "c-family/c-objc.h" #include "c-family/c-common.h" #include "c-family/c-ubsan.h" +#include "wide-int.h" /* Possible cases of implicit bad conversions. Used to select diagnostic messages in convert_for_assignment. */ @@ -5102,9 +5103,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); } } @@ -8025,20 +8024,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); } @@ -8049,24 +8048,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); } @@ -12271,8 +12272,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)); |