diff options
author | mrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-08-13 20:41:07 +0000 |
---|---|---|
committer | mrs <mrs@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-08-13 20:41:07 +0000 |
commit | e913b5cd5b6a9bd3a2ad58c65f9e3cd2bb55a28c (patch) | |
tree | f52a097017e3dcf89fad6525984e4591489f961e /gcc/c | |
parent | 9a5942c1d4d9116ab74b0741cfe3894a89fd17fb (diff) | |
download | gcc-e913b5cd5b6a9bd3a2ad58c65f9e3cd2bb55a28c.tar.gz |
Add wide-int branch.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/wide-int@201707 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/Make-lang.in | 2 | ||||
-rw-r--r-- | gcc/c/c-decl.c | 25 | ||||
-rw-r--r-- | gcc/c/c-parser.c | 8 | ||||
-rw-r--r-- | gcc/c/c-typeck.c | 38 |
4 files changed, 38 insertions, 35 deletions
diff --git a/gcc/c/Make-lang.in b/gcc/c/Make-lang.in index 1161742c274..8a4eb85cbbe 100644 --- a/gcc/c/Make-lang.in +++ b/gcc/c/Make-lang.in @@ -190,7 +190,7 @@ c/c-parser.o : c/c-parser.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \ c/c-typeck.o : c/c-typeck.c c/c-lang.h $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ $(TREE_H) $(C_TREE_H) $(TARGET_H) $(FLAGS_H) intl.h \ langhooks.h tree-iterator.h $(BITMAP_H) $(GIMPLE_H) \ - c-family/c-objc.h c-family/c-common.h + c-family/c-objc.h c-family/c-common.h wide-int.h c/c-array-notation.o: c/c-array-notation.c c/c-lang.h $(CONFIG_H) \ $(SYSTEM_H) coretypes.h $(TREE_H) $(C_TREE_H) $(TARGET_H) \ 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); diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index b612e29c852..db0f730f787 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -378,7 +378,7 @@ c_lex_one_token (c_parser *parser, c_token *token) break; case CPP_PRAGMA: /* We smuggled the cpp_token->u.pragma value in an INTEGER_CST. */ - token->pragma_kind = (enum pragma_kind) TREE_INT_CST_LOW (token->value); + token->pragma_kind = (enum pragma_kind) tree_to_hwi (token->value); token->value = NULL; break; default: @@ -9210,8 +9210,8 @@ c_parser_omp_clause_collapse (c_parser *parser, tree list) if (num == error_mark_node) return list; if (!INTEGRAL_TYPE_P (TREE_TYPE (num)) - || !host_integerp (num, 0) - || (n = tree_low_cst (num, 0)) <= 0 + || !tree_fits_shwi_p (num) + || (n = tree_to_shwi (num)) <= 0 || (int) n != n) { error_at (loc, @@ -10261,7 +10261,7 @@ c_parser_omp_for_loop (location_t loc, for (cl = clauses; cl; cl = OMP_CLAUSE_CHAIN (cl)) if (OMP_CLAUSE_CODE (cl) == OMP_CLAUSE_COLLAPSE) - collapse = tree_low_cst (OMP_CLAUSE_COLLAPSE_EXPR (cl), 0); + collapse = tree_to_shwi (OMP_CLAUSE_COLLAPSE_EXPR (cl)); gcc_assert (collapse >= 1); diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c index 30871db3623..ce0cddc8ae6 100644 --- a/gcc/c/c-typeck.c +++ b/gcc/c/c-typeck.c @@ -39,6 +39,7 @@ along with GCC; see the file COPYING3. If not see #include "gimple.h" #include "c-family/c-objc.h" #include "c-family/c-common.h" +#include "wide-int.h" /* Possible cases of implicit bad conversions. Used to select diagnostic messages in convert_for_assignment. */ @@ -4736,9 +4737,8 @@ 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); } } @@ -6798,7 +6798,7 @@ push_init_level (int implicit, struct obstack * braced_init_obstack) else if (TREE_CODE (constructor_type) == ARRAY_TYPE) { constructor_type = TREE_TYPE (constructor_type); - push_array_bounds (tree_low_cst (constructor_index, 1)); + push_array_bounds (tree_to_uhwi (constructor_index)); constructor_depth++; } @@ -7597,20 +7597,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); } @@ -7621,24 +7621,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); } @@ -8348,7 +8350,7 @@ process_init_element (struct c_expr value, bool implicit, /* Now output the actual element. */ if (value.value) { - push_array_bounds (tree_low_cst (constructor_index, 1)); + push_array_bounds (tree_to_uhwi (constructor_index)); output_init_element (value.value, value.original_type, strict_string, elttype, constructor_index, 1, implicit, @@ -9144,7 +9146,7 @@ c_finish_bc_stmt (location_t loc, tree *label_p, bool is_break) } else if (TREE_CODE (label) == LABEL_DECL) ; - else switch (TREE_INT_CST_LOW (label)) + else switch (tree_to_hwi (label)) { case 0: if (is_break) |