OSDN Git Service

Oops - forgot to include ChangeLog entry for m32r patch
[pf3gnuchains/gcc-fork.git] / gcc / gengtype.c
index 2cdff54..0ff0c11 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.
 
@@ -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
@@ -1081,13 +1083,11 @@ 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",
+      "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",
       NULL
     };
     const char *const *ifp;
@@ -1128,7 +1128,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;
         }
     }
@@ -1442,7 +1442,7 @@ output_mangled_typename (outf_p of, type_p t)
       }
       break;
     case TYPE_ARRAY:
-      abort ();
+      gcc_unreachable ();
     }
 }
 
@@ -1608,7 +1608,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 +1681,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 +1717,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 +1844,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 +1900,7 @@ walk_type (type_p t, struct walk_type_data *d)
       break;
 
     default:
-      abort ();
+      gcc_unreachable ();
     }
 }
 
@@ -1928,6 +1928,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,7 +1972,7 @@ write_types_process_field (type_p f, const struct walk_type_data *d)
       break;
 
     default:
-      abort ();
+      gcc_unreachable ();
     }
 }
 
@@ -2035,6 +2050,21 @@ 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);
+
+         if (orig_s->u.p->kind == TYPE_PARAM_STRUCT
+             && orig_s->u.p->u.s.line.file != NULL)
+           {
+             oprintf (d.of, ", gt_e_");
+             output_mangled_typename (d.of, orig_s);
+           }
+         else if (UNION_OR_STRUCT_P (orig_s)
+                  && orig_s->u.s.line.file != NULL)
+           {
+             oprintf (d.of, ", gt_ggc_e_");
+             output_mangled_typename (d.of, orig_s);
+           }
+         else
+           oprintf (d.of, ", gt_types_enum_last");
        }
       oprintf (d.of, "))\n");
     }
@@ -2045,6 +2075,21 @@ 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);
+
+         if (orig_s->u.p->kind == TYPE_PARAM_STRUCT
+             && orig_s->u.p->u.s.line.file != NULL)
+           {
+             oprintf (d.of, ", gt_e_");
+             output_mangled_typename (d.of, orig_s);
+           }
+         else if (UNION_OR_STRUCT_P (orig_s)
+                  && orig_s->u.s.line.file != NULL)
+           {
+             oprintf (d.of, ", gt_ggc_e_");
+             output_mangled_typename (d.of, orig_s);
+           }
+         else
+           oprintf (d.of, ", gt_types_enum_last");
        }
       oprintf (d.of, "))\n");
       oprintf (d.of, "   xlimit = (");
@@ -2070,6 +2115,21 @@ 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);
+
+             if (orig_s->u.p->kind == TYPE_PARAM_STRUCT
+                 && orig_s->u.p->u.s.line.file != NULL)
+               {
+                 oprintf (d.of, ", gt_e_");
+                 output_mangled_typename (d.of, orig_s);
+               }
+             else if (UNION_OR_STRUCT_P (orig_s)
+                      && orig_s->u.s.line.file != NULL)
+               {
+                 oprintf (d.of, ", gt_ggc_e_");
+                 output_mangled_typename (d.of, orig_s);
+               }
+             else
+               oprintf (d.of, ", gt_types_enum_last");
            }
          oprintf (d.of, ");\n");
          oprintf (d.of, "      }\n");
@@ -2227,7 +2287,7 @@ write_types_local_process_field (type_p f, const struct walk_type_data *d)
       break;
 
     default:
-      abort ();
+      gcc_unreachable ();
     }
 }
 
@@ -3006,7 +3066,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