optabs.c (init_optabs): Initialize fixtab...

* optabs.c (init_optabs): Initialize fixtab, fixtrunctab, floattab,
	and extendtab within their proper array boundaries.
	* emit-rtl.c (init_emit_once): Pass `const_tiny_rtx' with bounds
	for the entire array.

	* config/arm/arm.c (arm_override_options): Use ARRAY_SIZE.
	* config/alpha/alpha.c (alpha_lookup_xfloating_lib_func): Likewise.
	* config/avr/avr.c (order_regs_for_local_alloc): Likewise.
	* config/fr30/fr30.c (fr30_print_operand): Likewise.
	* config/i386/dgux.c (output_options): Likewise.
	* config/i386/dgux.h (ASM_FILE_START): Likewise.
	* config/m88k/m88k.c (output_options): Likewise.
	* config/m88k/m88k.h (ASM_FILE_START): Likewise.
	* config/mcore/mcore.c (mcore_output_inline_const_forced,
	layout_mcore_frame, handle_structs_in_regs): Likewise.
	* config/mips/mips.c (output_block_move): Likewise.
	* config/rs6000/rs6000.c (rs6000_override_options,
	rs6000_file_start): Likewise.
	* config/sparc/sparc.c (sparc_add_gc_roots): Likewise.
	* fixinc/fixfixes.c (FIX_TABLE_CT): Likewise.
	* fixinc/fixtests.c (TEST_TABLE_CT): Likewise.
	* builtins.c (expand_builtin_setjmp): Likewise.
	* expr.c (safe_from_p): Likewise.
	* flow.c (life_analysis): Likewise.
	* fold-const.c (size_int_type_wide): Likewise.
	* gcc.c (translate_options, init_spec, set_spec, main): Likewise.
	* genattrtab.c (make_length_attrs): Likewise.
	* genopinit.c (gen_insn): Likewise.
	* genrecog.c (NUM_KNOWN_PREDS, NUM_SPECIAL_MODE_PREDS): Likewise.
	* global.c (global_alloc): Likewise.
	* local-alloc.c (find_free_reg): Likewise.
	* mips-tdump.c (print_symbol): Likewise.
	* mips-tfile.c (parse_def, parse_input): Likewise.
	* reload1.c (NUM_ELIMINABLE_REGS): Likewise.
	* stmt.c (expand_nl_goto_receiver): Likewise.
	* stor-layout.c (set_sizetype): Likewise.
	* varasm.c (decode_reg_name): Likewise.
	* toplev.c (decode_f_option, decode_W_option,
	set_target_switch, print_switch_values): Likewise.
	(NUM_ELEM): Remove macro.
	(display_help, main): s/NUM_ELEM/ARRAY_SIZE/

From-SVN: r35949
This commit is contained in:
Greg McGary 2000-08-24 20:31:35 +00:00 committed by Greg McGary
parent 2f26c11dbb
commit b6a1cbaeb1
33 changed files with 134 additions and 106 deletions

View File

@ -1,3 +1,47 @@
2000-08-24 Greg McGary <greg@mcgary.org>
* optabs.c (init_optabs): Initialize fixtab, fixtrunctab, floattab,
and extendtab within their proper array boundaries.
* emit-rtl.c (init_emit_once): Pass `const_tiny_rtx' with bounds
for the entire array.
* config/arm/arm.c (arm_override_options): Use ARRAY_SIZE.
* config/alpha/alpha.c (alpha_lookup_xfloating_lib_func): Likewise.
* config/avr/avr.c (order_regs_for_local_alloc): Likewise.
* config/fr30/fr30.c (fr30_print_operand): Likewise.
* config/i386/dgux.c (output_options): Likewise.
* config/i386/dgux.h (ASM_FILE_START): Likewise.
* config/m88k/m88k.c (output_options): Likewise.
* config/m88k/m88k.h (ASM_FILE_START): Likewise.
* config/mcore/mcore.c (mcore_output_inline_const_forced,
layout_mcore_frame, handle_structs_in_regs): Likewise.
* config/mips/mips.c (output_block_move): Likewise.
* config/rs6000/rs6000.c (rs6000_override_options,
rs6000_file_start): Likewise.
* config/sparc/sparc.c (sparc_add_gc_roots): Likewise.
* fixinc/fixfixes.c (FIX_TABLE_CT): Likewise.
* fixinc/fixtests.c (TEST_TABLE_CT): Likewise.
* builtins.c (expand_builtin_setjmp): Likewise.
* expr.c (safe_from_p): Likewise.
* flow.c (life_analysis): Likewise.
* fold-const.c (size_int_type_wide): Likewise.
* gcc.c (translate_options, init_spec, set_spec, main): Likewise.
* genattrtab.c (make_length_attrs): Likewise.
* genopinit.c (gen_insn): Likewise.
* genrecog.c (NUM_KNOWN_PREDS, NUM_SPECIAL_MODE_PREDS): Likewise.
* global.c (global_alloc): Likewise.
* local-alloc.c (find_free_reg): Likewise.
* mips-tdump.c (print_symbol): Likewise.
* mips-tfile.c (parse_def, parse_input): Likewise.
* reload1.c (NUM_ELIMINABLE_REGS): Likewise.
* stmt.c (expand_nl_goto_receiver): Likewise.
* stor-layout.c (set_sizetype): Likewise.
* varasm.c (decode_reg_name): Likewise.
* toplev.c (decode_f_option, decode_W_option,
set_target_switch, print_switch_values): Likewise.
(NUM_ELEM): Remove macro.
(display_help, main): s/NUM_ELEM/ARRAY_SIZE/
2000-08-24 Greg McGary <greg@mcgary.org> 2000-08-24 Greg McGary <greg@mcgary.org>
* tree.h (enum tree_index): New member `TI_MAIN_IDENTIFIER'. * tree.h (enum tree_index): New member `TI_MAIN_IDENTIFIER'.

View File

@ -417,12 +417,12 @@ expand_builtin_setjmp (buf_addr, target, first_label, next_label)
size_t i; size_t i;
static struct elims {int from, to;} elim_regs[] = ELIMINABLE_REGS; static struct elims {int from, to;} elim_regs[] = ELIMINABLE_REGS;
for (i = 0; i < sizeof elim_regs / sizeof elim_regs[0]; i++) for (i = 0; i < ARRAY_SIZE (elim_regs); i++)
if (elim_regs[i].from == ARG_POINTER_REGNUM if (elim_regs[i].from == ARG_POINTER_REGNUM
&& elim_regs[i].to == HARD_FRAME_POINTER_REGNUM) && elim_regs[i].to == HARD_FRAME_POINTER_REGNUM)
break; break;
if (i == sizeof elim_regs / sizeof elim_regs [0]) if (i == ARRAY_SIZE (elim_regs))
#endif #endif
{ {
/* Now restore our arg pointer from the address at which it /* Now restore our arg pointer from the address at which it

View File

@ -1988,7 +1988,7 @@ alpha_lookup_xfloating_lib_func (code)
}; };
const struct xfloating_op *ops; const struct xfloating_op *ops;
const long n = sizeof(osf_xfloating_ops) / sizeof(osf_xfloating_ops[0]); const long n = ARRAY_SIZE (osf_xfloating_ops);
long i; long i;
/* How irritating. Nothing to key off for the table. Hardcode /* How irritating. Nothing to key off for the table. Hardcode

View File

@ -317,7 +317,7 @@ arm_override_options ()
unsigned i; unsigned i;
/* Set up the flags based on the cpu/architecture selected by the user. */ /* Set up the flags based on the cpu/architecture selected by the user. */
for (i = sizeof (arm_select) / sizeof (arm_select[0]); i--;) for (i = ARRAY_SIZE (arm_select); i--;)
{ {
struct arm_cpu_select * ptr = arm_select + i; struct arm_cpu_select * ptr = arm_select + i;

View File

@ -575,7 +575,7 @@ fr30_print_operand (file, x, code)
switch (GET_CODE (x0)) switch (GET_CODE (x0))
{ {
case REG: case REG:
if ((unsigned) REGNO (x0) >= (sizeof (reg_names) / sizeof (reg_names[0]))) if ((unsigned) REGNO (x0) >= ARRAY_SIZE (reg_names))
abort (); abort ();
fprintf (file, "@%s", reg_names [REGNO (x0)]); fprintf (file, "@%s", reg_names [REGNO (x0)]);
break; break;

View File

@ -1,5 +1,5 @@
/* Subroutines for GNU compiler for Intel 80x86 running DG/ux /* Subroutines for GNU compiler for Intel 80x86 running DG/ux
Copyright (C) 1993, 1995, 1997, 1999 Free Software Foundation, Inc. Copyright (C) 1993, 1995, 1997, 1999, 2000 Free Software Foundation, Inc.
Currently maintained by (gcc@dg-rtp.dg.com) Currently maintained by (gcc@dg-rtp.dg.com)
This file is part of GNU CC. This file is part of GNU CC.
@ -90,7 +90,7 @@ output_options (file, f_options, f_len, W_options, W_len,
pos = output_option (file, sep, "-W", W_options[j].string, pos = output_option (file, sep, "-W", W_options[j].string,
indent, pos, max); indent, pos, max);
for (j = 0; j < sizeof m_options / sizeof m_options[0]; j++) for (j = 0; j < ARRAY_SIZE (m_options); j++)
if (m_options[j].name[0] != '\0' if (m_options[j].name[0] != '\0'
&& m_options[j].value > 0 && m_options[j].value > 0
&& ((m_options[j].value & target_flags) && ((m_options[j].value & target_flags)

View File

@ -27,7 +27,7 @@ Boston, MA 02111-1307, USA. */
#include "i386/sysv4.h" #include "i386/sysv4.h"
#ifndef VERSION_INFO2 #ifndef VERSION_INFO2
#define VERSION_INFO2 "$Revision: 1.9 $" #define VERSION_INFO2 "$Revision: 1.10 $"
#endif #endif
#ifndef VERSION_STRING #ifndef VERSION_STRING
@ -85,8 +85,8 @@ Boston, MA 02111-1307, USA. */
/* Override svr[34].h. */ /* Override svr[34].h. */
#undef ASM_FILE_START #undef ASM_FILE_START
#define ASM_FILE_START(FILE) \ #define ASM_FILE_START(FILE) \
output_file_start (FILE, f_options, sizeof f_options / sizeof f_options[0], \ output_file_start (FILE, f_options, ARRAY_SIZE (f_options), \
W_options, sizeof W_options / sizeof W_options[0]) W_options, ARRAY_SIZE (W_options))
/* ix86 abi specified type for wchar_t */ /* ix86 abi specified type for wchar_t */

View File

@ -1544,7 +1544,7 @@ output_options (file, f_options, f_len, W_options, W_len,
pos = output_option (file, sep, "-W", W_options[j].string, pos = output_option (file, sep, "-W", W_options[j].string,
indent, pos, max); indent, pos, max);
for (j = 0; j < (long) (sizeof m_options / sizeof m_options[0]); j++) for (j = 0; j < (long) ARRAY_SIZE (m_options); j++)
if (m_options[j].name[0] != '\0' if (m_options[j].name[0] != '\0'
&& m_options[j].value > 0 && m_options[j].value > 0
&& ((m_options[j].value & target_flags) && ((m_options[j].value & target_flags)

View File

@ -1818,9 +1818,9 @@ enum reg_class { NO_REGS, AP_REG, XRF_REGS, GENERAL_REGS, AGRF_REGS,
#define ASM_FILE_START(FILE) \ #define ASM_FILE_START(FILE) \
output_file_start (FILE, \ output_file_start (FILE, \
(struct m88k_lang_independent_options *) f_options, \ (struct m88k_lang_independent_options *) f_options, \
sizeof f_options / sizeof f_options[0], \ ARRAY_SIZE (f_options), \
(struct m88k_lang_independent_options *) W_options, \ (struct m88k_lang_independent_options *) W_options, \
sizeof W_options / sizeof W_options[0]) ARRAY_SIZE (W_options))
#undef ASM_FILE_END #undef ASM_FILE_END

View File

@ -1158,7 +1158,7 @@ mcore_output_inline_const_forced (insn, operands, mode)
if (mcore_const_ok_for_inline (value)) if (mcore_const_ok_for_inline (value))
return output_inline_const (SImode, operands); return output_inline_const (SImode, operands);
for (i = 0; (unsigned) i < sizeof (part) / sizeof (part[0]); i++) for (i = 0; (unsigned) i < ARRAY_SIZE (part); i++)
{ {
part[i].shift = 0; part[i].shift = 0;
part[i].low = (value & 0x1F); part[i].low = (value & 0x1F);
@ -1990,7 +1990,7 @@ layout_mcore_frame (infp)
(1) run fast, (1) run fast,
(2) reduce instruction space, or (2) reduce instruction space, or
(3) reduce stack space. */ (3) reduce stack space. */
for (i = 0; i < sizeof (infp->growth) / sizeof (infp->growth[0]); i++) for (i = 0; i < ARRAY_SIZE (infp->growth); i++)
infp->growth[i] = 0; infp->growth[i] = 0;
regarg = infp->reg_size + infp->arg_size; regarg = infp->reg_size + infp->arg_size;
@ -3139,7 +3139,7 @@ handle_structs_in_regs (mode, type, reg)
} }
/* We assume here that NPARM_REGS == 6. The assert checks this. */ /* We assume here that NPARM_REGS == 6. The assert checks this. */
assert (sizeof (arg_regs) / sizeof (arg_regs[0]) == 6); assert (ARRAY_SIZE (arg_regs) == 6);
rtvec = gen_rtvec (nregs, arg_regs[0], arg_regs[1], arg_regs[2], rtvec = gen_rtvec (nregs, arg_regs[0], arg_regs[1], arg_regs[2],
arg_regs[3], arg_regs[4], arg_regs[5]); arg_regs[3], arg_regs[4], arg_regs[5]);

View File

@ -3417,10 +3417,7 @@ output_block_move (insn, operands, num_regs, move_type)
/* ??? Detect a bug in GCC, where it can give us a register /* ??? Detect a bug in GCC, where it can give us a register
the same as one of the addressing registers and reduce the same as one of the addressing registers and reduce
the number of registers available. */ the number of registers available. */
for (i = 4; for (i = 4; i < last_operand && safe_regs < (int) ARRAY_SIZE (xoperands); i++)
i < last_operand
&& safe_regs < (int)(sizeof(xoperands) / sizeof(xoperands[0]));
i++)
if (! reg_mentioned_p (operands[i], operands[0]) if (! reg_mentioned_p (operands[i], operands[0])
&& ! reg_mentioned_p (operands[i], operands[1])) && ! reg_mentioned_p (operands[i], operands[1]))
xoperands[safe_regs++] = operands[i]; xoperands[safe_regs++] = operands[i];
@ -3515,8 +3512,8 @@ output_block_move (insn, operands, num_regs, move_type)
} }
} }
if (num_regs > (int)(sizeof (load_store) / sizeof (load_store[0]))) if (num_regs > (int) ARRAY_SIZE (load_store))
num_regs = sizeof (load_store) / sizeof (load_store[0]); num_regs = ARRAY_SIZE (load_store);
else if (num_regs < 1) else if (num_regs < 1)
abort_with_insn (insn, abort_with_insn (insn,

View File

@ -293,7 +293,7 @@ rs6000_override_options (default_cpu)
rs6000_select[0].string = default_cpu; rs6000_select[0].string = default_cpu;
rs6000_cpu = TARGET_POWERPC64 ? PROCESSOR_DEFAULT64 : PROCESSOR_DEFAULT; rs6000_cpu = TARGET_POWERPC64 ? PROCESSOR_DEFAULT64 : PROCESSOR_DEFAULT;
for (i = 0; i < sizeof (rs6000_select) / sizeof (rs6000_select[0]); i++) for (i = 0; i < ARRAY_SIZE (rs6000_select); i++)
{ {
ptr = &rs6000_select[i]; ptr = &rs6000_select[i];
if (ptr->string != (char *)0 && ptr->string[0] != '\0') if (ptr->string != (char *)0 && ptr->string[0] != '\0')
@ -433,7 +433,7 @@ rs6000_file_start (file, default_cpu)
sprintf (buffer, "\n%s rs6000/powerpc options:", ASM_COMMENT_START); sprintf (buffer, "\n%s rs6000/powerpc options:", ASM_COMMENT_START);
rs6000_select[0].string = default_cpu; rs6000_select[0].string = default_cpu;
for (i = 0; i < sizeof (rs6000_select) / sizeof (rs6000_select[0]); i++) for (i = 0; i < ARRAY_SIZE (rs6000_select); i++)
{ {
ptr = &rs6000_select[i]; ptr = &rs6000_select[i];
if (ptr->string != (char *)0 && ptr->string[0] != '\0') if (ptr->string != (char *)0 && ptr->string[0] != '\0')

View File

@ -8569,8 +8569,6 @@ sparc_add_gc_roots ()
ggc_add_rtx_root (&get_pc_symbol, 1); ggc_add_rtx_root (&get_pc_symbol, 1);
ggc_add_rtx_root (&sparc_addr_diff_list, 1); ggc_add_rtx_root (&sparc_addr_diff_list, 1);
ggc_add_rtx_root (&sparc_addr_list, 1); ggc_add_rtx_root (&sparc_addr_list, 1);
ggc_add_root (ultra_pipe_hist, ggc_add_root (ultra_pipe_hist, ARRAY_SIZE (ultra_pipe_hist),
sizeof (ultra_pipe_hist) / sizeof (ultra_pipe_hist[0]), sizeof (ultra_pipe_hist[0]), &mark_ultrasparc_pipeline_state);
sizeof (ultra_pipe_hist[0]),
&mark_ultrasparc_pipeline_state);
} }

View File

@ -4180,7 +4180,10 @@ init_emit_once (line_numbers)
if (GET_MODE_CLASS (mode) == MODE_CC) if (GET_MODE_CLASS (mode) == MODE_CC)
const_tiny_rtx[0][(int) mode] = const0_rtx; const_tiny_rtx[0][(int) mode] = const0_rtx;
ggc_add_rtx_root (&const_tiny_rtx[0][0], sizeof(const_tiny_rtx)/sizeof(rtx)); /* For bounded pointers, `&const_tiny_rtx[0][0]' is not the same as
`(rtx *) const_tiny_rtx'. The former has bounds that only cover
`const_tiny_rtx[0]', whereas the latter has bounds that cover all. */
ggc_add_rtx_root ((rtx *) const_tiny_rtx, sizeof const_tiny_rtx / sizeof (rtx));
ggc_add_rtx_root (&const_true_rtx, 1); ggc_add_rtx_root (&const_true_rtx, 1);
#ifdef RETURN_ADDRESS_POINTER_REGNUM #ifdef RETURN_ADDRESS_POINTER_REGNUM

View File

@ -5404,7 +5404,7 @@ safe_from_p (x, exp, top_p)
int rtn; int rtn;
save_expr_count = 0; save_expr_count = 0;
save_expr_size = sizeof (save_expr_trees) / sizeof (save_expr_trees[0]); save_expr_size = ARRAY_SIZE (save_expr_trees);
save_expr_rewritten = &save_expr_trees[0]; save_expr_rewritten = &save_expr_trees[0];
rtn = safe_from_p (x, exp, 1); rtn = safe_from_p (x, exp, 1);

View File

@ -706,7 +706,7 @@ apply_fix( p_fixd, filname )
#define _FT_(n,p) { n, p }, #define _FT_(n,p) { n, p },
static fix_entry_t fix_table[] = { FIXUP_TABLE { NULL, NULL }}; static fix_entry_t fix_table[] = { FIXUP_TABLE { NULL, NULL }};
#undef _FT_ #undef _FT_
#define FIX_TABLE_CT ((sizeof(fix_table)/sizeof(fix_table[0]))-1) #define FIX_TABLE_CT (ARRAY_SIZE (fix_table)-1)
tCC* fixname = p_fixd->patch_args[0]; tCC* fixname = p_fixd->patch_args[0];
char* buf; char* buf;

View File

@ -129,7 +129,7 @@ run_test( tname, fname, text )
#define _FT_(n,p) { n, p }, #define _FT_(n,p) { n, p },
static test_entry_t test_table[] = { FIX_TEST_TABLE { NULL, NULL }}; static test_entry_t test_table[] = { FIX_TEST_TABLE { NULL, NULL }};
#undef _FT_ #undef _FT_
#define TEST_TABLE_CT ((sizeof(test_table)/sizeof(test_table[0]))-1) #define TEST_TABLE_CT (ARRAY_SIZE (test_table)-1)
int ct = TEST_TABLE_CT; int ct = TEST_TABLE_CT;
test_entry_t* pte = test_table; test_entry_t* pte = test_table;

View File

@ -2624,7 +2624,7 @@ life_analysis (f, file, flags)
CLEAR_HARD_REG_SET (elim_reg_set); CLEAR_HARD_REG_SET (elim_reg_set);
#ifdef ELIMINABLE_REGS #ifdef ELIMINABLE_REGS
for (i = 0; i < (int) (sizeof eliminables / sizeof eliminables[0]); i++) for (i = 0; i < (int) ARRAY_SIZE (eliminables); i++)
SET_HARD_REG_BIT (elim_reg_set, eliminables[i].from); SET_HARD_REG_BIT (elim_reg_set, eliminables[i].from);
#else #else
SET_HARD_REG_BIT (elim_reg_set, FRAME_POINTER_REGNUM); SET_HARD_REG_BIT (elim_reg_set, FRAME_POINTER_REGNUM);

View File

@ -1870,7 +1870,7 @@ size_int_type_wide (number, type)
/* If this is a positive number that fits in the table we use to hold /* If this is a positive number that fits in the table we use to hold
cached entries, see if it is already in the table and put it there cached entries, see if it is already in the table and put it there
if not. */ if not. */
if (number >= 0 && number < (int) (sizeof size_table / sizeof size_table[0])) if (number >= 0 && number < (int) ARRAY_SIZE (size_table))
{ {
if (size_table[number] != 0) if (size_table[number] != 0)
for (t = size_table[number]; t != 0; t = TREE_CHAIN (t)) for (t = size_table[number]; t != 0; t = TREE_CHAIN (t))

View File

@ -880,7 +880,7 @@ translate_options (argcp, argvp)
{ {
size_t j; size_t j;
/* Find a mapping that applies to this option. */ /* Find a mapping that applies to this option. */
for (j = 0; j < sizeof (option_map) / sizeof (option_map[0]); j++) for (j = 0; j < ARRAY_SIZE (option_map); j++)
{ {
size_t optlen = strlen (option_map[j].name); size_t optlen = strlen (option_map[j].name);
size_t arglen = strlen (argv[i]); size_t arglen = strlen (argv[i]);
@ -897,9 +897,7 @@ translate_options (argcp, argvp)
if (arglen < optlen) if (arglen < optlen)
{ {
size_t k; size_t k;
for (k = j + 1; for (k = j + 1; k < ARRAY_SIZE (option_map); k++)
k < sizeof (option_map) / sizeof (option_map[0]);
k++)
if (strlen (option_map[k].name) >= arglen if (strlen (option_map[k].name) >= arglen
&& !strncmp (argv[i], option_map[k].name, arglen)) && !strncmp (argv[i], option_map[k].name, arglen))
{ {
@ -907,7 +905,7 @@ translate_options (argcp, argvp)
break; break;
} }
if (k != sizeof (option_map) / sizeof (option_map[0])) if (k != ARRAY_SIZE (option_map))
break; break;
} }
@ -1130,10 +1128,9 @@ init_spec ()
#ifdef EXTRA_SPECS #ifdef EXTRA_SPECS
extra_specs = (struct spec_list *) extra_specs = (struct spec_list *)
xcalloc (sizeof(struct spec_list), xcalloc (sizeof (struct spec_list), ARRAY_SIZE (extra_specs_1));
(sizeof(extra_specs_1)/sizeof(extra_specs_1[0])));
for (i = (sizeof(extra_specs_1) / sizeof(extra_specs_1[0])) - 1; i >= 0; i--) for (i = ARRAY_SIZE (extra_specs_1) - 1; i >= 0; i--)
{ {
sl = &extra_specs[i]; sl = &extra_specs[i];
sl->name = extra_specs_1[i].name; sl->name = extra_specs_1[i].name;
@ -1145,7 +1142,7 @@ init_spec ()
} }
#endif #endif
for (i = (sizeof (static_specs) / sizeof (static_specs[0])) - 1; i >= 0; i--) for (i = ARRAY_SIZE (static_specs) - 1; i >= 0; i--)
{ {
sl = &static_specs[i]; sl = &static_specs[i];
sl->next = next; sl->next = next;
@ -1174,8 +1171,7 @@ set_spec (name, spec)
if (!specs) if (!specs)
{ {
struct spec_list *next = (struct spec_list *)0; struct spec_list *next = (struct spec_list *)0;
for (i = (sizeof (static_specs) / sizeof (static_specs[0])) - 1; for (i = ARRAY_SIZE (static_specs) - 1; i >= 0; i--)
i >= 0; i--)
{ {
sl = &static_specs[i]; sl = &static_specs[i];
sl->next = next; sl->next = next;
@ -5170,9 +5166,7 @@ main (argc, argv)
multilib_exclusions = obstack_finish (&multilib_obstack); multilib_exclusions = obstack_finish (&multilib_obstack);
need_space = FALSE; need_space = FALSE;
for (i = 0; for (i = 0; i < ARRAY_SIZE (multilib_defaults_raw); i++)
i < sizeof (multilib_defaults_raw) / sizeof (multilib_defaults_raw[0]);
i++)
{ {
if (need_space) if (need_space)
obstack_1grow (&multilib_obstack, ' '); obstack_1grow (&multilib_obstack, ' ');

View File

@ -2491,7 +2491,7 @@ make_length_attrs ()
length_attr->is_special = 1; length_attr->is_special = 1;
/* Make each new attribute, in turn. */ /* Make each new attribute, in turn. */
for (i = 0; i < sizeof new_names / sizeof new_names[0]; i++) for (i = 0; i < ARRAY_SIZE (new_names); i++)
{ {
make_internal_attr (new_names[i], make_internal_attr (new_names[i],
substitute_address (length_attr->default_val->value, substitute_address (length_attr->default_val->value,

View File

@ -134,7 +134,7 @@ gen_insn (insn)
/* See if NAME matches one of the patterns we have for the optabs we know /* See if NAME matches one of the patterns we have for the optabs we know
about. */ about. */
for (pindex = 0; pindex < sizeof optabs / sizeof optabs[0]; pindex++) for (pindex = 0; pindex < ARRAY_SIZE (optabs); pindex++)
{ {
int force_float = 0, force_int = 0; int force_float = 0, force_int = 0;
int force_consec = 0; int force_consec = 0;
@ -221,7 +221,7 @@ gen_insn (insn)
break; break;
} }
if (pindex == sizeof optabs / sizeof optabs[0]) if (pindex == ARRAY_SIZE (optabs))
return; return;
/* We found a match. If this pattern is only conditionally present, /* We found a match. If this pattern is only conditionally present,

View File

@ -213,7 +213,7 @@ static struct pred_table
LABEL_REF, SUBREG, REG, MEM}} LABEL_REF, SUBREG, REG, MEM}}
}; };
#define NUM_KNOWN_PREDS (sizeof preds / sizeof preds[0]) #define NUM_KNOWN_PREDS ARRAY_SIZE (preds)
static const char * special_mode_pred_table[] = { static const char * special_mode_pred_table[] = {
#ifdef SPECIAL_MODE_PREDICATES #ifdef SPECIAL_MODE_PREDICATES
@ -222,8 +222,7 @@ static const char * special_mode_pred_table[] = {
"pmode_register_operand" "pmode_register_operand"
}; };
#define NUM_SPECIAL_MODE_PREDS \ #define NUM_SPECIAL_MODE_PREDS ARRAY_SIZE (special_mode_pred_table)
(sizeof (special_mode_pred_table) / sizeof (special_mode_pred_table[0]))
static struct decision *new_decision static struct decision *new_decision
PARAMS ((const char *, struct decision_head *)); PARAMS ((const char *, struct decision_head *));

View File

@ -342,7 +342,7 @@ global_alloc (file)
/* Build the regset of all eliminable registers and show we can't use those /* Build the regset of all eliminable registers and show we can't use those
that we already know won't be eliminated. */ that we already know won't be eliminated. */
#ifdef ELIMINABLE_REGS #ifdef ELIMINABLE_REGS
for (i = 0; i < sizeof eliminables / sizeof eliminables[0]; i++) for (i = 0; i < ARRAY_SIZE (eliminables); i++)
{ {
SET_HARD_REG_BIT (eliminable_regset, eliminables[i].from); SET_HARD_REG_BIT (eliminable_regset, eliminables[i].from);

View File

@ -1981,7 +1981,7 @@ find_free_reg (class, mode, qtyno, accept_call_clobbered, just_try_suggested,
This is true of any register that can be eliminated. */ This is true of any register that can be eliminated. */
#ifdef ELIMINABLE_REGS #ifdef ELIMINABLE_REGS
for (i = 0; i < (int) (sizeof eliminables / sizeof eliminables[0]); i++) for (i = 0; i < (int) ARRAY_SIZE (eliminables); i++)
SET_HARD_REG_BIT (used, eliminables[i].from); SET_HARD_REG_BIT (used, eliminables[i].from);
#if FRAME_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM #if FRAME_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
/* If FRAME_POINTER_REGNUM is not a real register, then protect the one /* If FRAME_POINTER_REGNUM is not a real register, then protect the one

View File

@ -1033,7 +1033,7 @@ print_symbol (sym_ptr, number, strbase, aux_base, ifd, fdp)
if (MIPS_IS_STAB(sym_ptr)) if (MIPS_IS_STAB(sym_ptr))
{ {
register int i = sizeof(stab_names) / sizeof(stab_names[0]); register int i = ARRAY_SIZE (stab_names);
const char *stab_name = "stab"; const char *stab_name = "stab";
short code = MIPS_UNMARK_STAB(sym_ptr->index); short code = MIPS_UNMARK_STAB(sym_ptr->index);
while (--i >= 0) while (--i >= 0)

View File

@ -3283,7 +3283,7 @@ parse_def (name_start)
if (diff) if (diff)
{ {
for (j = (sizeof (t.sizes) / sizeof (t.sizes[0])) - 1; j >= 0; j--) for (j = ARRAY_SIZE (t.sizes) - 1; j >= 0; j--)
t.sizes[ j ] = ((j-diff) >= 0) ? t.sizes[ j-diff ] : 0; t.sizes[ j ] = ((j-diff) >= 0) ? t.sizes[ j-diff ] : 0;
t.num_sizes = i + 1; t.num_sizes = i + 1;
@ -3882,7 +3882,7 @@ parse_input __proto((void))
p++; p++;
/* See if it's a directive we handle. If so, dispatch handler. */ /* See if it's a directive we handle. If so, dispatch handler. */
for (i = 0; i < sizeof (pseudo_ops) / sizeof (pseudo_ops[0]); i++) for (i = 0; i < ARRAY_SIZE (pseudo_ops); i++)
if (memcmp (p, pseudo_ops[i].name, pseudo_ops[i].len) == 0 if (memcmp (p, pseudo_ops[i].name, pseudo_ops[i].len) == 0
&& ISSPACE ((unsigned char)(p[pseudo_ops[i].len]))) && ISSPACE ((unsigned char)(p[pseudo_ops[i].len])))
{ {

View File

@ -4484,34 +4484,29 @@ mark_optab (arg)
void void
init_optabs () init_optabs ()
{ {
int i; unsigned int i, j, k;
#ifdef FIXUNS_TRUNC_LIKE_FIX_TRUNC
int j;
#endif
enum insn_code *p;
/* Start by initializing all tables to contain CODE_FOR_nothing. */ /* Start by initializing all tables to contain CODE_FOR_nothing. */
for (p = fixtab[0][0]; for (i = 0; i < ARRAY_SIZE (fixtab); i++)
p < fixtab[0][0] + sizeof fixtab / sizeof (fixtab[0][0][0]); for (j = 0; j < ARRAY_SIZE (fixtab[0]); j++)
p++) for (k = 0; k < ARRAY_SIZE (fixtab[0][0]); k++)
*p = CODE_FOR_nothing; fixtab[i][j][k] = CODE_FOR_nothing;
for (p = fixtrunctab[0][0]; for (i = 0; i < ARRAY_SIZE (fixtrunctab); i++)
p < fixtrunctab[0][0] + sizeof fixtrunctab / sizeof (fixtrunctab[0][0][0]); for (j = 0; j < ARRAY_SIZE (fixtrunctab[0]); j++)
p++) for (k = 0; k < ARRAY_SIZE (fixtrunctab[0][0]); k++)
*p = CODE_FOR_nothing; fixtrunctab[i][j][k] = CODE_FOR_nothing;
for (p = floattab[0][0]; for (i = 0; i < ARRAY_SIZE (floattab); i++)
p < floattab[0][0] + sizeof floattab / sizeof (floattab[0][0][0]); for (j = 0; j < ARRAY_SIZE (floattab[0]); j++)
p++) for (k = 0; k < ARRAY_SIZE (floattab[0][0]); k++)
*p = CODE_FOR_nothing; floattab[i][j][k] = CODE_FOR_nothing;
for (p = extendtab[0][0]; for (i = 0; i < ARRAY_SIZE (extendtab); i++)
p < extendtab[0][0] + sizeof extendtab / sizeof extendtab[0][0][0]; for (j = 0; j < ARRAY_SIZE (extendtab[0]); j++)
p++) for (k = 0; k < ARRAY_SIZE (extendtab[0][0]); k++)
*p = CODE_FOR_nothing; extendtab[i][j][k] = CODE_FOR_nothing;
for (i = 0; i < NUM_RTX_CODE; i++) for (i = 0; i < NUM_RTX_CODE; i++)
setcc_gen_code[i] = CODE_FOR_nothing; setcc_gen_code[i] = CODE_FOR_nothing;

View File

@ -343,7 +343,7 @@ static struct elim_table_1
{{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}}; {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}};
#endif #endif
#define NUM_ELIMINABLE_REGS (sizeof reg_eliminate_1/sizeof reg_eliminate_1[0]) #define NUM_ELIMINABLE_REGS ARRAY_SIZE (reg_eliminate_1)
/* Record the number of pending eliminations that have an offset not equal /* Record the number of pending eliminations that have an offset not equal
to their initial offset. If non-zero, we use a new copy of each to their initial offset. If non-zero, we use a new copy of each

View File

@ -3395,12 +3395,12 @@ expand_nl_goto_receiver ()
static struct elims {int from, to;} elim_regs[] = ELIMINABLE_REGS; static struct elims {int from, to;} elim_regs[] = ELIMINABLE_REGS;
size_t i; size_t i;
for (i = 0; i < sizeof elim_regs / sizeof elim_regs[0]; i++) for (i = 0; i < ARRAY_SIZE (elim_regs); i++)
if (elim_regs[i].from == ARG_POINTER_REGNUM if (elim_regs[i].from == ARG_POINTER_REGNUM
&& elim_regs[i].to == HARD_FRAME_POINTER_REGNUM) && elim_regs[i].to == HARD_FRAME_POINTER_REGNUM)
break; break;
if (i == sizeof elim_regs / sizeof elim_regs [0]) if (i == ARRAY_SIZE (elim_regs))
#endif #endif
{ {
/* Now restore our arg pointer from the address at which it /* Now restore our arg pointer from the address at which it

View File

@ -1657,7 +1657,7 @@ set_sizetype (type)
TYPE_NAME (bitsizetype) = get_identifier ("bit_size_type"); TYPE_NAME (bitsizetype) = get_identifier ("bit_size_type");
/* Show is a sizetype, is a main type, and has no pointers to it. */ /* Show is a sizetype, is a main type, and has no pointers to it. */
for (i = 0; i < sizeof sizetype_tab / sizeof sizetype_tab[0]; i++) for (i = 0; i < ARRAY_SIZE (sizetype_tab); i++)
{ {
TYPE_IS_SIZETYPE (sizetype_tab[i]) = 1; TYPE_IS_SIZETYPE (sizetype_tab[i]) = 1;
TYPE_MAIN_VARIANT (sizetype_tab[i]) = sizetype_tab[i]; TYPE_MAIN_VARIANT (sizetype_tab[i]) = sizetype_tab[i];

View File

@ -1119,8 +1119,6 @@ lang_independent_options f_options[] =
"Convert floating point constant to single precision constant"} "Convert floating point constant to single precision constant"}
}; };
#define NUM_ELEM(a) (sizeof (a) / sizeof ((a)[0]))
/* Table of language-specific options. */ /* Table of language-specific options. */
static struct lang_opt static struct lang_opt
@ -3730,7 +3728,7 @@ display_help ()
printf (_(" -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line. 0 suppresses line-wrapping\n")); printf (_(" -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line. 0 suppresses line-wrapping\n"));
printf (_(" -fdiagnostics-show-location=[once | never] Indicates how often source location information should be emitted, as prefix, at the beginning of diagnostics when line-wrapping\n")); printf (_(" -fdiagnostics-show-location=[once | never] Indicates how often source location information should be emitted, as prefix, at the beginning of diagnostics when line-wrapping\n"));
for (i = NUM_ELEM (f_options); i--;) for (i = ARRAY_SIZE (f_options); i--;)
{ {
const char *description = f_options[i].description; const char *description = f_options[i].description;
@ -3746,7 +3744,7 @@ display_help ()
printf (_(" -w Suppress warnings\n")); printf (_(" -w Suppress warnings\n"));
printf (_(" -W Enable extra warnings\n")); printf (_(" -W Enable extra warnings\n"));
for (i = NUM_ELEM (W_options); i--;) for (i = ARRAY_SIZE (W_options); i--;)
{ {
const char *description = W_options[i].description; const char *description = W_options[i].description;
@ -3770,7 +3768,7 @@ display_help ()
-G <number> Put global and static data smaller than <number>\n\ -G <number> Put global and static data smaller than <number>\n\
bytes into a special section (on some targets)\n")); bytes into a special section (on some targets)\n"));
for (i = NUM_ELEM (debug_args); i--;) for (i = ARRAY_SIZE (debug_args); i--;)
{ {
if (debug_args[i].description != NULL) if (debug_args[i].description != NULL)
printf (" -g%-21s %s\n", printf (" -g%-21s %s\n",
@ -3798,11 +3796,11 @@ display_help ()
that the description string is in fact the name of a language, whose that the description string is in fact the name of a language, whose
language specific options are to follow. */ language specific options are to follow. */
if (NUM_ELEM (documented_lang_options) > 1) if (ARRAY_SIZE (documented_lang_options) > 1)
{ {
printf (_("\nLanguage specific options:\n")); printf (_("\nLanguage specific options:\n"));
for (i = 0; i < NUM_ELEM (documented_lang_options); i++) for (i = 0; i < ARRAY_SIZE (documented_lang_options); i++)
{ {
const char *description = documented_lang_options[i].description; const char *description = documented_lang_options[i].description;
const char *option = documented_lang_options[i].option; const char *option = documented_lang_options[i].option;
@ -3837,9 +3835,9 @@ display_help ()
printf (_("\nThere are undocumented %s specific options as well.\n"), printf (_("\nThere are undocumented %s specific options as well.\n"),
lang); lang);
if (NUM_ELEM (target_switches) > 1 if (ARRAY_SIZE (target_switches) > 1
#ifdef TARGET_OPTIONS #ifdef TARGET_OPTIONS
|| NUM_ELEM (target_options) > 1 || ARRAY_SIZE (target_options) > 1
#endif #endif
) )
{ {
@ -3849,7 +3847,7 @@ display_help ()
printf (_("\nTarget specific options:\n")); printf (_("\nTarget specific options:\n"));
for (i = NUM_ELEM (target_switches); i--;) for (i = ARRAY_SIZE (target_switches); i--;)
{ {
const char *option = target_switches[i].name; const char *option = target_switches[i].name;
const char *description = target_switches[i].description; const char *description = target_switches[i].description;
@ -3868,7 +3866,7 @@ display_help ()
} }
#ifdef TARGET_OPTIONS #ifdef TARGET_OPTIONS
for (i = NUM_ELEM (target_options); i--;) for (i = ARRAY_SIZE (target_options); i--;)
{ {
const char *option = target_options[i].prefix; const char *option = target_options[i].prefix;
const char *description = target_options[i].description; const char *description = target_options[i].description;
@ -3960,7 +3958,7 @@ decode_f_option (arg)
const char *option_value = NULL; const char *option_value = NULL;
/* Search for the option in the table of binary f options. */ /* Search for the option in the table of binary f options. */
for (j = sizeof (f_options) / sizeof (f_options[0]); j--;) for (j = ARRAY_SIZE (f_options); j--;)
{ {
if (!strcmp (arg, f_options[j].string)) if (!strcmp (arg, f_options[j].string))
{ {
@ -4059,7 +4057,7 @@ decode_W_option (arg)
/* Search for the option in the table of binary W options. */ /* Search for the option in the table of binary W options. */
for (j = sizeof (W_options) / sizeof (W_options[0]); j--;) for (j = ARRAY_SIZE (W_options); j--;)
{ {
if (!strcmp (arg, W_options[j].string)) if (!strcmp (arg, W_options[j].string))
{ {
@ -4622,7 +4620,7 @@ main (argc, argv)
possibility here. If we do find a match, then if extra_warnings possibility here. If we do find a match, then if extra_warnings
is set we generate a warning message, otherwise we will just is set we generate a warning message, otherwise we will just
ignore the option. */ ignore the option. */
for (j = 0; j < NUM_ELEM (documented_lang_options); j++) for (j = 0; j < ARRAY_SIZE (documented_lang_options); j++)
{ {
option = documented_lang_options[j].option; option = documented_lang_options[j].option;
@ -4632,7 +4630,7 @@ main (argc, argv)
break; break;
} }
if (j != NUM_ELEM (documented_lang_options)) if (j != ARRAY_SIZE (documented_lang_options))
{ {
if (extra_warnings) if (extra_warnings)
{ {
@ -4798,7 +4796,7 @@ set_target_switch (name)
register size_t j; register size_t j;
int valid_target_option = 0; int valid_target_option = 0;
for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++) for (j = 0; j < ARRAY_SIZE (target_switches); j++)
if (!strcmp (target_switches[j].name, name)) if (!strcmp (target_switches[j].name, name))
{ {
if (target_switches[j].value < 0) if (target_switches[j].value < 0)
@ -4810,7 +4808,7 @@ set_target_switch (name)
#ifdef TARGET_OPTIONS #ifdef TARGET_OPTIONS
if (!valid_target_option) if (!valid_target_option)
for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++) for (j = 0; j < ARRAY_SIZE (target_options); j++)
{ {
int len = strlen (target_options[j].prefix); int len = strlen (target_options[j].prefix);
if (!strncmp (target_options[j].prefix, name, len)) if (!strncmp (target_options[j].prefix, name, len))
@ -4925,14 +4923,14 @@ print_switch_values (file, pos, max, indent, sep, term)
pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term, pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
_("options enabled: "), ""); _("options enabled: "), "");
for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++) for (j = 0; j < ARRAY_SIZE (f_options); j++)
if (*f_options[j].variable == f_options[j].on_value) if (*f_options[j].variable == f_options[j].on_value)
pos = print_single_switch (file, pos, max, indent, sep, term, pos = print_single_switch (file, pos, max, indent, sep, term,
"-f", f_options[j].string); "-f", f_options[j].string);
/* Print target specific options. */ /* Print target specific options. */
for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++) for (j = 0; j < ARRAY_SIZE (target_switches); j++)
if (target_switches[j].name[0] != '\0' if (target_switches[j].name[0] != '\0'
&& target_switches[j].value > 0 && target_switches[j].value > 0
&& ((target_switches[j].value & target_flags) && ((target_switches[j].value & target_flags)
@ -4943,7 +4941,7 @@ print_switch_values (file, pos, max, indent, sep, term)
} }
#ifdef TARGET_OPTIONS #ifdef TARGET_OPTIONS
for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++) for (j = 0; j < ARRAY_SIZE (target_options); j++)
if (*target_options[j].variable != NULL) if (*target_options[j].variable != NULL)
{ {
char prefix[256]; char prefix[256];

View File

@ -641,7 +641,7 @@ decode_reg_name (asmspec)
static struct { const char *name; int number; } table[] static struct { const char *name; int number; } table[]
= ADDITIONAL_REGISTER_NAMES; = ADDITIONAL_REGISTER_NAMES;
for (i = 0; i < (int)(sizeof (table) / sizeof (table[0])); i++) for (i = 0; i < (int) ARRAY_SIZE (table); i++)
if (! strcmp (asmspec, table[i].name)) if (! strcmp (asmspec, table[i].name))
return table[i].number; return table[i].number;
} }