OSDN Git Service

Fix typo
[pf3gnuchains/gcc-fork.git] / gcc / gengtype.c
index 2cdff54..eb3c0c1 100644 (file)
@@ -1,5 +1,5 @@
 /* Process source files and output type information.
-   Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -15,8 +15,8 @@ for more details.
 
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING.  If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.  */
+Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301, USA.  */
 
 #include "bconfig.h"
 #include "system.h"
@@ -24,7 +24,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "tm.h"
 #include "gengtype.h"
 #include "gtyp-gen.h"
-#undef abort
+#include "errors.h"
 
 /* Nonzero iff an error has occurred.  */
 static int hit_error = 0;
@@ -367,7 +367,9 @@ enum insn_note {
   NOTE_INSN_MAX
 };
 
-static const char *const note_insn_name[NOTE_INSN_MAX] = {
+/* We must allocate one more entry here, as we use NOTE_INSN_MAX as the
+   default field for line number notes.  */
+static const char *const note_insn_name[NOTE_INSN_MAX+1] = {
 #define DEF_INSN_NOTE(NAME) #NAME,
 #include "insn-notes.def"
 #undef DEF_INSN_NOTE
@@ -626,14 +628,6 @@ adjust_field_rtx_def (type_p t, options_p ARG_UNUSED (opt))
              subfields->opt->name = "desc";
              subfields->opt->info = "NOTE_LINE_NUMBER (&%0)";
            }
-         else if (t == basic_block_tp)
-           {
-             /* We don't presently GC basic block structures...  */
-             subfields->opt = XNEW (struct options);
-             subfields->opt->next = nodot;
-             subfields->opt->name = "skip";
-             subfields->opt->info = NULL;
-           }
          else
            subfields->opt = nodot;
        }
@@ -1016,8 +1010,8 @@ create_file (const char *name, const char *oname)
     "\n",
     "You should have received a copy of the GNU General Public License\n",
     "along with GCC; see the file COPYING.  If not, write to the Free\n",
-    "Software Foundation, 59 Temple Place - Suite 330, Boston, MA\n",
-    "02111-1307, USA.  */\n",
+    "Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA\n",
+    "02110-1301, USA.  */\n",
     "\n",
     "/* This file is machine generated.  Do not edit.  */\n"
   };
@@ -1081,14 +1075,12 @@ open_base_files (void)
     /* The order of files here matters very much.  */
     static const char *const ifiles [] = {
       "config.h", "system.h", "coretypes.h", "tm.h", "varray.h", 
-      "hashtab.h", "splay-tree.h", "bitmap.h", "input.h", "tree.h", "rtl.h",
-      "function.h", "insn-config.h", "expr.h", "hard-reg-set.h",
-      "basic-block.h", "cselib.h", "insn-addr.h", "optabs.h",
-      "libfuncs.h", "debug.h", "ggc.h", "cgraph.h",
-      "tree-alias-type.h", "tree-flow.h", "reload.h",
-      "cpp-id-data.h",
-      "tree-chrec.h",
-      NULL
+      "hashtab.h", "splay-tree.h",  "obstack.h", "bitmap.h", "input.h",
+      "tree.h", "rtl.h", "function.h", "insn-config.h", "expr.h",
+      "hard-reg-set.h", "basic-block.h", "cselib.h", "insn-addr.h",
+      "optabs.h", "libfuncs.h", "debug.h", "ggc.h", "cgraph.h",
+      "tree-flow.h", "reload.h", "cpp-id-data.h", "tree-chrec.h",
+      "except.h", NULL
     };
     const char *const *ifp;
     outf_p gtype_desc_c;
@@ -1128,7 +1120,7 @@ get_file_basename (const char *f)
         {
           basename -= l2 + 1;
           if ((basename - f - 1) != srcdir_len)
-            abort (); /* Match is wrong - should be preceded by $srcdir.  */
+           fatal ("filename `%s' should be preceded by $srcdir", f);
           break;
         }
     }
@@ -1238,6 +1230,15 @@ get_output_file_with_visibility (const char *input_file)
     output_name = "gt-c-common.h", for_name = "c-common.c";
   else if (strcmp (basename, "c-tree.h") == 0)
     output_name = "gt-c-decl.h", for_name = "c-decl.c";
+  else if (strncmp (basename, "cp", 2) == 0 && IS_DIR_SEPARATOR (basename[2])
+          && strcmp (basename + 3, "cp-tree.h") == 0)
+    output_name = "gt-cp-tree.h", for_name = "cp/tree.c";
+  else if (strncmp (basename, "cp", 2) == 0 && IS_DIR_SEPARATOR (basename[2])
+          && strcmp (basename + 3, "decl.h") == 0)
+    output_name = "gt-cp-decl.h", for_name = "cp/decl.c";
+  else if (strncmp (basename, "cp", 2) == 0 && IS_DIR_SEPARATOR (basename[2])
+          && strcmp (basename + 3, "name-lookup.h") == 0)
+    output_name = "gt-cp-name-lookup.h", for_name = "cp/name-lookup.c";
   else if (strncmp (basename, "objc", 4) == 0 && IS_DIR_SEPARATOR (basename[4])
           && strcmp (basename + 5, "objc-act.h") == 0)
     output_name = "gt-objc-objc-act.h", for_name = "objc/objc-act.c";
@@ -1442,7 +1443,7 @@ output_mangled_typename (outf_p of, type_p t)
       }
       break;
     case TYPE_ARRAY:
-      abort ();
+      gcc_unreachable ();
     }
 }
 
@@ -1608,7 +1609,7 @@ walk_type (type_p t, struct walk_type_data *d)
        if (maybe_undef_p
            && t->u.p->u.s.line.file == NULL)
          {
-           oprintf (d->of, "%*sif (%s) abort();\n", d->indent, "", d->val);
+           oprintf (d->of, "%*sgcc_assert (!%s);\n", d->indent, "", d->val);
            break;
          }
 
@@ -1681,7 +1682,7 @@ walk_type (type_p t, struct walk_type_data *d)
            oprintf (d->of, "%*sif (%s != NULL) {\n", d->indent, "", d->val);
            d->indent += 2;
            oprintf (d->of, "%*ssize_t i%d;\n", d->indent, "", loopcounter);
-           oprintf (d->of, "%*sfor (i%d = 0; i%d < (size_t)(", d->indent, "",
+           oprintf (d->of, "%*sfor (i%d = 0; i%d != (size_t)(", d->indent, "",
                     loopcounter, loopcounter);
            output_escaped_param (d, length, "length");
            oprintf (d->of, "); i%d++) {\n", loopcounter);
@@ -1717,7 +1718,7 @@ walk_type (type_p t, struct walk_type_data *d)
        oprintf (d->of, "%*s{\n", d->indent, "");
        d->indent += 2;
        oprintf (d->of, "%*ssize_t i%d;\n", d->indent, "", loopcounter);
-       oprintf (d->of, "%*sfor (i%d = 0; i%d < (size_t)(", d->indent, "",
+       oprintf (d->of, "%*sfor (i%d = 0; i%d != (size_t)(", d->indent, "",
                 loopcounter, loopcounter);
        if (length)
          output_escaped_param (d, length, "length");
@@ -1844,7 +1845,7 @@ walk_type (type_p t, struct walk_type_data *d)
            d->used_length = false;
 
            if (union_p && use_param_p && d->param == NULL)
-             oprintf (d->of, "%*sabort();\n", d->indent, "");
+             oprintf (d->of, "%*sgcc_unreachable ();\n", d->indent, "");
            else
              walk_type (f->type, d);
 
@@ -1900,7 +1901,7 @@ walk_type (type_p t, struct walk_type_data *d)
       break;
 
     default:
-      abort ();
+      gcc_unreachable ();
     }
 }
 
@@ -1928,6 +1929,21 @@ write_types_process_field (type_p f, const struct walk_type_data *d)
            }
          else
            oprintf (d->of, ", gt_%sa_%s", wtd->param_prefix, d->prev_val[0]);
+
+         if (f->u.p->kind == TYPE_PARAM_STRUCT
+             && f->u.p->u.s.line.file != NULL)
+           {
+             oprintf (d->of, ", gt_e_");
+             output_mangled_typename (d->of, f);
+           }
+         else if (UNION_OR_STRUCT_P (f)
+                  && f->u.p->u.s.line.file != NULL)
+           {
+             oprintf (d->of, ", gt_ggc_e_");
+             output_mangled_typename (d->of, f);
+           }
+         else
+           oprintf (d->of, ", gt_types_enum_last");
        }
       oprintf (d->of, ");\n");
       if (d->reorder_fn && wtd->reorder_note_routine)
@@ -1957,10 +1973,29 @@ write_types_process_field (type_p f, const struct walk_type_data *d)
       break;
 
     default:
-      abort ();
+      gcc_unreachable ();
     }
 }
 
+/* A subroutine of write_func_for_structure.  Write the enum tag for S.  */
+
+static void
+output_type_enum (outf_p of, type_p s)
+{
+  if (s->kind == TYPE_PARAM_STRUCT && s->u.s.line.file != NULL)
+    {
+      oprintf (of, ", gt_e_");
+      output_mangled_typename (of, s);
+    }
+  else if (UNION_OR_STRUCT_P (s) && s->u.s.line.file != NULL)
+    {
+      oprintf (of, ", gt_ggc_e_");
+      output_mangled_typename (of, s);
+    }
+  else
+    oprintf (of, ", gt_types_enum_last");
+}
+
 /* For S, a structure that's part of ORIG_S, and using parameters
    PARAM, write out a routine that:
    - Takes a parameter, a void * but actually of type *S
@@ -2035,6 +2070,7 @@ write_func_for_structure (type_p orig_s, type_p s, type_p *param,
        {
          oprintf (d.of, ", x, gt_%s_", wtd->param_prefix);
          output_mangled_typename (d.of, orig_s);
+         output_type_enum (d.of, orig_s);
        }
       oprintf (d.of, "))\n");
     }
@@ -2045,6 +2081,7 @@ write_func_for_structure (type_p orig_s, type_p s, type_p *param,
        {
          oprintf (d.of, ", xlimit, gt_%s_", wtd->param_prefix);
          output_mangled_typename (d.of, orig_s);
+         output_type_enum (d.of, orig_s);
        }
       oprintf (d.of, "))\n");
       oprintf (d.of, "   xlimit = (");
@@ -2070,6 +2107,7 @@ write_func_for_structure (type_p orig_s, type_p s, type_p *param,
            {
              oprintf (d.of, ", xprev, gt_%s_", wtd->param_prefix);
              output_mangled_typename (d.of, orig_s);
+             output_type_enum (d.of, orig_s);
            }
          oprintf (d.of, ");\n");
          oprintf (d.of, "      }\n");
@@ -2227,7 +2265,7 @@ write_types_local_process_field (type_p f, const struct walk_type_data *d)
       break;
 
     default:
-      abort ();
+      gcc_unreachable ();
     }
 }
 
@@ -3006,7 +3044,7 @@ main(int ARG_UNUSED (argc), char ** ARG_UNUSED (argv))
         parse_file (all_files[i]);
 #ifndef USE_MAPPED_LOCATION
       /* temporary kludge - gengtype doesn't handle conditionals.
-        Manually add source_locus *after* we've processed input.h. */
+        Manually add source_locus *after* we've processed input.h.  */
       if (i == 0)
        do_typedef ("source_locus", create_pointer (resolve_typedef ("location_t", &pos)), &pos);
 #endif