This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Patch for some sign warnings
- To: gcc-patches at gcc dot gnu dot org
- Subject: Patch for some sign warnings
- From: Jason Merrill <jason at cygnus dot com>
- Date: Thu, 4 May 2000 14:10:34 -0700
This patch fixes some of the warnings about sign mismatch in gcc.
Many remain; most of these are due to Kenner's Mar 25 change to make
GET_MODE_SIZE unsigned. IMO, this is a mistake, since other code
(notably, int_size_in_bytes and get_inner_reference) want to return -1
as an escape value for sizes. I think that GET_MODE_SIZE et al should
cast to HOST_WIDE_INT, but I don't feel like fixing right now all the things
that have already been changed to expect an unsigned...
2000-05-04 Jason Merrill <jason@casey.cygnus.com>
* simplify-rtx.c (simplify_ternary_operation): Cast to unsigned.
* stor-layout.c (place_field): Likewise.
* integrate.h (struct inline_remap): Make regno_pointer_align unsigned.
* expr.c (store_expr): Make align unsigned.
* explow.c (plus_constant_wide): Make low words unsigned.
* expmed.c (choose_multiplier): Likewise.
* fold-const.c (fold): Likewise.
* tree.h (build_int_2): Likewise.
* tree.c (build_int_2_wide, tree_int_cst_msb): Likewise.
* emit-rtl.c (gen_reg_rtx): Add cast to unsigned char*.
(init_emit): Change cast to unsigned char*.
* varasm.c (compare_constant_1): Add cast to char*.
* gcse.c (delete_null_pointer_checks): Change cast to unsigned int*.
* reload1.c (reload): Likewise.
* rtl.h (MEM_SET_IN_STRUCT_P): Use do { } while (0).
Index: emit-rtl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/emit-rtl.c,v
retrieving revision 1.129
diff -c -p -r1.129 emit-rtl.c
*** emit-rtl.c 2000/05/04 13:49:48 1.129
--- emit-rtl.c 2000/05/04 20:46:57
*************** gen_reg_rtx (mode)
*** 572,578 ****
new = xrealloc (f->emit->regno_pointer_align, old_size * 2);
memset (new + old_size, 0, old_size);
! f->emit->regno_pointer_align = new;
new1 = (rtx *) xrealloc (f->emit->x_regno_reg_rtx,
old_size * 2 * sizeof (rtx));
--- 572,578 ----
new = xrealloc (f->emit->regno_pointer_align, old_size * 2);
memset (new + old_size, 0, old_size);
! f->emit->regno_pointer_align = (unsigned char *) new;
new1 = (rtx *) xrealloc (f->emit->x_regno_reg_rtx,
old_size * 2 * sizeof (rtx));
*************** init_emit ()
*** 3893,3900 ****
= (char *) xcalloc (f->emit->regno_pointer_flag_length, sizeof (char));
f->emit->regno_pointer_align
! = (char *) xcalloc (f->emit->regno_pointer_flag_length,
! sizeof (char));
regno_reg_rtx
= (rtx *) xcalloc (f->emit->regno_pointer_flag_length * sizeof (rtx),
--- 3893,3900 ----
= (char *) xcalloc (f->emit->regno_pointer_flag_length, sizeof (char));
f->emit->regno_pointer_align
! = (unsigned char *) xcalloc (f->emit->regno_pointer_flag_length,
! sizeof (unsigned char));
regno_reg_rtx
= (rtx *) xcalloc (f->emit->regno_pointer_flag_length * sizeof (rtx),
Index: explow.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/explow.c,v
retrieving revision 1.46
diff -c -p -r1.46 explow.c
*** explow.c 2000/05/04 13:49:48 1.46
--- explow.c 2000/05/04 20:46:58
*************** plus_constant_wide (x, c)
*** 106,116 ****
case CONST_DOUBLE:
{
! HOST_WIDE_INT l1 = CONST_DOUBLE_LOW (x);
HOST_WIDE_INT h1 = CONST_DOUBLE_HIGH (x);
! HOST_WIDE_INT l2 = c;
HOST_WIDE_INT h2 = c < 0 ? ~0 : 0;
! HOST_WIDE_INT lv, hv;
add_double (l1, h1, l2, h2, &lv, &hv);
--- 106,117 ----
case CONST_DOUBLE:
{
! unsigned HOST_WIDE_INT l1 = CONST_DOUBLE_LOW (x);
HOST_WIDE_INT h1 = CONST_DOUBLE_HIGH (x);
! unsigned HOST_WIDE_INT l2 = c;
HOST_WIDE_INT h2 = c < 0 ? ~0 : 0;
! unsigned HOST_WIDE_INT lv;
! HOST_WIDE_INT hv;
add_double (l1, h1, l2, h2, &lv, &hv);
Index: expmed.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/expmed.c,v
retrieving revision 1.58
diff -c -p -r1.58 expmed.c
*** expmed.c 2000/04/18 19:14:58 1.58
--- expmed.c 2000/05/04 20:47:02
*************** choose_multiplier (d, n, precision, mult
*** 2567,2577 ****
int *post_shift_ptr;
int *lgup_ptr;
{
! unsigned HOST_WIDE_INT mhigh_hi, mhigh_lo;
! unsigned HOST_WIDE_INT mlow_hi, mlow_lo;
int lgup, post_shift;
int pow, pow2;
! unsigned HOST_WIDE_INT nh, nl, dummy1, dummy2;
/* lgup = ceil(log2(divisor)); */
lgup = ceil_log2 (d);
--- 2567,2578 ----
int *post_shift_ptr;
int *lgup_ptr;
{
! HOST_WIDE_INT mhigh_hi, mlow_hi;
! unsigned HOST_WIDE_INT mhigh_lo, mlow_lo;
int lgup, post_shift;
int pow, pow2;
! unsigned HOST_WIDE_INT nl, dummy1;
! HOST_WIDE_INT nh, dummy2;
/* lgup = ceil(log2(divisor)); */
lgup = ceil_log2 (d);
*************** choose_multiplier (d, n, precision, mult
*** 2592,2598 ****
/* mlow = 2^(N + lgup)/d */
if (pow >= HOST_BITS_PER_WIDE_INT)
{
! nh = (unsigned HOST_WIDE_INT) 1 << (pow - HOST_BITS_PER_WIDE_INT);
nl = 0;
}
else
--- 2593,2599 ----
/* mlow = 2^(N + lgup)/d */
if (pow >= HOST_BITS_PER_WIDE_INT)
{
! nh = (HOST_WIDE_INT) 1 << (pow - HOST_BITS_PER_WIDE_INT);
nl = 0;
}
else
*************** choose_multiplier (d, n, precision, mult
*** 2605,2611 ****
/* mhigh = (2^(N + lgup) + 2^N + lgup - precision)/d */
if (pow2 >= HOST_BITS_PER_WIDE_INT)
! nh |= (unsigned HOST_WIDE_INT) 1 << (pow2 - HOST_BITS_PER_WIDE_INT);
else
nl |= (unsigned HOST_WIDE_INT) 1 << pow2;
div_and_round_double (TRUNC_DIV_EXPR, 1, nl, nh, d, (HOST_WIDE_INT) 0,
--- 2606,2612 ----
/* mhigh = (2^(N + lgup) + 2^N + lgup - precision)/d */
if (pow2 >= HOST_BITS_PER_WIDE_INT)
! nh |= (HOST_WIDE_INT) 1 << (pow2 - HOST_BITS_PER_WIDE_INT);
else
nl |= (unsigned HOST_WIDE_INT) 1 << pow2;
div_and_round_double (TRUNC_DIV_EXPR, 1, nl, nh, d, (HOST_WIDE_INT) 0,
Index: expr.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/expr.c,v
retrieving revision 1.235
diff -c -p -r1.235 expr.c
*** expr.c 2000/05/04 13:49:48 1.235
--- expr.c 2000/05/04 20:47:09
*************** store_expr (exp, target, want_value)
*** 3926,3932 ****
= size_binop (MIN_EXPR,
make_tree (sizetype, size),
size_int (TREE_STRING_LENGTH (exp)));
! int align = TYPE_ALIGN (TREE_TYPE (exp));
rtx copy_size_rtx = expand_expr (copy_size, NULL_RTX,
VOIDmode, 0);
rtx label = 0;
--- 3926,3932 ----
= size_binop (MIN_EXPR,
make_tree (sizetype, size),
size_int (TREE_STRING_LENGTH (exp)));
! unsigned int align = TYPE_ALIGN (TREE_TYPE (exp));
rtx copy_size_rtx = expand_expr (copy_size, NULL_RTX,
VOIDmode, 0);
rtx label = 0;
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fold-const.c,v
retrieving revision 1.116
diff -c -p -r1.116 fold-const.c
*** fold-const.c 2000/05/03 20:04:31 1.116
--- fold-const.c 2000/05/04 20:47:14
*************** fold (expr)
*** 5185,5191 ****
{
if (TREE_CODE (arg0) == INTEGER_CST)
{
! HOST_WIDE_INT low, high;
int overflow = neg_double (TREE_INT_CST_LOW (arg0),
TREE_INT_CST_HIGH (arg0),
&low, &high);
--- 5185,5192 ----
{
if (TREE_CODE (arg0) == INTEGER_CST)
{
! unsigned HOST_WIDE_INT low;
! HOST_WIDE_INT high;
int overflow = neg_double (TREE_INT_CST_LOW (arg0),
TREE_INT_CST_HIGH (arg0),
&low, &high);
*************** fold (expr)
*** 5219,5225 ****
if (! TREE_UNSIGNED (type)
&& TREE_INT_CST_HIGH (arg0) < 0)
{
! HOST_WIDE_INT low, high;
int overflow = neg_double (TREE_INT_CST_LOW (arg0),
TREE_INT_CST_HIGH (arg0),
&low, &high);
--- 5220,5227 ----
if (! TREE_UNSIGNED (type)
&& TREE_INT_CST_HIGH (arg0) < 0)
{
! unsigned HOST_WIDE_INT low;
! HOST_WIDE_INT high;
int overflow = neg_double (TREE_INT_CST_LOW (arg0),
TREE_INT_CST_HIGH (arg0),
&low, &high);
Index: gcse.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/gcse.c,v
retrieving revision 1.86
diff -c -p -r1.86 gcse.c
*** gcse.c 2000/04/10 11:33:18 1.86
--- gcse.c 2000/05/04 20:47:20
*************** delete_null_pointer_checks (f)
*** 5093,5099 ****
/* Go through the basic blocks, seeing whether or not each block
ends with a conditional branch whose condition is a comparison
against zero. Record the register compared in BLOCK_REG. */
! block_reg = (int *) xcalloc (n_basic_blocks, sizeof (int));
for (bb = 0; bb < n_basic_blocks; bb++)
{
rtx last_insn = BLOCK_END (bb);
--- 5093,5099 ----
/* Go through the basic blocks, seeing whether or not each block
ends with a conditional branch whose condition is a comparison
against zero. Record the register compared in BLOCK_REG. */
! block_reg = (unsigned int *) xcalloc (n_basic_blocks, sizeof (int));
for (bb = 0; bb < n_basic_blocks; bb++)
{
rtx last_insn = BLOCK_END (bb);
Index: integrate.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/integrate.h,v
retrieving revision 1.13
diff -c -p -r1.13 integrate.h
*** integrate.h 2000/01/17 17:16:20 1.13
--- integrate.h 2000/05/04 20:47:20
*************** struct inline_remap
*** 95,101 ****
/* Indications for regs being pointers and their alignment. */
char *regno_pointer_flag;
! char *regno_pointer_align;
/* The next few fields are used for subst_constants to record the SETs
that it saw. */
--- 95,101 ----
/* Indications for regs being pointers and their alignment. */
char *regno_pointer_flag;
! unsigned char *regno_pointer_align;
/* The next few fields are used for subst_constants to record the SETs
that it saw. */
Index: reload1.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/reload1.c,v
retrieving revision 1.208
diff -c -p -r1.208 reload1.c
*** reload1.c 2000/04/12 15:04:25 1.208
--- reload1.c 2000/05/04 20:47:37
*************** reload (first, global, dumpfile)
*** 674,680 ****
reg_equiv_mem = (rtx *) xcalloc (max_regno, sizeof (rtx));
reg_equiv_init = (rtx *) xcalloc (max_regno, sizeof (rtx));
reg_equiv_address = (rtx *) xcalloc (max_regno, sizeof (rtx));
! reg_max_ref_width = (int *) xcalloc (max_regno, sizeof (int));
reg_old_renumber = (short *) xcalloc (max_regno, sizeof (short));
bcopy ((PTR) reg_renumber, (PTR) reg_old_renumber, max_regno * sizeof (short));
pseudo_forbidden_regs
--- 674,680 ----
reg_equiv_mem = (rtx *) xcalloc (max_regno, sizeof (rtx));
reg_equiv_init = (rtx *) xcalloc (max_regno, sizeof (rtx));
reg_equiv_address = (rtx *) xcalloc (max_regno, sizeof (rtx));
! reg_max_ref_width = (unsigned int *) xcalloc (max_regno, sizeof (int));
reg_old_renumber = (short *) xcalloc (max_regno, sizeof (short));
bcopy ((PTR) reg_renumber, (PTR) reg_old_renumber, max_regno * sizeof (short));
pseudo_forbidden_regs
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/rtl.h,v
retrieving revision 1.196
diff -c -p -r1.196 rtl.h
*** rtl.h 2000/05/04 13:49:49 1.196
--- rtl.h 2000/05/04 20:47:39
*************** extern const char * const note_insn_name
*** 772,780 ****
RTX. Otherwise, vice versa. Use this macro only when you are
*sure* that you know that the MEM is in a structure, or is a
scalar. VAL is evaluated only once. */
! #define MEM_SET_IN_STRUCT_P(RTX, VAL) \
! ((VAL) ? (MEM_IN_STRUCT_P (RTX) = 1, MEM_SCALAR_P (RTX) = 0) \
! : (MEM_IN_STRUCT_P (RTX) = 0, MEM_SCALAR_P (RTX) = 1))
/* For a MEM rtx, the alias set. If 0, this MEM is not in any alias
set, and may alias anything. Otherwise, the MEM can only alias
--- 772,789 ----
RTX. Otherwise, vice versa. Use this macro only when you are
*sure* that you know that the MEM is in a structure, or is a
scalar. VAL is evaluated only once. */
! #define MEM_SET_IN_STRUCT_P(RTX, VAL) do { \
! if (VAL) \
! { \
! MEM_IN_STRUCT_P (RTX) = 1; \
! MEM_SCALAR_P (RTX) = 0; \
! } \
! else \
! { \
! MEM_IN_STRUCT_P (RTX) = 0; \
! MEM_SCALAR_P (RTX) = 1; \
! } \
! } while (0)
/* For a MEM rtx, the alias set. If 0, this MEM is not in any alias
set, and may alias anything. Otherwise, the MEM can only alias
Index: simplify-rtx.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/simplify-rtx.c,v
retrieving revision 1.15
diff -c -p -r1.15 simplify-rtx.c
*** simplify-rtx.c 2000/05/04 13:49:49 1.15
--- simplify-rtx.c 2000/05/04 20:47:41
*************** simplify_ternary_operation (code, mode,
*** 1905,1911 ****
&& GET_CODE (op1) == CONST_INT
&& GET_CODE (op2) == CONST_INT
&& INTVAL (op1) + INTVAL (op2) <= GET_MODE_BITSIZE (op0_mode)
! && width <= HOST_BITS_PER_WIDE_INT)
{
/* Extracting a bit-field from a constant */
HOST_WIDE_INT val = INTVAL (op0);
--- 1905,1911 ----
&& GET_CODE (op1) == CONST_INT
&& GET_CODE (op2) == CONST_INT
&& INTVAL (op1) + INTVAL (op2) <= GET_MODE_BITSIZE (op0_mode)
! && width <= (unsigned) HOST_BITS_PER_WIDE_INT)
{
/* Extracting a bit-field from a constant */
HOST_WIDE_INT val = INTVAL (op0);
Index: stor-layout.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/stor-layout.c,v
retrieving revision 1.70
diff -c -p -r1.70 stor-layout.c
*** stor-layout.c 2000/05/04 17:58:40 1.70
--- stor-layout.c 2000/05/04 20:47:48
*************** place_field (rli, field)
*** 667,673 ****
/* Some targets (i.e. VMS) limit struct field alignment
to a lower boundary than alignment of variables. */
#ifdef BIGGEST_FIELD_ALIGNMENT
! desired_align = MIN (desired_align, BIGGEST_FIELD_ALIGNMENT);
#endif
#ifdef ADJUST_FIELD_ALIGN
desired_align = ADJUST_FIELD_ALIGN (field, desired_align);
--- 667,673 ----
/* Some targets (i.e. VMS) limit struct field alignment
to a lower boundary than alignment of variables. */
#ifdef BIGGEST_FIELD_ALIGNMENT
! desired_align = MIN (desired_align, (unsigned) BIGGEST_FIELD_ALIGNMENT);
#endif
#ifdef ADJUST_FIELD_ALIGN
desired_align = ADJUST_FIELD_ALIGN (field, desired_align);
Index: tree.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tree.c,v
retrieving revision 1.141
diff -c -p -r1.141 tree.c
*** tree.c 2000/05/04 00:36:20 1.141
--- tree.c 2000/05/04 20:47:51
*************** set_identifier_size (size)
*** 1386,1392 ****
tree
build_int_2_wide (low, hi)
! HOST_WIDE_INT low, hi;
{
register tree t = make_node (INTEGER_CST);
--- 1386,1393 ----
tree
build_int_2_wide (low, hi)
! unsigned HOST_WIDE_INT low;
! HOST_WIDE_INT hi;
{
register tree t = make_node (INTEGER_CST);
*************** tree_int_cst_msb (t)
*** 4334,4340 ****
{
register int prec;
HOST_WIDE_INT h;
! HOST_WIDE_INT l;
/* Note that using TYPE_PRECISION here is wrong. We care about the
actual bits, not the (arbitrary) range of the type. */
--- 4335,4341 ----
{
register int prec;
HOST_WIDE_INT h;
! unsigned HOST_WIDE_INT l;
/* Note that using TYPE_PRECISION here is wrong. We care about the
actual bits, not the (arbitrary) range of the type. */
Index: tree.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tree.h,v
retrieving revision 1.167
diff -c -p -r1.167 tree.h
*** tree.h 2000/05/04 17:58:40 1.167
--- tree.h 2000/05/04 20:47:54
*************** extern tree maybe_get_identifier PARAMS
*** 1824,1836 ****
/* Construct various types of nodes. */
#define build_int_2(LO,HI) \
! build_int_2_wide ((HOST_WIDE_INT) (LO), (HOST_WIDE_INT) (HI))
extern tree build PARAMS ((enum tree_code, tree, ...));
extern tree build_nt PARAMS ((enum tree_code, ...));
extern tree build_parse_node PARAMS ((enum tree_code, ...));
! extern tree build_int_2_wide PARAMS ((HOST_WIDE_INT, HOST_WIDE_INT));
extern tree build_real PARAMS ((tree, REAL_VALUE_TYPE));
extern tree build_real_from_int_cst PARAMS ((tree, tree));
extern tree build_complex PARAMS ((tree, tree, tree));
--- 1824,1836 ----
/* Construct various types of nodes. */
#define build_int_2(LO,HI) \
! build_int_2_wide ((unsigned HOST_WIDE_INT) (LO), (HOST_WIDE_INT) (HI))
extern tree build PARAMS ((enum tree_code, tree, ...));
extern tree build_nt PARAMS ((enum tree_code, ...));
extern tree build_parse_node PARAMS ((enum tree_code, ...));
! extern tree build_int_2_wide PARAMS ((unsigned HOST_WIDE_INT, HOST_WIDE_INT));
extern tree build_real PARAMS ((tree, REAL_VALUE_TYPE));
extern tree build_real_from_int_cst PARAMS ((tree, tree));
extern tree build_complex PARAMS ((tree, tree, tree));
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/varasm.c,v
retrieving revision 1.114
diff -c -p -r1.114 varasm.c
*** varasm.c 2000/05/03 18:06:26 1.114
--- varasm.c 2000/05/04 20:47:57
*************** compare_constant_1 (exp, p)
*** 2563,2570 ****
int xlen = len = int_size_in_bytes (TREE_TYPE (exp));
unsigned char *tmp = (unsigned char *) alloca (len);
! get_set_constructor_bytes (exp, (unsigned char *) tmp, len);
! strp = tmp;
if (bcmp ((char *) &xlen, p, sizeof xlen))
return 0;
--- 2563,2570 ----
int xlen = len = int_size_in_bytes (TREE_TYPE (exp));
unsigned char *tmp = (unsigned char *) alloca (len);
! get_set_constructor_bytes (exp, tmp, len);
! strp = (char *) tmp;
if (bcmp ((char *) &xlen, p, sizeof xlen))
return 0;