utils.c (init_gigi_decls): Use ARRAY_SIZE in lieu of explicit array size calculation.
authorKaveh R. Ghazi <ghazi@caip.rutgers.edu>
Thu, 20 Jun 2002 17:38:23 +0000 (17:38 +0000)
committerKaveh Ghazi <ghazi@gcc.gnu.org>
Thu, 20 Jun 2002 17:38:23 +0000 (17:38 +0000)
ada:
* utils.c (init_gigi_decls): Use ARRAY_SIZE in lieu of explicit
array size calculation.

gcc:
* c-decl.c (c_decode_option): Use ARRAY_SIZE in lieu of explicit
array size calculation.
* gengtype.c (NUM_BASE_FILES, create_file, write_gc_root):
Likewise.

cp:
* spew.c (remove_last_token): Use ARRAY_SIZE in lieu of explicit
array size calculation.

From-SVN: r54842

gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/utils.c
gcc/c-decl.c
gcc/cp/ChangeLog
gcc/cp/spew.c
gcc/gengtype.c

index 9ba7f390b8f6b938b2b57881216c20787257f98b..f3796e22084fbc56ba363bf003234ff9cee38b28 100644 (file)
@@ -1,5 +1,10 @@
 2002-06-20  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
+       * c-decl.c (c_decode_option): Use ARRAY_SIZE in lieu of explicit
+       array size calculation.
+       * gengtype.c (NUM_BASE_FILES, create_file, write_gc_root):
+       Likewise.
+
        * diagnostic.c (diagnostic_kind_text): Const-ify.
        * gengtype.c (lang_names): Likewise.
 
index d6ae69c7ae6373d32477f8806d4c16cda55f16eb..7ecd0257f5330befc0191248863cc7d573a4abb5 100644 (file)
@@ -1,3 +1,8 @@
+2002-06-20  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       * utils.c (init_gigi_decls): Use ARRAY_SIZE in lieu of explicit
+       array size calculation.
+
 2002-06-04  Andreas Jaeger  <aj@suse.de>
 
        * Make-lang.in (gnatbind): Readd rule that has been lost in last
index 11cee7568d46911a6e1d5cf51e2dec3c79523dc7..d820401f20f584be458a78cad83bbde2ae1b2695 100644 (file)
@@ -625,13 +625,12 @@ init_gigi_decls (long_long_float_type, exception_type)
                                                      endlink))),
           NULL_TREE, 0, 1, 1, 0);
 
-      for (i = 0; i < sizeof gnat_raise_decls / sizeof gnat_raise_decls[0];
-          i++)
+      for (i = 0; i < ARRAY_SIZE (gnat_raise_decls); i++)
        gnat_raise_decls[i] = decl;
     }
   else
     /* Otherwise, make one decl for each exception reason.  */
-    for (i = 0; i < sizeof gnat_raise_decls / sizeof gnat_raise_decls[0]; i++)
+    for (i = 0; i < ARRAY_SIZE (gnat_raise_decls); i++)
       {
        char name[17];
 
@@ -656,7 +655,7 @@ init_gigi_decls (long_long_float_type, exception_type)
     = build_qualified_type (TREE_TYPE (raise_nodefer_decl),
                            TYPE_QUAL_VOLATILE);
 
-  for (i = 0; i < sizeof gnat_raise_decls / sizeof gnat_raise_decls[0]; i++)
+  for (i = 0; i < ARRAY_SIZE (gnat_raise_decls); i++)
     {
       TREE_THIS_VOLATILE (gnat_raise_decls[i]) = 1;
       TREE_SIDE_EFFECTS (gnat_raise_decls[i]) = 1;
index 96233e34230cc8474153a6acdc68dc469299ffeb..23134e385b7b86c82417b9d97364b6b5a0caf3e3 100644 (file)
@@ -697,7 +697,7 @@ c_decode_option (argc, argv)
   else
     {
       size_t i;
-      for (i = 0; i < sizeof (warn_options) / sizeof (warn_options[0]); i++)
+      for (i = 0; i < ARRAY_SIZE (warn_options); i++)
        if (strncmp (p, "-W", 2) == 0 
            && warn_options[i].flag
            && (strcmp (p+2, warn_options[i].option) == 0
index b3df1ad53ff6b06f1bef4e70a86d346f6b55f363..4a37ab3fe0bdfa348d07b6eed9aa2463e52f86a2 100644 (file)
@@ -1,3 +1,8 @@
+2002-06-20  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
+
+       * spew.c (remove_last_token): Use ARRAY_SIZE in lieu of explicit
+       array size calculation.
+
 2002-06-20  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        PR c++/6892
index 8abf8dcee7b2c537555f53565b6016d6829b4a64..56990a4117506236d25d537af0b76211192d9944 100644 (file)
@@ -1063,7 +1063,7 @@ remove_last_token (t)
       for (tc = &t->tokens; (*tc)->next != NULL; tc = &(*tc)->next)
        ;
       *tc = NULL;
-      t->last_pos = sizeof ((*tc)->toks) / sizeof ((*tc)->toks[0]);
+      t->last_pos = ARRAY_SIZE ((*tc)->toks);
     }
   return result;
 }
index 30dea5a12aebfe3007807f05d7c98ad8dea559c4..e58fc35dd8608d6bf7163b80be661c1a4eebea02 100644 (file)
@@ -525,7 +525,7 @@ enum {
 static const char *const lang_names[] = {
   "c", "objc", "cp", "treelang", "cobol", "f", "ada", "java"
 };
-#define NUM_BASE_FILES (sizeof (lang_names) / sizeof (lang_names[0]))
+#define NUM_BASE_FILES ARRAY_SIZE (lang_names)
 outf_p base_files[NUM_BASE_FILES];
 
 static outf_p create_file PARAMS ((const char *, const char *));
@@ -570,7 +570,7 @@ create_file (name, oname)
   output_files = f;
 
   oprintf (f, "/* Type information for %s.\n", name);
-  for (i = 0; i < sizeof(hdr)/sizeof(hdr[0]); i++)
+  for (i = 0; i < ARRAY_SIZE (hdr); i++)
     oprintf (f, "%s", hdr[i]);
   return f;
 }
@@ -1626,8 +1626,7 @@ write_gc_root (f, v, type, name, has_length, line, if_marked)
          if (ap->u.a.len[0])
            oprintf (f, " * (%s)", ap->u.a.len);
          else if (ap == v->type)
-           oprintf (f, " * (sizeof (%s) / sizeof (%s[0]))",
-                    v->name, v->name);
+           oprintf (f, " * ARRAY_SIZE (%s)", v->name);
        oprintf (f, ",\n");
        oprintf (f, "    sizeof (%s", v->name);
        for (ap = v->type; ap->kind == TYPE_ARRAY; ap = ap->u.a.p)