This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
more warning patches, part 2/3
- To: egcs-patches at cygnus dot com
- Subject: more warning patches, part 2/3
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Tue, 13 Oct 1998 22:02:31 -0400 (EDT)
More warning patches. This is part 2/3. Okay to install?
--Kaveh
(PS: Jeff, this set also includes the conditional ATTRIBUTE_UNUSED
hacks. I'll remove them before final checkin.)
Tue Oct 13 18:32:19 1998 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* gcc.c (translate_options): Move variables `j' and `k' into the
scope in which they are used. Change their types to `size_t'.
(set_spec): Cast the argument of ctype macro to `unsigned char'.
(read_specs): Likewise.
(process_command): Cat `sizeof' to (int) when comparing against one.
(do_spec_1): Cast the argument of ctype macro to `unsigned char'.
(handle_braces): Cast both sides of `==' expression to `long' to
ensure sign matching.
(main): Cast variable `i' to `int' when comparing against one.
* gcov-io.h (__fetch_long): Change type of parameter `bytes' from
int to size_t. Cast variable `i' to size_t when comparing against
one.
* genattrtab.c (convert_set_attr_alternative): Remove unused
parameter `insn_code'. All callers changed.
(convert_set_attr): Likewise.
* genrecog.c (add_to_sequence): Cast result of XVECLEN() macro to
size_t when comparing against one. Likewise for variable `len'.
* global.c (global_alloc): Cast variable `max_regno' to size_t
when comparing against one. Likewise for variable `max_allocno'.
* jump.c (sets_cc0_p): Mark parameter `x' with ATTRIBUTE_UNUSED.
* local-alloc.c (validate_equiv_mem_from_store): Mark parameter
`set' with ATTRIBUTE_UNUSED.
(find_free_reg): Cast `sizeof' expression to (int) when comparing
against one.
* loop.c (count_loop_regs_set): Remove unused variable `dest'.
(strength_reduce): Mark parameter `bct_p' with ATTRIBUTE_UNUSED.
(get_condition): Cast variable `const_val' to `unsigned
HOST_WIDE_INT' when comparing against one. Cast unsigned
expression to HOST_WIDE_INT when comparing against one.
(insert_loop_mem): Mark parameter `data' with ATTRIBUTE_UNUSED.
(load_mems_and_recount_loop_regs_set): Cast variable `nregs' to
`unsigned' when comparing against one.
diff -rup orig/egcs-CVS19981012/gcc/gcc.c egcs-CVS19981012/gcc/gcc.c
--- orig/egcs-CVS19981012/gcc/gcc.c Tue Oct 13 17:38:00 1998
+++ egcs-CVS19981012/gcc/gcc.c Tue Oct 13 13:20:56 1998
@@ -930,7 +930,7 @@ translate_options (argcp, argvp)
int *argcp;
char ***argvp;
{
- int i, j, k;
+ int i;
int argc = *argcp;
char **argv = *argvp;
char **newv = (char **) xmalloc ((argc + 2) * 2 * sizeof (char *));
@@ -944,6 +944,7 @@ translate_options (argcp, argvp)
/* Translate -- options. */
if (argv[i][0] == '-' && argv[i][1] == '-')
{
+ size_t j;
/* Find a mapping that applies to this option. */
for (j = 0; j < sizeof (option_map) / sizeof (option_map[0]); j++)
{
@@ -961,6 +962,7 @@ translate_options (argcp, argvp)
if (arglen < optlen)
{
+ size_t k;
for (k = j + 1;
k < sizeof (option_map) / sizeof (option_map[0]);
k++)
@@ -1267,7 +1269,7 @@ set_spec (name, spec)
}
old_spec = *(sl->ptr_spec);
- *(sl->ptr_spec) = ((spec[0] == '+' && ISSPACE (spec[1]))
+ *(sl->ptr_spec) = ((spec[0] == '+' && ISSPACE ((unsigned char)spec[1]))
? concat (old_spec, spec + 1, NULL_PTR)
: save_string (spec, strlen (spec)));
@@ -1566,12 +1568,12 @@ read_specs (filename, main_p)
while (*p1 == ' ' || *p1 == '\t')
p1++;
- if (! ISALPHA (*p1))
+ if (! ISALPHA ((unsigned char)*p1))
fatal ("specs %%rename syntax malformed after %d characters",
p1 - buffer);
p2 = p1;
- while (*p2 && !ISSPACE (*p2))
+ while (*p2 && !ISSPACE ((unsigned char)*p2))
p2++;
if (*p2 != ' ' && *p2 != '\t')
@@ -1583,13 +1585,13 @@ read_specs (filename, main_p)
while (*p2 == ' ' || *p2 == '\t')
p2++;
- if (! ISALPHA (*p2))
+ if (! ISALPHA ((unsigned char)*p2))
fatal ("specs %%rename syntax malformed after %d characters",
p2 - buffer);
/* Get new spec name */
p3 = p2;
- while (*p3 && !ISSPACE (*p3))
+ while (*p3 && !ISSPACE ((unsigned char)*p3))
p3++;
if (p3 != p-1)
@@ -2606,7 +2608,7 @@ process_command (argc, argv)
if (gcc_exec_prefix)
{
int len = strlen (gcc_exec_prefix);
- if (len > sizeof ("/lib/gcc-lib/")-1
+ if (len > (int) sizeof ("/lib/gcc-lib/")-1
&& (gcc_exec_prefix[len-1] == '/'
|| gcc_exec_prefix[len-1] == DIR_SEPARATOR))
{
@@ -3664,7 +3666,7 @@ do_spec_1 (spec, inswitch, soft_matched_
if (p[0] == '%' && p[1] == 'O')
{
/* We don't support extra suffix characters after %O. */
- if (*p == '.' || ISALPHA (*p))
+ if (*p == '.' || ISALPHA ((unsigned char)*p))
abort ();
suffix = OBJECT_SUFFIX;
suffix_length = strlen (OBJECT_SUFFIX);
@@ -3672,7 +3674,7 @@ do_spec_1 (spec, inswitch, soft_matched_
}
else
{
- while (*p == '.' || ISALPHA (*p))
+ while (*p == '.' || ISALPHA ((unsigned char)*p))
p++;
suffix_length = p - suffix;
}
@@ -3960,7 +3962,8 @@ do_spec_1 (spec, inswitch, soft_matched_
*x++ = *y++;
if (*y != '_'
- || (*(y+1) != '_' && ! ISUPPER (*(y+1))))
+ || (*(y+1) != '_'
+ && ! ISUPPER ((unsigned char)*(y+1))))
{
/* Stick __ at front of macro name. */
*x++ = '_';
@@ -4002,7 +4005,8 @@ do_spec_1 (spec, inswitch, soft_matched_
y += 2;
if (*y != '_'
- || (*(y+1) != '_' && ! ISUPPER (*(y+1))))
+ || (*(y+1) != '_'
+ && ! ISUPPER ((unsigned char)*(y+1))))
{
/* Stick -D__ at front of macro name. */
*x++ = '-';
@@ -4304,7 +4308,7 @@ next_member:
if (suffix)
{
int found = (input_suffix != 0
- && strlen (input_suffix) == p - filter
+ && (long) strlen (input_suffix) == (long)(p - filter)
&& strncmp (input_suffix, filter, p - filter) == 0);
if (body[0] == '}')
@@ -4748,7 +4752,7 @@ main (argc, argv)
sizeof ("COLLECT_GCC_OPTIONS=")-1);
first_time = TRUE;
- for (i = 0; i < n_switches; i++)
+ for (i = 0; (int)i < n_switches; i++)
{
char **args;
char *p, *q;
@@ -4919,7 +4923,7 @@ main (argc, argv)
/* Warn about any switches that no pass was interested in. */
- for (i = 0; i < n_switches; i++)
+ for (i = 0; (int)i < n_switches; i++)
if (! switches[i].valid)
error ("unrecognized option `-%s'", switches[i].part1);
@@ -5018,7 +5022,7 @@ main (argc, argv)
explicit_link_files = xmalloc (n_infiles);
bzero (explicit_link_files, n_infiles);
- for (i = 0; i < n_infiles; i++)
+ for (i = 0; (int)i < n_infiles; i++)
{
register struct compiler *cp = 0;
int this_file_error = 0;
@@ -5149,7 +5153,7 @@ main (argc, argv)
complain about input files to be given to the linker. */
if (! linker_was_run && error_count == 0)
- for (i = 0; i < n_infiles; i++)
+ for (i = 0; (int)i < n_infiles; i++)
if (explicit_link_files[i])
error ("%s: linker input file unused since linking not done",
outfiles[i]);
diff -rup orig/egcs-CVS19981012/gcc/gcov-io.h egcs-CVS19981012/gcc/gcov-io.h
--- orig/egcs-CVS19981012/gcc/gcov-io.h Mon Oct 12 21:08:46 1998
+++ egcs-CVS19981012/gcc/gcov-io.h Tue Oct 13 12:02:27 1998
@@ -24,7 +24,7 @@ Boston, MA 02111-1307, USA. */
#include <stdio.h>
#include <sys/types.h>
-static int __fetch_long PROTO ((long *, char *, int));
+static int __fetch_long PROTO ((long *, char *, size_t));
static int __store_long PROTO ((long, char *, size_t));
static int __read_long PROTO ((long *, FILE *, size_t));
static int __write_long PROTO ((long, FILE *, size_t));
@@ -74,17 +74,17 @@ static int
__fetch_long (dest, source, bytes)
long *dest;
char *source;
- int bytes;
+ size_t bytes;
{
long value = 0;
int i;
- for (i = bytes - 1; i > (sizeof (*dest) - 1); i--)
- if (source[i] & (i == (bytes - 1) ? 127 : 255 ))
+ for (i = bytes - 1; (size_t) i > (sizeof (*dest) - 1); i--)
+ if (source[i] & ((size_t) i == (bytes - 1) ? 127 : 255 ))
return 1;
for (; i >= 0; i--)
- value = value * 256 + (source[i] & (i == (bytes - 1) ? 127 : 255));
+ value = value * 256 + (source[i] & ((size_t)i == (bytes - 1) ? 127 : 255));
if ((source[bytes - 1] & 128) && (value > 0))
value = - value;
diff -rup orig/egcs-CVS19981012/gcc/genattrtab.c egcs-CVS19981012/gcc/genattrtab.c
--- orig/egcs-CVS19981012/gcc/genattrtab.c Tue Oct 13 17:38:00 1998
+++ egcs-CVS19981012/gcc/genattrtab.c Tue Oct 13 12:06:03 1998
@@ -369,8 +369,8 @@ static char *attr_printf PVPROTO((int, c
static char *attr_string PROTO((char *, int));
static rtx check_attr_test PROTO((rtx, int));
static rtx check_attr_value PROTO((rtx, struct attr_desc *));
-static rtx convert_set_attr_alternative PROTO((rtx, int, int, int));
-static rtx convert_set_attr PROTO((rtx, int, int, int));
+static rtx convert_set_attr_alternative PROTO((rtx, int, int));
+static rtx convert_set_attr PROTO((rtx, int, int));
static void check_defs PROTO((void));
#if 0
static rtx convert_const_symbol_ref PROTO((rtx, struct attr_desc *));
@@ -1167,10 +1167,10 @@ check_attr_value (exp, attr)
It becomes a COND with each test being (eq_attr "alternative "n") */
static rtx
-convert_set_attr_alternative (exp, num_alt, insn_code, insn_index)
+convert_set_attr_alternative (exp, num_alt, insn_index)
rtx exp;
int num_alt;
- int insn_code, insn_index;
+ int insn_index;
{
rtx condexp;
int i;
@@ -1208,10 +1208,10 @@ convert_set_attr_alternative (exp, num_a
list of values is given, convert to SET_ATTR_ALTERNATIVE first. */
static rtx
-convert_set_attr (exp, num_alt, insn_code, insn_index)
+convert_set_attr (exp, num_alt, insn_index)
rtx exp;
int num_alt;
- int insn_code, insn_index;
+ int insn_index;
{
rtx newexp;
char *name_ptr;
@@ -1235,7 +1235,7 @@ convert_set_attr (exp, num_alt, insn_cod
while ((p = next_comma_elt (&name_ptr)) != NULL)
XVECEXP (newexp, 1, n++) = attr_rtx (CONST_STRING, p);
- return convert_set_attr_alternative (newexp, num_alt, insn_code, insn_index);
+ return convert_set_attr_alternative (newexp, num_alt, insn_index);
}
/* Scan all definitions, checking for validity. Also, convert any SET_ATTR
@@ -1268,13 +1268,12 @@ check_defs ()
case SET_ATTR_ALTERNATIVE:
value = convert_set_attr_alternative (value,
id->num_alternatives,
- id->insn_code,
id->insn_index);
break;
case SET_ATTR:
value = convert_set_attr (value, id->num_alternatives,
- id->insn_code, id->insn_index);
+ id->insn_index);
break;
default:
diff -rup orig/egcs-CVS19981012/gcc/genrecog.c egcs-CVS19981012/gcc/genrecog.c
--- orig/egcs-CVS19981012/gcc/genrecog.c Tue Oct 13 17:38:01 1998
+++ egcs-CVS19981012/gcc/genrecog.c Tue Oct 13 11:54:38 1998
@@ -417,7 +417,7 @@ add_to_sequence (pattern, last, position
if (code == MATCH_OPERATOR || code == MATCH_PARALLEL)
{
- for (i = 0; i < XVECLEN (pattern, 2); i++)
+ for (i = 0; i < (size_t) XVECLEN (pattern, 2); i++)
{
newpos[depth] = i + (code == MATCH_OPERATOR ? '0': 'a');
new = add_to_sequence (XVECEXP (pattern, 2, i),
@@ -432,7 +432,7 @@ add_to_sequence (pattern, last, position
new->dupno = XINT (pattern, 0);
new->code = UNKNOWN;
new->tests = 0;
- for (i = 0; i < XVECLEN (pattern, 1); i++)
+ for (i = 0; i < (size_t) XVECLEN (pattern, 1); i++)
{
newpos[depth] = i + '0';
new = add_to_sequence (XVECEXP (pattern, 1, i),
@@ -529,7 +529,7 @@ add_to_sequence (pattern, last, position
fmt = GET_RTX_FORMAT (code);
len = GET_RTX_LENGTH (code);
- for (i = 0; i < len; i++)
+ for (i = 0; i < (size_t) len; i++)
{
newpos[depth] = '0' + i;
if (fmt[i] == 'e' || fmt[i] == 'u')
diff -rup orig/egcs-CVS19981012/gcc/global.c egcs-CVS19981012/gcc/global.c
--- orig/egcs-CVS19981012/gcc/global.c Mon Oct 12 21:09:16 1998
+++ egcs-CVS19981012/gcc/global.c Tue Oct 13 10:53:20 1998
@@ -363,7 +363,7 @@ global_alloc (file)
SET_HARD_REG_BIT (regs_used_so_far, i);
#endif
- for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
+ for (i = FIRST_PSEUDO_REGISTER; i < (size_t) max_regno; i++)
if (reg_renumber[i] >= 0)
SET_HARD_REG_BIT (regs_used_so_far, reg_renumber[i]);
@@ -389,7 +389,7 @@ global_alloc (file)
reg_may_share[r2] = r1;
}
- for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
+ for (i = FIRST_PSEUDO_REGISTER; i < (size_t) max_regno; i++)
/* Note that reg_live_length[i] < 0 indicates a "constant" reg
that we are supposed to refrain from putting in a hard reg.
-2 means do make an allocno but don't allocate it. */
@@ -419,7 +419,7 @@ global_alloc (file)
bzero ((char *) allocno_n_refs, max_allocno * sizeof (int));
bzero ((char *) allocno_live_length, max_allocno * sizeof (int));
- for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
+ for (i = FIRST_PSEUDO_REGISTER; i < (size_t) max_regno; i++)
if (reg_allocno[i] >= 0)
{
int allocno = reg_allocno[i];
@@ -436,7 +436,7 @@ global_alloc (file)
override it. */
bzero ((char *) local_reg_live_length, sizeof local_reg_live_length);
bzero ((char *) local_reg_n_refs, sizeof local_reg_n_refs);
- for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++)
+ for (i = FIRST_PSEUDO_REGISTER; i < (size_t) max_regno; i++)
if (reg_renumber[i] >= 0)
{
int regno = reg_renumber[i];
@@ -509,7 +509,7 @@ global_alloc (file)
So in either case, we can ignore the conflict. Likewise for
preferences. */
- for (i = 0; i < max_allocno; i++)
+ for (i = 0; i < (size_t) max_allocno; i++)
{
AND_COMPL_HARD_REG_SET (hard_reg_conflicts[i], eliminable_regset);
AND_COMPL_HARD_REG_SET (hard_reg_copy_preferences[i],
@@ -524,7 +524,7 @@ global_alloc (file)
/* Determine the order to allocate the remaining pseudo registers. */
allocno_order = (int *) alloca (max_allocno * sizeof (int));
- for (i = 0; i < max_allocno; i++)
+ for (i = 0; i < (size_t) max_allocno; i++)
allocno_order[i] = i;
/* Default the size to 1, since allocno_compare uses it to divide by.
@@ -534,7 +534,7 @@ global_alloc (file)
allocate it. So avoid the divide-by-zero and set it to a low
priority. */
- for (i = 0; i < max_allocno; i++)
+ for (i = 0; i < (size_t) max_allocno; i++)
{
if (allocno_size[i] == 0)
allocno_size[i] = 1;
@@ -552,7 +552,7 @@ global_alloc (file)
/* Try allocating them, one by one, in that order,
except for parameters marked with reg_live_length[regno] == -2. */
- for (i = 0; i < max_allocno; i++)
+ for (i = 0; i < (size_t) max_allocno; i++)
if (reg_renumber[allocno_reg[allocno_order[i]]] < 0
&& REG_LIVE_LENGTH (allocno_reg[allocno_order[i]]) >= 0)
{
diff -rup orig/egcs-CVS19981012/gcc/jump.c egcs-CVS19981012/gcc/jump.c
--- orig/egcs-CVS19981012/gcc/jump.c Mon Oct 12 21:09:19 1998
+++ egcs-CVS19981012/gcc/jump.c Tue Oct 13 09:59:58 1998
@@ -3328,7 +3328,11 @@ condjump_in_parallel_p (insn)
int
sets_cc0_p (x)
- rtx x;
+ rtx x
+#ifndef HAVE_cc0
+ ATTRIBUTE_UNUSED
+#endif
+ ;
{
#ifdef HAVE_cc0
if (GET_CODE (x) == SET && SET_DEST (x) == cc0_rtx)
diff -rup orig/egcs-CVS19981012/gcc/local-alloc.c egcs-CVS19981012/gcc/local-alloc.c
--- orig/egcs-CVS19981012/gcc/local-alloc.c Mon Oct 12 21:09:19 1998
+++ egcs-CVS19981012/gcc/local-alloc.c Tue Oct 13 10:46:32 1998
@@ -420,7 +420,7 @@ static int equiv_mem_modified;
static void
validate_equiv_mem_from_store (dest, set)
rtx dest;
- rtx set;
+ rtx set ATTRIBUTE_UNUSED;
{
if ((GET_CODE (dest) == REG
&& reg_overlap_mentioned_p (dest, equiv_mem))
@@ -1858,7 +1858,7 @@ find_free_reg (class, mode, qty, accept_
This is true of any register that can be eliminated. */
#ifdef ELIMINABLE_REGS
- for (i = 0; i < sizeof eliminables / sizeof eliminables[0]; i++)
+ for (i = 0; i < (int)(sizeof eliminables / sizeof eliminables[0]); i++)
SET_HARD_REG_BIT (used, eliminables[i].from);
#if FRAME_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
/* If FRAME_POINTER_REGNUM is not a real register, then protect the one
diff -rup orig/egcs-CVS19981012/gcc/loop.c egcs-CVS19981012/gcc/loop.c
--- orig/egcs-CVS19981012/gcc/loop.c Mon Oct 12 21:09:20 1998
+++ egcs-CVS19981012/gcc/loop.c Tue Oct 13 10:16:17 1998
@@ -3387,7 +3387,6 @@ count_loop_regs_set (from, to, may_not_m
register rtx *last_set = (rtx *) alloca (nregs * sizeof (rtx));
register rtx insn;
register int count = 0;
- register rtx dest;
bzero ((char *) last_set, nregs * sizeof (rtx));
for (insn = from; insn != to; insn = NEXT_INSN (insn))
@@ -3544,7 +3543,11 @@ strength_reduce (scan_start, end, loop_t
int insn_count;
rtx loop_start;
rtx loop_end;
- int unroll_p, bct_p;
+ int unroll_p, bct_p
+#ifndef HAVE_decrement_and_branch_on_count
+ ATTRIBUTE_UNUSED
+#endif
+ ;
{
rtx p;
rtx set;
@@ -7871,14 +7874,14 @@ get_condition (jump, earliest)
switch (code)
{
case LE:
- if (const_val != max_val >> 1)
+ if ((unsigned HOST_WIDE_INT) const_val != max_val >> 1)
code = LT, op1 = GEN_INT (const_val + 1);
break;
/* When cross-compiling, const_val might be sign-extended from
BITS_PER_WORD to HOST_BITS_PER_WIDE_INT */
case GE:
- if ((const_val & max_val)
+ if ((HOST_WIDE_INT) (const_val & max_val)
!= (((HOST_WIDE_INT) 1
<< (GET_MODE_BITSIZE (GET_MODE (op0)) - 1))))
code = GT, op1 = GEN_INT (const_val - 1);
@@ -8249,7 +8252,7 @@ indirect_jump_in_function_p (start)
static int
insert_loop_mem (mem, data)
rtx *mem;
- void *data;
+ void *data ATTRIBUTE_UNUSED;
{
int i;
rtx m = *mem;
@@ -8339,7 +8342,7 @@ load_mems_and_recount_loop_regs_set (sca
old_nregs = nregs;
nregs = max_reg_num ();
- if (nregs > n_times_set->num_elements)
+ if ((unsigned) nregs > n_times_set->num_elements)
{
/* Grow all the arrays. */
VARRAY_GROW (n_times_set, nregs);