From 3098b2d3707544218ec1789dddaecb0cb8b9eae9 Mon Sep 17 00:00:00 2001 From: gkm Date: Thu, 24 Aug 2000 20:31:35 +0000 Subject: [PATCH] * 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/ git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@35949 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 44 ++++++++++++++++++++++++++++++++++++++++++++ gcc/builtins.c | 4 ++-- gcc/config/alpha/alpha.c | 2 +- gcc/config/arm/arm.c | 2 +- gcc/config/fr30/fr30.c | 2 +- gcc/config/i386/dgux.c | 4 ++-- gcc/config/i386/dgux.h | 6 +++--- gcc/config/m88k/m88k.c | 2 +- gcc/config/m88k/m88k.h | 4 ++-- gcc/config/mcore/mcore.c | 6 +++--- gcc/config/mips/mips.c | 9 +++------ gcc/config/rs6000/rs6000.c | 4 ++-- gcc/config/sparc/sparc.c | 6 ++---- gcc/emit-rtl.c | 5 ++++- gcc/expr.c | 2 +- gcc/fixinc/fixfixes.c | 2 +- gcc/fixinc/fixtests.c | 2 +- gcc/flow.c | 2 +- gcc/fold-const.c | 2 +- gcc/gcc.c | 22 ++++++++-------------- gcc/genattrtab.c | 2 +- gcc/genopinit.c | 4 ++-- gcc/genrecog.c | 5 ++--- gcc/global.c | 2 +- gcc/local-alloc.c | 2 +- gcc/mips-tdump.c | 2 +- gcc/mips-tfile.c | 4 ++-- gcc/optabs.c | 45 ++++++++++++++++++++------------------------- gcc/reload1.c | 2 +- gcc/stmt.c | 4 ++-- gcc/stor-layout.c | 2 +- gcc/toplev.c | 38 ++++++++++++++++++-------------------- gcc/varasm.c | 2 +- 33 files changed, 137 insertions(+), 109 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b76a4fbb865..650bb361360 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,49 @@ 2000-08-24 Greg McGary + * 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 + * 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 d7ce1e74236..4f3f7a9fd24 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 99535ab9d74..ef6845b4f77 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 4c7679abb15..6abe7321ab1 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 68bae05ceac..c2ee0055b82 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 915719d1c5a..069a7acceb3 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 5b0ca5f0995..10982c505cd 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 ab79bf015fe..86c92e75447 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 ca2d0f73858..1412ff2f08a 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 4622adeeb9c..8dbcb2bac7a 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 629fac1fd30..f059dddd616 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 9e4c11f23e3..18106cb0c7a 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 f6a354dfab2..82e9a742222 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 e219d5ab043..632c4e24e25 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 diff --git a/gcc/expr.c b/gcc/expr.c index 2592a58a66a..a5c306fd3a5 100644 --- a/gcc/expr.c +++ b/gcc/expr.c @@ -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 4cb3e5874d6..e419126944c 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 0da04b51774..3b0c79833df 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; diff --git a/gcc/flow.c b/gcc/flow.c index 1291ac404a6..c242490557c 100644 --- a/gcc/flow.c +++ b/gcc/flow.c @@ -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 88ee674c4f0..ecc7c3200aa 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)) diff --git a/gcc/gcc.c b/gcc/gcc.c index 243609d5597..4aa4f9488cf 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -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 aedd1d04877..a6a9a9010ea 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 dcacc9fa392..993c347a1b0 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 3e665dce05f..e506f8d85b6 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 62e80afd2f0..7f426df38f6 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 02e969492b5..f1ac07cebe7 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 f771549c206..68359aeb235 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 ee0afe581db..ff24ce8e9af 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 6530d834ee0..0a64fad7499 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 5639d2f3740..8d7caffbf91 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 diff --git a/gcc/stmt.c b/gcc/stmt.c index 7ea077dd9ec..2d7566ef4ca 100644 --- a/gcc/stmt.c +++ b/gcc/stmt.c @@ -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 294f2d400ed..43ae6f2cf47 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 55ff15d28fa..2a1b5a79768 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= Limits diagnostics messages lengths to 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 Put global and static data smaller than \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 5b934e863ff..b30d08901c3 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; } -- 2.11.4.GIT