+2002-03-03 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * attribs.c (init_attributes, decl_attributes): Use ARRAY_SIZE in
+ lieu of explicit sizeof/sizeof.
+ * i386.c (override_options, ix86_init_mmx_sse_builtins,
+ ix86_expand_builtin): Likewise.
+ * mips.c (mips_add_gc_roots): Likewise.
+ * mmix.c (mmix_output_condition): Likewise.
+ * rs6000.c (rs6000_override_options, altivec_expand_builtin,
+ altivec_init_builtins): Likewise.
+ * sparc.c (mark_ultrasparc_pipeline_state): Likewise.
+ * cppexp.c (Nsuff, parse_number): Likewise.
+ * cppinit.c (builtin_array_end): Likewise.
+ * gcc.c (n_default_compilers, process_command): Likewise.
+ * genpreds.c (output_predicate_decls): Likewise.
+ * ggc-page.c (NUM_EXTRA_ORDERS): Likewise.
+ * lcm.c (N_ENTITIES): Likewise.
+ * stor-layout.c (set_sizetype): Likewise.
+
2002-03-03 Richard Henderson <rth@redhat.com>
* toplev.c (rest_of_decl_compilation): Do not invoke make_decl_rtl
+2002-03-03 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * utils.c (init_gnat_to_gnu, init_gigi_decls): Use ARRAY_SIZE in
+ lieu of explicit sizeof/sizeof.
+
2002-02-28 Neil Booth <neil@daikokuya.demon.co.uk>
* misc.c (copy_lang_decl): Remove.
* *
* C Implementation File *
* *
- * $Revision: 1.7 $
+ * $Revision: 1.8 $
* *
* Copyright (C) 1992-2001, Free Software Foundation, Inc. *
* *
ggc_add_tree_root (&signed_and_unsigned_types[0][0],
(sizeof signed_and_unsigned_types
/ sizeof signed_and_unsigned_types[0][0]));
- ggc_add_tree_root (float_types, sizeof float_types / sizeof float_types[0]);
+ ggc_add_tree_root (float_types, ARRAY_SIZE (float_types));
ggc_add_root (¤t_binding_level, 1, sizeof current_binding_level,
mark_binding_level);
DECL_BUILT_IN_CLASS (setjmp_decl) = BUILT_IN_NORMAL;
DECL_FUNCTION_CODE (setjmp_decl) = BUILT_IN_SETJMP;
- ggc_add_tree_root (gnat_std_decls,
- sizeof gnat_std_decls / sizeof gnat_std_decls[0]);
+ ggc_add_tree_root (gnat_std_decls, ARRAY_SIZE (gnat_std_decls));
}
\f
/* This routine is called in tree.c to print an error message for invalid use
init_attributes ()
{
#ifdef ENABLE_CHECKING
- int i;
+ size_t i;
#endif
attribute_tables[0]
#ifdef ENABLE_CHECKING
/* Make some sanity checks on the attribute tables. */
- for (i = 0;
- i < (int) (sizeof (attribute_tables) / sizeof (attribute_tables[0]));
- i++)
+ for (i = 0; i < ARRAY_SIZE (attribute_tables); i++)
{
int j;
}
/* Check that each name occurs just once in each table. */
- for (i = 0;
- i < (int) (sizeof (attribute_tables) / sizeof (attribute_tables[0]));
- i++)
+ for (i = 0; i < ARRAY_SIZE (attribute_tables); i++)
{
int j, k;
for (j = 0; attribute_tables[i][j].name != NULL; j++)
abort ();
}
/* Check that no name occurs in more than one table. */
- for (i = 0;
- i < (int) (sizeof (attribute_tables) / sizeof (attribute_tables[0]));
- i++)
+ for (i = 0; i < ARRAY_SIZE (attribute_tables); i++)
{
- int j, k, l;
+ size_t j, k, l;
- for (j = i + 1;
- j < ((int) (sizeof (attribute_tables)
- / sizeof (attribute_tables[0])));
- j++)
+ for (j = i + 1; j < ARRAY_SIZE (attribute_tables); j++)
for (k = 0; attribute_tables[i][k].name != NULL; k++)
for (l = 0; attribute_tables[j][l].name != NULL; l++)
if (!strcmp (attribute_tables[i][k].name,
bool no_add_attrs = 0;
int i;
- for (i = 0;
- i < ((int) (sizeof (attribute_tables)
- / sizeof (attribute_tables[0])));
- i++)
+ for (i = 0; i < ARRAY_SIZE (attribute_tables); i++)
{
int j;
| PTA_3DNOW_A | PTA_SSE},
};
- int const pta_size = sizeof (processor_alias_table) / sizeof (struct pta);
+ int const pta_size = ARRAY_SIZE (processor_alias_table);
#ifdef SUBTARGET_OVERRIDE_OPTIONS
SUBTARGET_OVERRIDE_OPTIONS;
/* Add all builtins that are more or less simple operations on two
operands. */
- for (i = 0, d = bdesc_2arg; i < sizeof (bdesc_2arg) / sizeof *d; i++, d++)
+ for (i = 0, d = bdesc_2arg; i < ARRAY_SIZE (bdesc_2arg); i++, d++)
{
/* Use one of the operands; the target can have a different mode for
mask-generating compares. */
def_builtin (MASK_MMX, "__builtin_ia32_pmaddwd", v2si_ftype_v4hi_v4hi, IX86_BUILTIN_PMADDWD);
/* comi/ucomi insns. */
- for (i = 0, d = bdesc_comi; i < sizeof (bdesc_comi) / sizeof *d; i++, d++)
+ for (i = 0, d = bdesc_comi; i < ARRAY_SIZE (bdesc_comi); i++, d++)
def_builtin (d->mask, d->name, int_ftype_v4sf_v4sf, d->code);
def_builtin (MASK_MMX, "__builtin_ia32_packsswb", v8qi_ftype_v4hi_v4hi, IX86_BUILTIN_PACKSSWB);
break;
}
- for (i = 0, d = bdesc_2arg; i < sizeof (bdesc_2arg) / sizeof *d; i++, d++)
+ for (i = 0, d = bdesc_2arg; i < ARRAY_SIZE (bdesc_2arg); i++, d++)
if (d->code == fcode)
{
/* Compares are treated specially. */
return ix86_expand_binop_builtin (d->icode, arglist, target);
}
- for (i = 0, d = bdesc_1arg; i < sizeof (bdesc_1arg) / sizeof *d; i++, d++)
+ for (i = 0, d = bdesc_1arg; i < ARRAY_SIZE (bdesc_1arg); i++, d++)
if (d->code == fcode)
return ix86_expand_unop_builtin (d->icode, arglist, target, 0);
- for (i = 0, d = bdesc_comi; i < sizeof (bdesc_comi) / sizeof *d; i++, d++)
+ for (i = 0, d = bdesc_comi; i < ARRAY_SIZE (bdesc_comi); i++, d++)
if (d->code == fcode)
return ix86_expand_sse_comi (d, arglist, target);
ggc_add_rtx_root (&mips_load_reg2, 1);
ggc_add_rtx_root (&mips_load_reg3, 1);
ggc_add_rtx_root (&mips_load_reg4, 1);
- ggc_add_rtx_root (branch_cmp, sizeof (branch_cmp) / sizeof (rtx));
+ ggc_add_rtx_root (branch_cmp, ARRAY_SIZE (branch_cmp));
ggc_add_rtx_root (&embedded_pic_fnaddr_rtx, 1);
ggc_add_rtx_root (&mips16_gp_pseudo_rtx, 1);
}
{CCmode, cc_signed_convs},
{DImode, cc_di_convs}};
- unsigned int i;
+ size_t i;
int j;
enum machine_mode mode = GET_MODE (XEXP (x, 0));
RTX_CODE cc = GET_CODE (x);
- for (i = 0; i < sizeof (cc_convs)/sizeof(*cc_convs); i++)
+ for (i = 0; i < ARRAY_SIZE (cc_convs); i++)
{
if (mode == cc_convs[i].cc_mode)
{
MASK_POWERPC | MASK_SOFT_FLOAT | MASK_NEW_MNEMONICS,
POWER_MASKS | POWERPC_OPT_MASKS | MASK_POWERPC64}};
- size_t ptt_size = sizeof (processor_target_table) / sizeof (struct ptt);
+ const size_t ptt_size = ARRAY_SIZE (processor_target_table);
/* Save current -mmultiple/-mno-multiple status. */
int multiple = TARGET_MULTIPLE;
/* Handle DST variants. */
d = (struct builtin_description *) bdesc_dst;
- for (i = 0; i < sizeof (bdesc_dst) / sizeof *d; i++, d++)
+ for (i = 0; i < ARRAY_SIZE (bdesc_dst); i++, d++)
if (d->code == fcode)
{
arg0 = TREE_VALUE (arglist);
/* Expand abs* operations. */
d = (struct builtin_description *) bdesc_abs;
- for (i = 0; i < sizeof (bdesc_abs) / sizeof *d; i++, d++)
+ for (i = 0; i < ARRAY_SIZE (bdesc_abs); i++, d++)
if (d->code == fcode)
return altivec_expand_abs_builtin (d->icode, arglist, target);
/* Handle simple unary operations. */
d = (struct builtin_description *) bdesc_1arg;
- for (i = 0; i < sizeof (bdesc_1arg) / sizeof *d; i++, d++)
+ for (i = 0; i < ARRAY_SIZE (bdesc_1arg); i++, d++)
if (d->code == fcode)
return altivec_expand_unop_builtin (d->icode, arglist, target);
/* Handle simple binary operations. */
d = (struct builtin_description *) bdesc_2arg;
- for (i = 0; i < sizeof (bdesc_2arg) / sizeof *d; i++, d++)
+ for (i = 0; i < ARRAY_SIZE (bdesc_2arg); i++, d++)
if (d->code == fcode)
return altivec_expand_binop_builtin (d->icode, arglist, target);
/* Expand the AltiVec predicates. */
dp = (struct builtin_description_predicates *) bdesc_altivec_preds;
- for (i = 0; i < sizeof (bdesc_altivec_preds) / sizeof *dp; i++, dp++)
+ for (i = 0; i < ARRAY_SIZE (bdesc_altivec_preds); i++, dp++)
if (dp->code == fcode)
return altivec_expand_predicate_builtin (dp->icode, dp->opcode, arglist, target);
/* Handle simple ternary operations. */
d = (struct builtin_description *) bdesc_3arg;
- for (i = 0; i < sizeof (bdesc_3arg) / sizeof *d; i++, d++)
+ for (i = 0; i < ARRAY_SIZE (bdesc_3arg); i++, d++)
if (d->code == fcode)
return altivec_expand_ternop_builtin (d->icode, arglist, target);
/* Add the simple ternary operators. */
d = (struct builtin_description *) bdesc_3arg;
- for (i = 0; i < sizeof (bdesc_3arg) / sizeof *d; i++, d++)
+ for (i = 0; i < ARRAY_SIZE (bdesc_3arg); i++, d++)
{
enum machine_mode mode0, mode1, mode2, mode3;
/* Add the DST variants. */
d = (struct builtin_description *) bdesc_dst;
- for (i = 0; i < sizeof (bdesc_dst) / sizeof *d; i++, d++)
+ for (i = 0; i < ARRAY_SIZE (bdesc_dst); i++, d++)
def_builtin (d->mask, d->name, void_ftype_pvoid_int_char, d->code);
/* Initialize the predicates. */
dp = (struct builtin_description_predicates *) bdesc_altivec_preds;
- for (i = 0; i < sizeof (bdesc_altivec_preds) / sizeof *dp; i++, dp++)
+ for (i = 0; i < ARRAY_SIZE (bdesc_altivec_preds); i++, dp++)
{
enum machine_mode mode1;
tree type;
/* Add the simple binary operators. */
d = (struct builtin_description *) bdesc_2arg;
- for (i = 0; i < sizeof (bdesc_2arg) / sizeof *d; i++, d++)
+ for (i = 0; i < ARRAY_SIZE (bdesc_2arg); i++, d++)
{
enum machine_mode mode0, mode1, mode2;
tree type;
/* Initialize the abs* operators. */
d = (struct builtin_description *) bdesc_abs;
- for (i = 0; i < sizeof (bdesc_abs) / sizeof *d; i++, d++)
+ for (i = 0; i < ARRAY_SIZE (bdesc_abs); i++, d++)
{
enum machine_mode mode0;
tree type;
/* Add the simple unary operators. */
d = (struct builtin_description *) bdesc_1arg;
- for (i = 0; i < sizeof (bdesc_1arg) / sizeof *d; i++, d++)
+ for (i = 0; i < ARRAY_SIZE (bdesc_1arg); i++, d++)
{
enum machine_mode mode0, mode1;
tree type;
size_t i;
ups = (struct ultrasparc_pipeline_state *) arg;
- for (i = 0; i < sizeof (ups->group) / sizeof (rtx); ++i)
+ for (i = 0; i < ARRAY_SIZE (ups->group); ++i)
ggc_mark_rtx (ups->group[i]);
}
+2002-03-03 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * decl.c (cxx_init_decl_processing): Use ARRAY_SIZE in lieu of
+ explicit sizeof/sizeof.
+ * decl2.c (cxx_decode_option): Likewise.
+ * lex.c (init_reswords, REDUCE_LENGTH, TOKEN_LENGTH): Likewise.
+
2002-03-02 Nathan Sidwell <nathan@codesourcery.com>
PR c++/775
flag_const_strings = 0;
/* Add GC roots for all of our global variables. */
- ggc_add_tree_root (c_global_trees, sizeof c_global_trees / sizeof(tree));
- ggc_add_tree_root (cp_global_trees, sizeof cp_global_trees / sizeof(tree));
+ ggc_add_tree_root (c_global_trees, ARRAY_SIZE (c_global_trees));
+ ggc_add_tree_root (cp_global_trees, ARRAY_SIZE (cp_global_trees));
ggc_add_tree_root (&integer_three_node, 1);
ggc_add_tree_root (&integer_two_node, 1);
ggc_add_tree_root (&signed_size_zero_node, 1);
caller that the option was processed successfully. */
if (bsearch (&positive_option,
unsupported_options,
- (sizeof (unsupported_options)
- / sizeof (unsupported_options[0])),
+ ARRAY_SIZE (unsupported_options),
sizeof (unsupported_options[0]),
compare_options))
{
{
int found = 0;
- for (j = 0;
- !found && j < (sizeof (lang_f_options)
- / sizeof (lang_f_options[0]));
- j++)
+ for (j = 0; !found && j < ARRAY_SIZE (lang_f_options); j++)
{
if (!strcmp (p, lang_f_options[j].string))
{
{ "xor_eq", RID_XOR_EQ, D_OPNAME },
};
-#define N_reswords (sizeof reswords / sizeof (struct resword))
/* Table mapping from RID_* constants to yacc token numbers.
Unfortunately we have to have entries for all the keywords in all
all the trees it points to are permanently interned in the
get_identifier hash anyway. */
ridpointers = (tree *) xcalloc ((int) RID_MAX, sizeof (tree));
- for (i = 0; i < N_reswords; i++)
+ for (i = 0; i < ARRAY_SIZE (reswords); i++)
{
id = get_identifier (reswords[i].word);
C_RID_CODE (id) = reswords[i].rid;
int *token_count;
#if 0
-#define REDUCE_LENGTH (sizeof (yyr2) / sizeof (yyr2[0]))
-#define TOKEN_LENGTH (256 + sizeof (yytname) / sizeof (yytname[0]))
+#define REDUCE_LENGTH ARRAY_SIZE (yyr2)
+#define TOKEN_LENGTH (256 + ARRAY_SIZE (yytname))
#endif
#ifdef GATHER_STATISTICS
{ "ull", 1, 2 }, { "ULL", 1, 2 }, { "uLL", 1, 2 }, { "Ull", 1, 2 },
{ "llu", 1, 2 }, { "LLU", 1, 2 }, { "LLu", 1, 2 }, { "llU", 1, 2 }
};
-#define Nsuff(tab) (sizeof tab / sizeof (struct suffix))
/* Parse and convert what is presumably an integer in TOK. Accepts
decimal, hex, or octal with or without size suffixes. Returned op
See the suffix tables, above. */
switch (end - p)
{
- case 1: sufftab = vsuf_1; nsuff = Nsuff(vsuf_1); break;
- case 2: sufftab = vsuf_2; nsuff = Nsuff(vsuf_2); break;
- case 3: sufftab = vsuf_3; nsuff = Nsuff(vsuf_3); break;
+ case 1: sufftab = vsuf_1; nsuff = ARRAY_SIZE (vsuf_1); break;
+ case 2: sufftab = vsuf_2; nsuff = ARRAY_SIZE (vsuf_2); break;
+ case 3: sufftab = vsuf_3; nsuff = ARRAY_SIZE (vsuf_3); break;
default: goto invalid_suffix;
}
#undef C
#undef X
#undef O
-#define builtin_array_end \
- builtin_array + sizeof(builtin_array)/sizeof(struct builtin)
+#define builtin_array_end (builtin_array + ARRAY_SIZE (builtin_array))
/* Subroutine of cpp_read_main_file; reads the builtins table above and
enters them, and language-specific macros, into the hash table. */
/* Number of elements in default_compilers, not counting the terminator. */
-static int n_default_compilers
- = (sizeof default_compilers / sizeof (struct compiler)) - 1;
+static const int n_default_compilers = ARRAY_SIZE (default_compilers) - 1;
/* A vector of options to give to the linker.
These options are accumulated by %x,
#ifdef MODIFY_TARGET_NAME
is_modify_target_name = 0;
- for (j = 0;
- j < sizeof modify_target / sizeof modify_target[0]; j++)
+ for (j = 0; j < ARRAY_SIZE (modify_target); j++)
if (! strcmp (argv[i], modify_target[j].sw))
{
char *new_name
#ifdef MODIFY_TARGET_NAME
is_modify_target_name = 0;
- for (j = 0; j < sizeof modify_target / sizeof modify_target[0]; j++)
+ for (j = 0; j < ARRAY_SIZE (modify_target); j++)
if (! strcmp (argv[i], modify_target[j].sw))
is_modify_target_name = 1;
size_t i;
puts ("#ifdef RTX_CODE\n");
- for (i = 0; i < sizeof predicate / sizeof *predicate; i++)
+ for (i = 0; i < ARRAY_SIZE (predicate); i++)
printf ("extern int %s PARAMS ((rtx, enum machine_mode));\n",
predicate[i].name);
puts ("\n#endif /* RTX_CODE */\n");
/* The number of extra orders, not corresponding to power-of-two sized
objects. */
-#define NUM_EXTRA_ORDERS \
- (sizeof (extra_order_size_table) / sizeof (extra_order_size_table[0]))
+#define NUM_EXTRA_ORDERS ARRAY_SIZE (extra_order_size_table)
/* The Ith entry is the maximum size of an object to be stored in the
Ith extra order. Adding a new entry to this array is the *only*
+2002-03-03 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
+
+ * class.c (init_class_processing): Use ARRAY_SIZE in lieu of
+ explicit sizeof/sizeof.
+ * decl.c (java_init_decl_processing): Likewise.
+ * jcf-parse.c (init_jcf_parse): Likewise.
+ * parse.y (init_src_parse): Likewise.
+
2002-03-02 Per Bothner <per@bothner.com>
Make --CLASSPATH by a synonym for --classpath and -classpath.
registerClass_libfunc = gen_rtx (SYMBOL_REF, Pmode, "_Jv_RegisterClass");
registerResource_libfunc =
gen_rtx (SYMBOL_REF, Pmode, "_Jv_RegisterResource");
- ggc_add_tree_root (class_roots, sizeof (class_roots) / sizeof (tree));
+ ggc_add_tree_root (class_roots, ARRAY_SIZE (class_roots));
fields_ident = get_identifier ("fields");
info_ident = get_identifier ("info");
ggc_add_rtx_root (®isterClass_libfunc, 1);
init_jcf_parse ();
/* Register nodes with the garbage collector. */
- ggc_add_tree_root (java_global_trees,
- sizeof (java_global_trees) / sizeof (tree));
+ ggc_add_tree_root (java_global_trees, ARRAY_SIZE (java_global_trees));
ggc_add_tree_root (&decl_map, 1);
ggc_add_tree_root (&pending_local_decls, 1);
init_jcf_parse ()
{
/* Register roots with the garbage collector. */
- ggc_add_tree_root (parse_roots, sizeof (parse_roots) / sizeof(tree));
+ ggc_add_tree_root (parse_roots, ARRAY_SIZE (parse_roots));
ggc_add_root (¤t_jcf, 1, sizeof (JCF), (void (*)(void *))ggc_mark_jcf);
init_src_parse ()
{
/* Register roots with the garbage collector. */
- ggc_add_tree_root (src_parse_roots, sizeof (src_parse_roots) / sizeof(tree));
+ ggc_add_tree_root (src_parse_roots, ARRAY_SIZE (src_parse_roots));
}
\f
sbitmap *kill;
struct edge_list *edge_list;
static const int num_modes[] = NUM_MODES_FOR_MODE_SWITCHING;
-#define N_ENTITIES (sizeof num_modes / sizeof (int))
+#define N_ENTITIES ARRAY_SIZE (num_modes)
int entity_map[N_ENTITIES];
struct bb_info *bb_info[N_ENTITIES];
int i, j;
TYPE_REFERENCE_TO (sizetype_tab[i]) = 0;
}
- ggc_add_tree_root ((tree *) &sizetype_tab,
- sizeof sizetype_tab / sizeof (tree));
+ ggc_add_tree_root ((tree *) &sizetype_tab, ARRAY_SIZE (sizetype_tab));
/* Go down each of the types we already made and set the proper type
for the sizes in them. */