diff options
author | Greg McGary <greg@mcgary.org> | 2000-08-24 20:31:35 +0000 |
---|---|---|
committer | Greg McGary <gkm@gcc.gnu.org> | 2000-08-24 20:31:35 +0000 |
commit | b6a1cbaeb19076fca9b0deb00138fedf0c8c36ff (patch) | |
tree | 598c21af74eb9deec6a463196f439a03d7a53b91 | |
parent | 2f26c11dbb2d0f1e37f16120c455147a00dff716 (diff) | |
download | gcc-b6a1cbaeb19076fca9b0deb00138fedf0c8c36ff.zip gcc-b6a1cbaeb19076fca9b0deb00138fedf0c8c36ff.tar.gz gcc-b6a1cbaeb19076fca9b0deb00138fedf0c8c36ff.tar.bz2 |
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
-rw-r--r-- | gcc/ChangeLog | 44 | ||||
-rw-r--r-- | gcc/builtins.c | 4 | ||||
-rw-r--r-- | gcc/config/alpha/alpha.c | 2 | ||||
-rw-r--r-- | gcc/config/arm/arm.c | 2 | ||||
-rw-r--r-- | gcc/config/fr30/fr30.c | 2 | ||||
-rw-r--r-- | gcc/config/i386/dgux.c | 4 | ||||
-rw-r--r-- | gcc/config/i386/dgux.h | 6 | ||||
-rw-r--r-- | gcc/config/m88k/m88k.c | 2 | ||||
-rw-r--r-- | gcc/config/m88k/m88k.h | 4 | ||||
-rw-r--r-- | gcc/config/mcore/mcore.c | 6 | ||||
-rw-r--r-- | gcc/config/mips/mips.c | 9 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000.c | 4 | ||||
-rw-r--r-- | gcc/config/sparc/sparc.c | 6 | ||||
-rw-r--r-- | gcc/emit-rtl.c | 5 | ||||
-rw-r--r-- | gcc/expr.c | 2 | ||||
-rw-r--r-- | gcc/fixinc/fixfixes.c | 2 | ||||
-rw-r--r-- | gcc/fixinc/fixtests.c | 2 | ||||
-rw-r--r-- | gcc/flow.c | 2 | ||||
-rw-r--r-- | gcc/fold-const.c | 2 | ||||
-rw-r--r-- | gcc/gcc.c | 22 | ||||
-rw-r--r-- | gcc/genattrtab.c | 2 | ||||
-rw-r--r-- | gcc/genopinit.c | 4 | ||||
-rw-r--r-- | gcc/genrecog.c | 5 | ||||
-rw-r--r-- | gcc/global.c | 2 | ||||
-rw-r--r-- | gcc/local-alloc.c | 2 | ||||
-rw-r--r-- | gcc/mips-tdump.c | 2 | ||||
-rw-r--r-- | gcc/mips-tfile.c | 4 | ||||
-rw-r--r-- | gcc/optabs.c | 45 | ||||
-rw-r--r-- | gcc/reload1.c | 2 | ||||
-rw-r--r-- | gcc/stmt.c | 4 | ||||
-rw-r--r-- | gcc/stor-layout.c | 2 | ||||
-rw-r--r-- | gcc/toplev.c | 38 | ||||
-rw-r--r-- | gcc/varasm.c | 2 |
33 files changed, 137 insertions, 109 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b76a4fb..650bb36 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,49 @@ 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> + * tree.h (enum tree_index): New member `TI_MAIN_IDENTIFIER'. (MAIN_NAME_P, main_identifier_node): New macros. * c-common.c (c_common_nodes_and_builtins): Init main_identifier_node. diff --git a/gcc/builtins.c b/gcc/builtins.c index d7ce1e7..4f3f7a9 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -417,12 +417,12 @@ expand_builtin_setjmp (buf_addr, target, first_label, next_label) size_t i; 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 && elim_regs[i].to == HARD_FRAME_POINTER_REGNUM) break; - if (i == sizeof elim_regs / sizeof elim_regs [0]) + if (i == ARRAY_SIZE (elim_regs)) #endif { /* Now restore our arg pointer from the address at which it diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index 99535ab..ef6845b 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -1988,7 +1988,7 @@ alpha_lookup_xfloating_lib_func (code) }; 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; /* How irritating. Nothing to key off for the table. Hardcode diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 4c7679a..6abe732 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -317,7 +317,7 @@ arm_override_options () unsigned i; /* 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; diff --git a/gcc/config/fr30/fr30.c b/gcc/config/fr30/fr30.c index 68bae05..c2ee005 100644 --- a/gcc/config/fr30/fr30.c +++ b/gcc/config/fr30/fr30.c @@ -575,7 +575,7 @@ fr30_print_operand (file, x, code) switch (GET_CODE (x0)) { case REG: - if ((unsigned) REGNO (x0) >= (sizeof (reg_names) / sizeof (reg_names[0]))) + if ((unsigned) REGNO (x0) >= ARRAY_SIZE (reg_names)) abort (); fprintf (file, "@%s", reg_names [REGNO (x0)]); break; diff --git a/gcc/config/i386/dgux.c b/gcc/config/i386/dgux.c index 915719d..069a7ac 100644 --- a/gcc/config/i386/dgux.c +++ b/gcc/config/i386/dgux.c @@ -1,5 +1,5 @@ /* 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) 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, 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' && m_options[j].value > 0 && ((m_options[j].value & target_flags) diff --git a/gcc/config/i386/dgux.h b/gcc/config/i386/dgux.h index 5b0ca5f..10982c5 100644 --- a/gcc/config/i386/dgux.h +++ b/gcc/config/i386/dgux.h @@ -27,7 +27,7 @@ Boston, MA 02111-1307, USA. */ #include "i386/sysv4.h" #ifndef VERSION_INFO2 -#define VERSION_INFO2 "$Revision: 1.9 $" +#define VERSION_INFO2 "$Revision: 1.10 $" #endif #ifndef VERSION_STRING @@ -85,8 +85,8 @@ Boston, MA 02111-1307, USA. */ /* Override svr[34].h. */ #undef ASM_FILE_START #define ASM_FILE_START(FILE) \ - output_file_start (FILE, f_options, sizeof f_options / sizeof f_options[0], \ - W_options, sizeof W_options / sizeof W_options[0]) + output_file_start (FILE, f_options, ARRAY_SIZE (f_options), \ + W_options, ARRAY_SIZE (W_options)) /* ix86 abi specified type for wchar_t */ diff --git a/gcc/config/m88k/m88k.c b/gcc/config/m88k/m88k.c index ab79bf0..86c92e7 100644 --- a/gcc/config/m88k/m88k.c +++ b/gcc/config/m88k/m88k.c @@ -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, 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' && m_options[j].value > 0 && ((m_options[j].value & target_flags) diff --git a/gcc/config/m88k/m88k.h b/gcc/config/m88k/m88k.h index ca2d0f7..1412ff2 100644 --- a/gcc/config/m88k/m88k.h +++ b/gcc/config/m88k/m88k.h @@ -1818,9 +1818,9 @@ enum reg_class { NO_REGS, AP_REG, XRF_REGS, GENERAL_REGS, AGRF_REGS, #define ASM_FILE_START(FILE) \ output_file_start (FILE, \ (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, \ - sizeof W_options / sizeof W_options[0]) + ARRAY_SIZE (W_options)) #undef ASM_FILE_END diff --git a/gcc/config/mcore/mcore.c b/gcc/config/mcore/mcore.c index 4622ade..8dbcb2b 100644 --- a/gcc/config/mcore/mcore.c +++ b/gcc/config/mcore/mcore.c @@ -1158,7 +1158,7 @@ mcore_output_inline_const_forced (insn, operands, mode) if (mcore_const_ok_for_inline (value)) 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].low = (value & 0x1F); @@ -1990,7 +1990,7 @@ layout_mcore_frame (infp) (1) run fast, (2) reduce instruction space, or (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; 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. */ - 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], arg_regs[3], arg_regs[4], arg_regs[5]); diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 629fac1..f059ddd 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -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 the same as one of the addressing registers and reduce the number of registers available. */ - for (i = 4; - i < last_operand - && safe_regs < (int)(sizeof(xoperands) / sizeof(xoperands[0])); - i++) + for (i = 4; i < last_operand && safe_regs < (int) ARRAY_SIZE (xoperands); i++) if (! reg_mentioned_p (operands[i], operands[0]) && ! reg_mentioned_p (operands[i], operands[1])) 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]))) - num_regs = sizeof (load_store) / sizeof (load_store[0]); + if (num_regs > (int) ARRAY_SIZE (load_store)) + num_regs = ARRAY_SIZE (load_store); else if (num_regs < 1) abort_with_insn (insn, diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 9e4c11f..18106cb 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -293,7 +293,7 @@ rs6000_override_options (default_cpu) rs6000_select[0].string = default_cpu; 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]; 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); 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]; if (ptr->string != (char *)0 && ptr->string[0] != '\0') diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index f6a354d..82e9a74 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -8569,8 +8569,6 @@ sparc_add_gc_roots () ggc_add_rtx_root (&get_pc_symbol, 1); ggc_add_rtx_root (&sparc_addr_diff_list, 1); ggc_add_rtx_root (&sparc_addr_list, 1); - ggc_add_root (ultra_pipe_hist, - sizeof (ultra_pipe_hist) / sizeof (ultra_pipe_hist[0]), - sizeof (ultra_pipe_hist[0]), - &mark_ultrasparc_pipeline_state); + ggc_add_root (ultra_pipe_hist, ARRAY_SIZE (ultra_pipe_hist), + sizeof (ultra_pipe_hist[0]), &mark_ultrasparc_pipeline_state); } diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index e219d5a..632c4e2 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -4180,7 +4180,10 @@ init_emit_once (line_numbers) if (GET_MODE_CLASS (mode) == MODE_CC) 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); #ifdef RETURN_ADDRESS_POINTER_REGNUM @@ -5404,7 +5404,7 @@ safe_from_p (x, exp, top_p) int rtn; 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]; rtn = safe_from_p (x, exp, 1); diff --git a/gcc/fixinc/fixfixes.c b/gcc/fixinc/fixfixes.c index 4cb3e58..e419126 100644 --- a/gcc/fixinc/fixfixes.c +++ b/gcc/fixinc/fixfixes.c @@ -706,7 +706,7 @@ apply_fix( p_fixd, filname ) #define _FT_(n,p) { n, p }, static fix_entry_t fix_table[] = { FIXUP_TABLE { NULL, NULL }}; #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]; char* buf; diff --git a/gcc/fixinc/fixtests.c b/gcc/fixinc/fixtests.c index 0da04b5..3b0c798 100644 --- a/gcc/fixinc/fixtests.c +++ b/gcc/fixinc/fixtests.c @@ -129,7 +129,7 @@ run_test( tname, fname, text ) #define _FT_(n,p) { n, p }, static test_entry_t test_table[] = { FIX_TEST_TABLE { NULL, NULL }}; #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; test_entry_t* pte = test_table; @@ -2624,7 +2624,7 @@ life_analysis (f, file, flags) CLEAR_HARD_REG_SET (elim_reg_set); #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); #else SET_HARD_REG_BIT (elim_reg_set, FRAME_POINTER_REGNUM); diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 88ee674..ecc7c32 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -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 cached entries, see if it is already in the table and put it there 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) for (t = size_table[number]; t != 0; t = TREE_CHAIN (t)) @@ -880,7 +880,7 @@ translate_options (argcp, argvp) { size_t j; /* 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 arglen = strlen (argv[i]); @@ -897,9 +897,7 @@ translate_options (argcp, argvp) if (arglen < optlen) { size_t k; - for (k = j + 1; - k < sizeof (option_map) / sizeof (option_map[0]); - k++) + for (k = j + 1; k < ARRAY_SIZE (option_map); k++) if (strlen (option_map[k].name) >= arglen && !strncmp (argv[i], option_map[k].name, arglen)) { @@ -907,7 +905,7 @@ translate_options (argcp, argvp) break; } - if (k != sizeof (option_map) / sizeof (option_map[0])) + if (k != ARRAY_SIZE (option_map)) break; } @@ -1130,10 +1128,9 @@ init_spec () #ifdef EXTRA_SPECS extra_specs = (struct spec_list *) - xcalloc (sizeof(struct spec_list), - (sizeof(extra_specs_1)/sizeof(extra_specs_1[0]))); + xcalloc (sizeof (struct spec_list), ARRAY_SIZE (extra_specs_1)); - 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->name = extra_specs_1[i].name; @@ -1145,7 +1142,7 @@ init_spec () } #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->next = next; @@ -1174,8 +1171,7 @@ set_spec (name, spec) if (!specs) { struct spec_list *next = (struct spec_list *)0; - 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->next = next; @@ -5170,9 +5166,7 @@ main (argc, argv) multilib_exclusions = obstack_finish (&multilib_obstack); need_space = FALSE; - for (i = 0; - i < sizeof (multilib_defaults_raw) / sizeof (multilib_defaults_raw[0]); - i++) + for (i = 0; i < ARRAY_SIZE (multilib_defaults_raw); i++) { if (need_space) obstack_1grow (&multilib_obstack, ' '); diff --git a/gcc/genattrtab.c b/gcc/genattrtab.c index aedd1d0..a6a9a90 100644 --- a/gcc/genattrtab.c +++ b/gcc/genattrtab.c @@ -2491,7 +2491,7 @@ make_length_attrs () length_attr->is_special = 1; /* 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], substitute_address (length_attr->default_val->value, diff --git a/gcc/genopinit.c b/gcc/genopinit.c index dcacc9f..993c347 100644 --- a/gcc/genopinit.c +++ b/gcc/genopinit.c @@ -134,7 +134,7 @@ gen_insn (insn) /* See if NAME matches one of the patterns we have for the optabs we know 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_consec = 0; @@ -221,7 +221,7 @@ gen_insn (insn) break; } - if (pindex == sizeof optabs / sizeof optabs[0]) + if (pindex == ARRAY_SIZE (optabs)) return; /* We found a match. If this pattern is only conditionally present, diff --git a/gcc/genrecog.c b/gcc/genrecog.c index 3e665dc..e506f8d 100644 --- a/gcc/genrecog.c +++ b/gcc/genrecog.c @@ -213,7 +213,7 @@ static struct pred_table 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[] = { #ifdef SPECIAL_MODE_PREDICATES @@ -222,8 +222,7 @@ static const char * special_mode_pred_table[] = { "pmode_register_operand" }; -#define NUM_SPECIAL_MODE_PREDS \ - (sizeof (special_mode_pred_table) / sizeof (special_mode_pred_table[0])) +#define NUM_SPECIAL_MODE_PREDS ARRAY_SIZE (special_mode_pred_table) static struct decision *new_decision PARAMS ((const char *, struct decision_head *)); diff --git a/gcc/global.c b/gcc/global.c index 62e80af..7f426df 100644 --- a/gcc/global.c +++ b/gcc/global.c @@ -342,7 +342,7 @@ global_alloc (file) /* Build the regset of all eliminable registers and show we can't use those that we already know won't be eliminated. */ #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); diff --git a/gcc/local-alloc.c b/gcc/local-alloc.c index 02e9694..f1ac07c 100644 --- a/gcc/local-alloc.c +++ b/gcc/local-alloc.c @@ -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. */ #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); #if FRAME_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM /* If FRAME_POINTER_REGNUM is not a real register, then protect the one diff --git a/gcc/mips-tdump.c b/gcc/mips-tdump.c index f771549..68359ae 100644 --- a/gcc/mips-tdump.c +++ b/gcc/mips-tdump.c @@ -1033,7 +1033,7 @@ print_symbol (sym_ptr, number, strbase, aux_base, ifd, fdp) 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"; short code = MIPS_UNMARK_STAB(sym_ptr->index); while (--i >= 0) diff --git a/gcc/mips-tfile.c b/gcc/mips-tfile.c index ee0afe5..ff24ce8 100644 --- a/gcc/mips-tfile.c +++ b/gcc/mips-tfile.c @@ -3283,7 +3283,7 @@ parse_def (name_start) 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.num_sizes = i + 1; @@ -3882,7 +3882,7 @@ parse_input __proto((void)) p++; /* 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 && ISSPACE ((unsigned char)(p[pseudo_ops[i].len]))) { diff --git a/gcc/optabs.c b/gcc/optabs.c index 6530d83..0a64fad 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -4484,34 +4484,29 @@ mark_optab (arg) void init_optabs () { - int i; -#ifdef FIXUNS_TRUNC_LIKE_FIX_TRUNC - int j; -#endif - - enum insn_code *p; + unsigned int i, j, k; /* Start by initializing all tables to contain CODE_FOR_nothing. */ - for (p = fixtab[0][0]; - p < fixtab[0][0] + sizeof fixtab / sizeof (fixtab[0][0][0]); - p++) - *p = CODE_FOR_nothing; - - for (p = fixtrunctab[0][0]; - p < fixtrunctab[0][0] + sizeof fixtrunctab / sizeof (fixtrunctab[0][0][0]); - p++) - *p = CODE_FOR_nothing; - - for (p = floattab[0][0]; - p < floattab[0][0] + sizeof floattab / sizeof (floattab[0][0][0]); - p++) - *p = CODE_FOR_nothing; - - for (p = extendtab[0][0]; - p < extendtab[0][0] + sizeof extendtab / sizeof extendtab[0][0][0]; - p++) - *p = CODE_FOR_nothing; + for (i = 0; i < ARRAY_SIZE (fixtab); i++) + for (j = 0; j < ARRAY_SIZE (fixtab[0]); j++) + for (k = 0; k < ARRAY_SIZE (fixtab[0][0]); k++) + fixtab[i][j][k] = CODE_FOR_nothing; + + for (i = 0; i < ARRAY_SIZE (fixtrunctab); i++) + for (j = 0; j < ARRAY_SIZE (fixtrunctab[0]); j++) + for (k = 0; k < ARRAY_SIZE (fixtrunctab[0][0]); k++) + fixtrunctab[i][j][k] = CODE_FOR_nothing; + + for (i = 0; i < ARRAY_SIZE (floattab); i++) + for (j = 0; j < ARRAY_SIZE (floattab[0]); j++) + for (k = 0; k < ARRAY_SIZE (floattab[0][0]); k++) + floattab[i][j][k] = CODE_FOR_nothing; + + for (i = 0; i < ARRAY_SIZE (extendtab); i++) + for (j = 0; j < ARRAY_SIZE (extendtab[0]); j++) + for (k = 0; k < ARRAY_SIZE (extendtab[0][0]); k++) + extendtab[i][j][k] = CODE_FOR_nothing; for (i = 0; i < NUM_RTX_CODE; i++) setcc_gen_code[i] = CODE_FOR_nothing; diff --git a/gcc/reload1.c b/gcc/reload1.c index 5639d2f..8d7caff 100644 --- a/gcc/reload1.c +++ b/gcc/reload1.c @@ -343,7 +343,7 @@ static struct elim_table_1 {{ FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}}; #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 to their initial offset. If non-zero, we use a new copy of each @@ -3395,12 +3395,12 @@ expand_nl_goto_receiver () static struct elims {int from, to;} elim_regs[] = ELIMINABLE_REGS; 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 && elim_regs[i].to == HARD_FRAME_POINTER_REGNUM) break; - if (i == sizeof elim_regs / sizeof elim_regs [0]) + if (i == ARRAY_SIZE (elim_regs)) #endif { /* Now restore our arg pointer from the address at which it diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 294f2d4..43ae6f2 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -1657,7 +1657,7 @@ set_sizetype (type) TYPE_NAME (bitsizetype) = get_identifier ("bit_size_type"); /* 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_MAIN_VARIANT (sizetype_tab[i]) = sizetype_tab[i]; diff --git a/gcc/toplev.c b/gcc/toplev.c index 55ff15d..2a1b5a7 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -1119,8 +1119,6 @@ lang_independent_options f_options[] = "Convert floating point constant to single precision constant"} }; -#define NUM_ELEM(a) (sizeof (a) / sizeof ((a)[0])) - /* Table of language-specific options. */ 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 (_(" -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; @@ -3746,7 +3744,7 @@ display_help () printf (_(" -w Suppress 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; @@ -3770,7 +3768,7 @@ display_help () -G <number> Put global and static data smaller than <number>\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) printf (" -g%-21s %s\n", @@ -3798,11 +3796,11 @@ display_help () that the description string is in fact the name of a language, whose 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")); - 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 *option = documented_lang_options[i].option; @@ -3837,9 +3835,9 @@ display_help () printf (_("\nThere are undocumented %s specific options as well.\n"), lang); - if (NUM_ELEM (target_switches) > 1 + if (ARRAY_SIZE (target_switches) > 1 #ifdef TARGET_OPTIONS - || NUM_ELEM (target_options) > 1 + || ARRAY_SIZE (target_options) > 1 #endif ) { @@ -3849,7 +3847,7 @@ display_help () 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 *description = target_switches[i].description; @@ -3868,7 +3866,7 @@ display_help () } #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 *description = target_options[i].description; @@ -3960,7 +3958,7 @@ decode_f_option (arg) const char *option_value = NULL; /* 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)) { @@ -4059,7 +4057,7 @@ decode_W_option (arg) /* 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)) { @@ -4622,7 +4620,7 @@ main (argc, argv) possibility here. If we do find a match, then if extra_warnings is set we generate a warning message, otherwise we will just 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; @@ -4632,7 +4630,7 @@ main (argc, argv) break; } - if (j != NUM_ELEM (documented_lang_options)) + if (j != ARRAY_SIZE (documented_lang_options)) { if (extra_warnings) { @@ -4798,7 +4796,7 @@ set_target_switch (name) register size_t j; 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 (target_switches[j].value < 0) @@ -4810,7 +4808,7 @@ set_target_switch (name) #ifdef TARGET_OPTIONS 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); 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, _("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) pos = print_single_switch (file, pos, max, indent, sep, term, "-f", f_options[j].string); /* 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' && target_switches[j].value > 0 && ((target_switches[j].value & target_flags) @@ -4943,7 +4941,7 @@ print_switch_values (file, pos, max, indent, sep, term) } #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) { char prefix[256]; diff --git a/gcc/varasm.c b/gcc/varasm.c index 5b934e8..b30d089 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -641,7 +641,7 @@ decode_reg_name (asmspec) static struct { const char *name; int number; } table[] = 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)) return table[i].number; } |