]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
debug.h (struct gcc_debug_hooks): Add type_decl field.
authorZack Weinberg <zack@codesourcery.com>
Thu, 12 Feb 2004 21:42:28 +0000 (21:42 +0000)
committerZack Weinberg <zack@gcc.gnu.org>
Thu, 12 Feb 2004 21:42:28 +0000 (21:42 +0000)
* debug.h (struct gcc_debug_hooks): Add type_decl field.
(debug_nothing_tree_int): Prototype.
(dwarf_debug_hooks): Delete, unused.
* debug.c (do_nothing_debug_hooks): Update.
(debug_nothing_tree_int): New function.
* langhooks.h (struct lang_hooks_for_decls):
Remove builtin_type_decls field.
* langhooks-def.h (LANG_HOOKS_BUILTIN_TYPE_DECLS): Delete.
(LANG_HOOKS_DECLS): Update.
* toplev.c (rest_of_decl_compilation, rest_of_type_compilation):
Use debug_hooks->type_decl.
* dbxout.c (preinit_symbols): New static.
(dbx_debug_hooks, xcoff_debug_hooks): Update.
(dbxout_init): Don't call DBX_OUTPUT_STANDARD_TYPES or
lang_hooks.decls.builtin_type_decls.  Do scan preinit_symbols
for symbols to output.
(dbxout_type_decl): New function.
(dbxout_symbol): If called before dbxout_init has run, queue
the symbol for later.  Apply DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER
to TYPE_DECLs before emitting them.
* xcoffout.c (assign_type_number): Delete.
(xcoff_type_numbers): New static table.
(xcoff_assign_fundamental_type_number): New function.
* xcoffout.h: Define DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER, not
DBX_OUTPUT_STANDARD_TYPES.  Remove unnecessary #ifdefs.
* sdbout.c: Include varray.h.
(deferred_global_decls): New static.
(sdb_debug_hooks): Update.
(sdbout_global_decl): If we can't emit something right now,
remember it in deferred_global_decls.
(sdbout_finish): Just scan deferred_global_decls; don't call getdecls.
(sdbout_init): Initialize deferred_global_decls.
* Makefile.in: Update dependencies of sdbout.o.
* dwarf2out.c (dwarf2out_type_decl): New function.
(dwarf2_debug_hooks): Update.
* vmsdbgout.c (vmsdbg_debug_hooks): Update.
* c-decl.c (getdecls): Just return 0.
(check_for_loop_decls): Don't use getdecls.
(record_builtin_type): Call debug_hooks->type_decl on the TYPE_DECL.
* c-objc-common.c (c_objc_common_finish_file): Don't use getdecls.
cp:
* cp-lang.c: Don't define LANG_HOOKS_BUILTIN_TYPE_DECLS.
* cp-tree.h: Don't declare cxx_builtin_type_decls.
* decl.c (builtin_type_decls, cxx_builtin_type_decls): Delete.
(record_builtin_type): Call debug_hooks->type_decl on the TYPE_DECL.

From-SVN: r77730

19 files changed:
gcc/ChangeLog
gcc/Makefile.in
gcc/c-decl.c
gcc/c-objc-common.c
gcc/cp/ChangeLog
gcc/cp/cp-lang.c
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/dbxout.c
gcc/debug.c
gcc/debug.h
gcc/dwarf2out.c
gcc/langhooks-def.h
gcc/langhooks.h
gcc/sdbout.c
gcc/toplev.c
gcc/vmsdbgout.c
gcc/xcoffout.c
gcc/xcoffout.h

index d252e8ca51239707ede127c3c17856cff5a0737f..9d75e321b452d7ffbfc3c651c9944bcf62cd328b 100644 (file)
@@ -1,3 +1,46 @@
+2004-02-12  Zack Weinberg  <zack@codesourcery.com>
+
+       * debug.h (struct gcc_debug_hooks): Add type_decl field.
+       (debug_nothing_tree_int): Prototype.
+       (dwarf_debug_hooks): Delete, unused.
+       * debug.c (do_nothing_debug_hooks): Update.
+       (debug_nothing_tree_int): New function.
+       * langhooks.h (struct lang_hooks_for_decls):
+       Remove builtin_type_decls field.
+       * langhooks-def.h (LANG_HOOKS_BUILTIN_TYPE_DECLS): Delete.
+       (LANG_HOOKS_DECLS): Update.
+       * toplev.c (rest_of_decl_compilation, rest_of_type_compilation):
+       Use debug_hooks->type_decl.
+       * dbxout.c (preinit_symbols): New static.
+       (dbx_debug_hooks, xcoff_debug_hooks): Update.
+       (dbxout_init): Don't call DBX_OUTPUT_STANDARD_TYPES or
+       lang_hooks.decls.builtin_type_decls.  Do scan preinit_symbols
+       for symbols to output.
+       (dbxout_type_decl): New function.
+       (dbxout_symbol): If called before dbxout_init has run, queue
+       the symbol for later.  Apply DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER
+       to TYPE_DECLs before emitting them.
+       * xcoffout.c (assign_type_number): Delete.
+       (xcoff_type_numbers): New static table.
+       (xcoff_assign_fundamental_type_number): New function.
+       * xcoffout.h: Define DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER, not
+       DBX_OUTPUT_STANDARD_TYPES.  Remove unnecessary #ifdefs.
+       * sdbout.c: Include varray.h.
+       (deferred_global_decls): New static.
+       (sdb_debug_hooks): Update.
+       (sdbout_global_decl): If we can't emit something right now,
+       remember it in deferred_global_decls.
+       (sdbout_finish): Just scan deferred_global_decls; don't call getdecls.
+       (sdbout_init): Initialize deferred_global_decls.
+       * Makefile.in: Update dependencies of sdbout.o.
+       * dwarf2out.c (dwarf2out_type_decl): New function.
+       (dwarf2_debug_hooks): Update.
+       * vmsdbgout.c (vmsdbg_debug_hooks): Update.
+       * c-decl.c (getdecls): Just return 0.
+       (check_for_loop_decls): Don't use getdecls.
+       (record_builtin_type): Call debug_hooks->type_decl on the TYPE_DECL.
+       * c-objc-common.c (c_objc_common_finish_file): Don't use getdecls.
+
 2004-02-12  Ulrich Weigand  <uweigand@de.ibm.com>
 
        * config/s390/s390.c (s390_sched_reorder2): Remove.
index e59c8f5f0924397b416f49c36f574ffcfe01515d..22640847394a4508344553efe345882a5d68db7a 100644 (file)
@@ -1605,10 +1605,10 @@ dbxout.o : dbxout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(RTL_
    insn-config.h reload.h gstab.h xcoffout.h output.h dbxout.h toplev.h \
    $(GGC_H) gt-dbxout.h
 debug.o : debug.c debug.h $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H)
-sdbout.o : sdbout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(RTL_H) \
-   flags.h function.h $(EXPR_H) output.h hard-reg-set.h $(REGS_H) real.h \
-   insn-config.h xcoffout.h c-pragma.h $(GGC_H) $(TARGET_H) \
-   sdbout.h toplev.h $(TM_P_H) except.h debug.h langhooks.h gt-sdbout.h
+sdbout.o : sdbout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) debug.h \
+   $(TREE_H) $(GGC_H) varray.h $(RTL_H) $(REGS_H) flags.h insn-config.h \
+   output.h toplev.h $(TM_P_H) gsyms.h langhooks.h $(TARGET_H) sdbout.h \
+   gt-sdbout.h
 dwarf2out.o : dwarf2out.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
    $(TREE_H) $(RTL_H) dwarf2.h debug.h flags.h insn-config.h reload.h \
    output.h $(DIAGNOSTIC_H) real.h hard-reg-set.h $(REGS_H) $(EXPR_H) \
index 87d24a9ead495f57ee8f2b28f8dec0cc6fa128e1..0487e03d0c9c48815bc1214a2a6560fcc7a95f86 100644 (file)
@@ -2056,12 +2056,13 @@ define_label (location_t location, tree name)
   return label;
 }
 \f
-/* Return the list of declarations of the current scope.  */
+/* Return the list of declarations of the current scope.
+   This hook is optional and not implemented for C.  */
 
 tree
 getdecls (void)
 {
-  return current_scope->names;
+  return 0;
 }
 
 \f
@@ -6197,7 +6198,7 @@ check_for_loop_decls (void)
         }
     }
 
-  for (t = getdecls (); t; t = TREE_CHAIN (t))
+  for (t = current_scope->names; t; t = TREE_CHAIN (t))
     {
       if (TREE_CODE (t) != VAR_DECL && DECL_NAME (t))
        error ("%Jdeclaration of non-variable '%D' in 'for' loop "
@@ -6380,11 +6381,14 @@ void
 record_builtin_type (enum rid rid_index, const char *name, tree type)
 {
   tree id;
+  tree tdecl;
   if (name == 0)
     id = ridpointers[(int) rid_index];
   else
     id = get_identifier (name);
-  pushdecl (build_decl (TYPE_DECL, id, type));
+  tdecl = build_decl (TYPE_DECL, id, type);
+  pushdecl (tdecl);
+  debug_hooks->type_decl (tdecl, 0);
 }
 
 /* Build the void_list_node (void_type_node having been created).  */
index d044ba9cb65e76717ed73d1109eadb5de6570433..d011ef4f5af9403d97c798acae0d015cf59ceebb 100644 (file)
@@ -265,17 +265,6 @@ c_objc_common_finish_file (void)
 
       finish_cdtor (body);
     }
-
-  {
-    int flags;
-    FILE *stream = dump_begin (TDI_all, &flags);
-
-    if (stream)
-      {
-       dump_node (getdecls (), flags & ~TDF_SLIM, stream);
-       dump_end (TDI_all, stream);
-      }
-  }
 }
 
 /* Called during diagnostic message formatting process to print a
index 97b1d7cd467cba639141318ac6c824776ec5ca1f..c7ddf37efc508d994e1307dd9ab0a1d8b4835e3f 100644 (file)
@@ -1,3 +1,10 @@
+2004-02-12  Zack Weinberg  <zack@codesourcery.com>
+
+       * cp-lang.c: Don't define LANG_HOOKS_BUILTIN_TYPE_DECLS.
+       * cp-tree.h: Don't declare cxx_builtin_type_decls.
+       * decl.c (builtin_type_decls, cxx_builtin_type_decls): Delete.
+       (record_builtin_type): Call debug_hooks->type_decl on the TYPE_DECL.
+
 2004-02-10  Mark Mitchell  <mark@codesourcery.com>
 
        * typeck.c (lookup_destructor): Fix typo in error message.
index f1f5eedcc548e75ad7d391606ea0db4eec3078dc..eda846826793f0a400edbf6a167a88f0c5d30394 100644 (file)
@@ -102,8 +102,6 @@ static void cxx_initialize_diagnostics (diagnostic_context *);
 #define LANG_HOOKS_DECL_PRINTABLE_NAME cxx_printable_name
 #undef LANG_HOOKS_PRINT_ERROR_FUNCTION
 #define LANG_HOOKS_PRINT_ERROR_FUNCTION        cxx_print_error_function
-#undef LANG_HOOKS_BUILTIN_TYPE_DECLS
-#define LANG_HOOKS_BUILTIN_TYPE_DECLS cxx_builtin_type_decls
 #undef LANG_HOOKS_PUSHLEVEL
 #define LANG_HOOKS_PUSHLEVEL lhd_do_nothing_i
 #undef LANG_HOOKS_POPLEVEL
index 64b9549b876b86ff8f72b9b870d1edeb63a2d384..91997270c9e210ece2aea6317da3c122f7cf50fa 100644 (file)
@@ -3707,7 +3707,6 @@ extern void register_dtor_fn                    (tree);
 extern tmpl_spec_kind current_tmpl_spec_kind    (int);
 extern tree cp_fname_init                      (const char *, tree *);
 extern tree check_elaborated_type_specifier     (enum tag_types, tree, bool);
-extern tree cxx_builtin_type_decls              (void);
 extern void warn_extern_redeclared_static (tree, tree);
 
 extern bool have_extern_spec;
index 3f9feac4737835cb2ee3a3be592d8eef36ace48d..a343e6ac357115e100cefdd9c5fd54788c20cefd 100644 (file)
@@ -2748,18 +2748,6 @@ make_unbound_class_template (tree context, tree name, tsubst_flags_t complain)
 
 \f
 
-/* A chain of TYPE_DECLs for the builtin types.  */
-
-static GTY(()) tree builtin_type_decls;
-
-/* Return a chain of TYPE_DECLs for the builtin types.  */
-
-tree
-cxx_builtin_type_decls (void)
-{
-  return builtin_type_decls;
-}
-
 /* Push the declarations of builtin types into the namespace.
    RID_INDEX is the index of the builtin type in the array
    RID_POINTERS.  NAME is the name used when looking up the builtin
@@ -2803,10 +2791,7 @@ record_builtin_type (enum rid rid_index,
     TYPE_NAME (type) = tdecl;
 
   if (tdecl)
-    {
-      TREE_CHAIN (tdecl) = builtin_type_decls;
-      builtin_type_decls = tdecl;
-    }
+    debug_hooks->type_decl (tdecl, 0);
 }
 
 /* Record one of the standard Java types.
index e020d03f47a6887fd757544528a67a1071f08b99..0fe6c0bd2c8a76aae28d08fd804b5d7e116c3afa 100644 (file)
@@ -179,6 +179,12 @@ static GTY(()) int typevec_len;
 
 static GTY(()) int next_type_number;
 
+/* The C front end may call dbxout_symbol before dbxout_init runs.
+   We save all such decls in this list and output them when we get
+   to dbxout_init.  */
+
+static GTY(()) tree preinit_symbols;
+
 enum binclstatus {BINCL_NOT_REQUIRED, BINCL_PENDING, BINCL_PROCESSED};
 
 /* When using N_BINCL in dbx output, each type number is actually a
@@ -371,6 +377,7 @@ static void dbxout_begin_function (tree);
 static void dbxout_begin_block (unsigned, unsigned);
 static void dbxout_end_block (unsigned, unsigned);
 static void dbxout_function_decl (tree);
+static void dbxout_type_decl (tree, int);
 
 const struct gcc_debug_hooks dbx_debug_hooks =
 {
@@ -396,6 +403,7 @@ const struct gcc_debug_hooks dbx_debug_hooks =
   debug_nothing_int,                    /* end_function */
   dbxout_function_decl,
   dbxout_global_decl,                   /* global_decl */
+  dbxout_type_decl,                     /* type_decl */
   debug_nothing_tree_tree,               /* imported_module_or_decl */
   debug_nothing_tree,                   /* deferred_inline_function */
   debug_nothing_tree,                   /* outlining_inline_function */
@@ -425,6 +433,7 @@ const struct gcc_debug_hooks xcoff_debug_hooks =
   xcoffout_end_function,
   debug_nothing_tree,                   /* function_decl */
   dbxout_global_decl,                   /* global_decl */
+  dbxout_type_decl,                     /* type_decl */
   debug_nothing_tree_tree,               /* imported_module_or_decl */
   debug_nothing_tree,                   /* deferred_inline_function */
   debug_nothing_tree,                   /* outlining_inline_function */
@@ -537,22 +546,20 @@ dbxout_init (const char *input_file_name)
   current_file->pending_bincl_name = NULL;
 #endif
 
-  /* Make sure that types `int' and `char' have numbers 1 and 2.
-     Definitions of other integer types will refer to those numbers.
-     (Actually it should no longer matter what their numbers are.
-     Also, if any types with tags have been defined, dbxout_symbol
-     will output them first, so the numbers won't be 1 and 2.  That
-     happens in C++.  So it's a good thing it should no longer matter).  */
-
-#ifdef DBX_OUTPUT_STANDARD_TYPES
-  DBX_OUTPUT_STANDARD_TYPES (syms);
-#endif
-
   /* Get all permanent types that have typedef names, and output them
      all, except for those already output.  Some language front ends
-     put these declarations in the top-level scope; some do not.  */
-  dbxout_typedefs ((*lang_hooks.decls.builtin_type_decls) ());
+     put these declarations in the top-level scope; some do not;
+     the latter are responsible for calling debug_hooks->type_decl from
+     their record_builtin_type function.  */
   dbxout_typedefs (syms);
+
+  if (preinit_symbols)
+    {
+      tree t;
+      for (t = nreverse (preinit_symbols); t; t = TREE_CHAIN (t))
+       dbxout_symbol (TREE_VALUE (t), 0);
+      preinit_symbols = 0;
+    }
 }
 
 /* Output any typedef names for types described by TYPE_DECLs in SYMS.  */
@@ -805,6 +812,14 @@ dbxout_global_decl (tree decl)
     }
 }
 
+/* This is just a function-type adapter; dbxout_symbol does exactly
+   what we want but returns an int.  */
+static void
+dbxout_type_decl (tree decl, int local)
+{
+  dbxout_symbol (decl, local);
+}
+
 /* At the end of compilation, finish writing the symbol table.
    Unless you define DBX_OUTPUT_MAIN_SOURCE_FILE_END, the default is
    to do nothing.  */
@@ -2064,14 +2079,22 @@ dbxout_symbol (tree decl, int local ATTRIBUTE_UNUSED)
      symbol nodees are flagged with TREE_USED.  Ignore any that
      aren't flaged as TREE_USED.  */
 
+  if (flag_debug_only_used_symbols
+      && (!TREE_USED (decl)
+          && (TREE_CODE (decl) != VAR_DECL || !DECL_INITIAL (decl))))
+    DBXOUT_DECR_NESTING_AND_RETURN (0);
+
+  /* If dbxout_init has not yet run, queue this symbol for later.  */
+  if (!typevec)
+    {
+      preinit_symbols = tree_cons (0, decl, preinit_symbols);
+      DBXOUT_DECR_NESTING_AND_RETURN (0);
+    }
+
   if (flag_debug_only_used_symbols)
     {
       tree t;
 
-      if (!TREE_USED (decl)
-          && (TREE_CODE (decl) != VAR_DECL || !DECL_INITIAL (decl)))
-        DBXOUT_DECR_NESTING_AND_RETURN (0);
-
       /* We now have a used symbol.  We need to generate the info for
          the symbol's type in addition to the symbol itself.  These
          type symbols are queued to be generated after were done with
@@ -2175,6 +2198,20 @@ dbxout_symbol (tree decl, int local ATTRIBUTE_UNUSED)
       if (TREE_ASM_WRITTEN (decl) || TYPE_DECL_SUPPRESS_DEBUG (decl))
        DBXOUT_DECR_NESTING_AND_RETURN (0);
 
+      /* Don't output typedefs for types with magic type numbers (XCOFF).  */
+#ifdef DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER
+      {
+       int fundamental_type_number =
+         DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER (decl);
+
+       if (fundamental_type_number != 0)
+         {
+           TREE_ASM_WRITTEN (decl) = 1;
+           TYPE_SYMTAB_ADDRESS (TREE_TYPE (decl)) = fundamental_type_number;
+           DBXOUT_DECR_NESTING_AND_RETURN (0);
+         }
+      }
+#endif
       FORCE_TEXT;
       result = 1;
       {
index 18d5bc8cae23c5ca315684cd53c8ac4bf416d0ab..812920604ba636a5f13b39824c42e6a88b2e8fe2 100644 (file)
@@ -41,6 +41,7 @@ const struct gcc_debug_hooks do_nothing_debug_hooks =
   debug_nothing_int,                    /* end_function */
   debug_nothing_tree,                   /* function_decl */
   debug_nothing_tree,                   /* global_decl */
+  debug_nothing_tree_int,               /* type_decl */
   debug_nothing_tree_tree,               /* imported_module_or_decl */
   debug_nothing_tree,                   /* deferred_inline_function */
   debug_nothing_tree,                   /* outlining_inline_function */
@@ -100,3 +101,9 @@ debug_nothing_int_int (unsigned int line ATTRIBUTE_UNUSED,
                       unsigned int n ATTRIBUTE_UNUSED)
 {
 }
+
+void
+debug_nothing_tree_int (tree decl ATTRIBUTE_UNUSED,
+                       int local ATTRIBUTE_UNUSED)
+{
+}
index 448b028ea798014c828f3a438d979083417c41e3..547b7f68eab209d864e69d70a2e2b798fe463aa2 100644 (file)
@@ -89,6 +89,14 @@ struct gcc_debug_hooks
      compilation proper has finished.  */
   void (* global_decl) (tree decl);
 
+  /* Debug information for a type DECL.  Called from toplev.c after
+     compilation proper, also from various language front ends to
+     record built-in types.  The second argument is properly a
+     boolean, which indicates whether or not the type is a "local"
+     type as determined by the language.  (It's not a boolean for
+     legacy reasons.)  */
+  void (* type_decl) (tree decl, int local);
+
   /* Debug information for imported modules and declarations.  */
   void (* imported_module_or_decl) (tree decl, tree context);
 
@@ -122,6 +130,7 @@ extern void debug_nothing_int_charstar (unsigned int, const char *);
 extern void debug_nothing_int (unsigned int);
 extern void debug_nothing_int_int (unsigned int, unsigned int);
 extern void debug_nothing_tree (tree);
+extern void debug_nothing_tree_int (tree, int);
 extern void debug_nothing_tree_tree (tree, tree);
 extern bool debug_true_tree (tree);
 extern void debug_nothing_rtx (rtx);
@@ -131,7 +140,6 @@ extern const struct gcc_debug_hooks do_nothing_debug_hooks;
 extern const struct gcc_debug_hooks dbx_debug_hooks;
 extern const struct gcc_debug_hooks sdb_debug_hooks;
 extern const struct gcc_debug_hooks xcoff_debug_hooks;
-extern const struct gcc_debug_hooks dwarf_debug_hooks;
 extern const struct gcc_debug_hooks dwarf2_debug_hooks;
 extern const struct gcc_debug_hooks vmsdbg_debug_hooks;
 
index 7bb4562b20627f89e659e1f2fd75527d381f1c78..91a4705021e3fe3ebd8b49f94236ba7c4a1b379a 100644 (file)
@@ -3249,6 +3249,7 @@ static void dwarf2out_begin_block (unsigned, unsigned);
 static void dwarf2out_end_block (unsigned, unsigned);
 static bool dwarf2out_ignore_block (tree);
 static void dwarf2out_global_decl (tree);
+static void dwarf2out_type_decl (tree, int);
 static void dwarf2out_imported_module_or_decl (tree, tree);
 static void dwarf2out_abstract_function (tree);
 static void dwarf2out_var_location (rtx);
@@ -3275,6 +3276,7 @@ const struct gcc_debug_hooks dwarf2_debug_hooks =
   debug_nothing_int,           /* end_function */
   dwarf2out_decl,              /* function_decl */
   dwarf2out_global_decl,
+  dwarf2out_type_decl,         /* type_decl */
   dwarf2out_imported_module_or_decl,
   debug_nothing_tree,          /* deferred_inline_function */
   /* The DWARF 2 backend tries to reduce debugging bloat by not
@@ -12494,6 +12496,15 @@ dwarf2out_global_decl (tree decl)
     dwarf2out_decl (decl);
 }
 
+/* Output debug information for type decl DECL.  Called from toplev.c
+   and from language front ends (to record built-in types).  */
+static void
+dwarf2out_type_decl (tree decl, int local)
+{
+  if (!local)
+    dwarf2out_decl (decl);
+}
+
 /* Output debug information for imported module or decl.  */ 
  
 static void
index 7caab7809bec574bf09819ecfde74247d436a6cc..7d66437af030d6003ab16a76b086ffed0ca6b451 100644 (file)
@@ -242,7 +242,6 @@ extern int lhd_tree_dump_type_quals (tree);
 #define LANG_HOOKS_SET_BLOCK   set_block
 #define LANG_HOOKS_PUSHDECL    pushdecl
 #define LANG_HOOKS_GETDECLS    getdecls
-#define LANG_HOOKS_BUILTIN_TYPE_DECLS lhd_return_null_tree_v
 #define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL lhd_warn_unused_global_decl
 #define LANG_HOOKS_WRITE_GLOBALS write_global_declarations
 #define LANG_HOOKS_PREPARE_ASSEMBLE_VARIABLE NULL
@@ -256,7 +255,6 @@ extern int lhd_tree_dump_type_quals (tree);
   LANG_HOOKS_SET_BLOCK, \
   LANG_HOOKS_PUSHDECL, \
   LANG_HOOKS_GETDECLS, \
-  LANG_HOOKS_BUILTIN_TYPE_DECLS, \
   LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL, \
   LANG_HOOKS_WRITE_GLOBALS, \
   LANG_HOOKS_PREPARE_ASSEMBLE_VARIABLE, \
index 199b79f237a149174f90f2e31508d0da5515be21..f2c879afd2c216c03a513c924b8636bda99fbc70 100644 (file)
@@ -189,9 +189,6 @@ struct lang_hooks_for_decls
   /* Returns the chain of decls so far in the current scope level.  */
   tree (*getdecls) (void);
 
-  /* Returns a chain of TYPE_DECLs for built-in types.  */
-  tree (*builtin_type_decls) (void);
-
   /* Returns true when we should warn for an unused global DECL.
      We will already have checked that it has static binding.  */
   bool (*warn_unused_global) (tree);
index 648b4c9ccde0e87d1da1aead0e8ebdad279b01a8..56cebba59361d091b9efe30a3290556a2299c885 100644 (file)
@@ -48,6 +48,7 @@ AT&T C compiler.  From the example below I would conclude the following:
 #include "debug.h"
 #include "tree.h"
 #include "ggc.h"
+#include "varray.h"
 
 static GTY(()) tree anonymous_types;
 
@@ -59,6 +60,10 @@ static GTY(()) int sdbout_source_line_counter;
 
 static GTY(()) int unnamed_struct_number;
 
+/* Declarations whose debug info was deferred till end of compilation.  */
+
+static GTY(()) varray_type deferred_global_decls;
+
 #ifdef SDB_DEBUGGING_INFO
 
 #include "rtl.h"
@@ -331,6 +336,7 @@ const struct gcc_debug_hooks sdb_debug_hooks =
   sdbout_end_function,                  /* end_function */
   debug_nothing_tree,                   /* function_decl */
   sdbout_global_decl,                   /* global_decl */
+  sdbout_type_decl,                     /* type_decl */
   debug_nothing_tree_tree,               /* imported_module_or_decl */
   debug_nothing_tree,                   /* deferred_inline_function */
   debug_nothing_tree,                   /* outlining_inline_function */
@@ -1438,6 +1444,8 @@ sdbout_global_decl (tree decl)
         sdbout_finish ().  */
       if (!DECL_INITIAL (decl) || !TREE_PUBLIC (decl))
        sdbout_symbol (decl, 0);
+      else
+       VARRAY_PUSH_TREE (deferred_global_decls, decl);
 
       /* Output COFF information for non-global file-scope initialized
         variables.  */
@@ -1452,29 +1460,12 @@ sdbout_global_decl (tree decl)
 static void
 sdbout_finish (const char *main_filename ATTRIBUTE_UNUSED)
 {
-  tree decl = (*lang_hooks.decls.getdecls) ();
-  unsigned int len = list_length (decl);
-  tree *vec = xmalloc (sizeof (tree) * len);
-  unsigned int i;
+  int i;
 
-  /* Process the decls in reverse order--earliest first.  Put them
-     into VEC from back to front, then take out from front.  */
+  for (i = 0; i < VARRAY_ACTIVE_SIZE (deferred_global_decls); i++)
+    sdbout_symbol (VARRAY_TREE (deferred_global_decls, i), 0);
 
-  for (i = 0; i < len; i++, decl = TREE_CHAIN (decl))
-    vec[len - i - 1] = decl;
-
-  for (i = 0; i < len; i++)
-    {
-      decl = vec[i];
-      if (TREE_CODE (decl) == VAR_DECL
-         && ! DECL_EXTERNAL (decl)
-         && DECL_INITIAL (decl)
-         && TREE_PUBLIC (decl)
-         && DECL_RTL_SET_P (decl))
-       sdbout_symbol (decl, 0);
-    }
-
-  free (vec);
+  VARRAY_FREE (deferred_global_decls);
 }
 
 /* Describe the beginning of an internal block within a function.
@@ -1677,6 +1668,8 @@ sdbout_init (const char *input_file_name ATTRIBUTE_UNUSED)
   current_file->next = NULL;
   current_file->name = input_file_name;
 #endif
+
+  VARRAY_TREE_INIT (deferred_global_decls, 12, "deferred_global_decls");
 }
 
 #else  /* SDB_DEBUGGING_INFO */
index 8330c89bc444b503731bafe31a9b0bd2a66ba238..763c5d024babcfc431a9fb46ee53a3746aec27f0 100644 (file)
@@ -1978,50 +1978,18 @@ rest_of_decl_compilation (tree decl,
            expand_decl (decl);
        }
     }
-#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
-  else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
-          && TREE_CODE (decl) == TYPE_DECL)
+  else if (TREE_CODE (decl) == TYPE_DECL)
     {
       timevar_push (TV_SYMOUT);
-      dbxout_symbol (decl, 0);
+      debug_hooks->type_decl (decl, !top_level);
       timevar_pop (TV_SYMOUT);
     }
-#endif
-#ifdef SDB_DEBUGGING_INFO
-  else if (write_symbols == SDB_DEBUG && top_level
-          && TREE_CODE (decl) == TYPE_DECL)
-    {
-      timevar_push (TV_SYMOUT);
-      sdbout_symbol (decl, 0);
-      timevar_pop (TV_SYMOUT);
-    }
-#endif
-#ifdef DWARF2_DEBUGGING_INFO
-  else if ((write_symbols == DWARF2_DEBUG
-          || write_symbols == VMS_AND_DWARF2_DEBUG)
-          && top_level
-          && TREE_CODE (decl) == TYPE_DECL)
-    {
-      timevar_push (TV_SYMOUT);
-      dwarf2out_decl (decl);
-      timevar_pop (TV_SYMOUT);
-    }
-#endif
 }
 
 /* Called after finishing a record, union or enumeral type.  */
 
 void
-rest_of_type_compilation (
-#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)     \
-    || defined (SDB_DEBUGGING_INFO) || defined (DWARF2_DEBUGGING_INFO)
-                         tree type,
-                         int toplev
-#else
-                         tree type ATTRIBUTE_UNUSED,
-                         int toplev ATTRIBUTE_UNUSED
-#endif
-                         )
+rest_of_type_compilation (tree type, int toplev)
 {
   /* Avoid confusing the debug information machinery when there are
      errors.  */
@@ -2029,20 +1997,7 @@ rest_of_type_compilation (
     return;
 
   timevar_push (TV_SYMOUT);
-#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO)
-  if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG)
-    dbxout_symbol (TYPE_STUB_DECL (type), !toplev);
-#endif
-#ifdef SDB_DEBUGGING_INFO
-  if (write_symbols == SDB_DEBUG)
-    sdbout_symbol (TYPE_STUB_DECL (type), !toplev);
-#endif
-#ifdef DWARF2_DEBUGGING_INFO
-  if ((write_symbols == DWARF2_DEBUG
-       || write_symbols == VMS_AND_DWARF2_DEBUG)
-      && toplev)
-    dwarf2out_decl (TYPE_STUB_DECL (type));
-#endif
+  debug_hooks->type_decl (TYPE_STUB_DECL (type), !toplev);
   timevar_pop (TV_SYMOUT);
 }
 
index 5c5634de3444c95ac13fba0776df553023672867..f0b49f6f6c60aa999573c6b9cd6983148338ce0b 100644 (file)
@@ -186,6 +186,7 @@ const struct gcc_debug_hooks vmsdbg_debug_hooks
    vmsdbgout_end_function,
    vmsdbgout_decl,
    vmsdbgout_global_decl,
+   debug_nothing_tree_int,       /* type_decl */
    debug_nothing_tree_tree,       /* imported_module_or_decl */
    debug_nothing_tree,           /* deferred_inline_function */
    vmsdbgout_abstract_function,
index 324c5d5fa5b6f7b1c2dcdf89ee35d9487ce10fc1..447da746ac40c56333b7ecf94488901710afc470 100644 (file)
@@ -112,59 +112,71 @@ const char *xcoff_lastfile;
 #define ASM_OUTPUT_LBE(FILE,LINENUM,BLOCKNUM) \
   fprintf (FILE, "\t.eb\t%d\n", ABS_OR_RELATIVE_LINENO (LINENUM))
 
-static void assign_type_number (tree, const char *, int);
 static void xcoffout_block (tree, int, tree);
 static void xcoffout_source_file (FILE *, const char *, int);
 \f
 /* Support routines for XCOFF debugging info.  */
 
-/* Assign NUMBER as the stabx type number for the type described by NAME.
-   Search all decls in the list SYMS to find the type NAME.  */
-
-static void
-assign_type_number (tree syms, const char *name, int number)
+struct xcoff_type_number
 {
-  tree decl;
-
-  for (decl = syms; decl; decl = TREE_CHAIN (decl))
-    if (DECL_NAME (decl)
-       && strcmp (IDENTIFIER_POINTER (DECL_NAME (decl)), name) == 0)
-      {
-       TREE_ASM_WRITTEN (decl) = 1;
-       TYPE_SYMTAB_ADDRESS (TREE_TYPE (decl)) = number;
-      }
-}
-
-/* Setup gcc primitive types to use the XCOFF built-in type numbers where
-   possible.  */
-
-void
-xcoff_output_standard_types (tree syms)
-{
-  /* Handle built-in C types here.  */
-
-  assign_type_number (syms, "int", -1);
-  assign_type_number (syms, "char", -2);
-  assign_type_number (syms, "short int", -3);
-  assign_type_number (syms, "long int", (TARGET_64BIT ? -31 : -4));
-  assign_type_number (syms, "unsigned char", -5);
-  assign_type_number (syms, "signed char", -6);
-  assign_type_number (syms, "short unsigned int", -7);
-  assign_type_number (syms, "unsigned int", -8);
+  const char *name;
+  int number;
+};
+static const struct xcoff_type_number xcoff_type_numbers[] = {
+  { "int", -1 },
+  { "char", -2 },
+  { "short int", -3 },
+  { "long int", -4 },  /* fiddled to -31 if 64 bits */
+  { "unsigned char", -5 },
+  { "signed char", -6 },
+  { "short unsigned int", -7 },
+  { "unsigned int", -8 },
   /* No such type "unsigned".  */
-  assign_type_number (syms, "long unsigned int", (TARGET_64BIT ? -32 : -10));
-  assign_type_number (syms, "void", -11);
-  assign_type_number (syms, "float", -12);
-  assign_type_number (syms, "double", -13);
-  assign_type_number (syms, "long double", -14);
+  { "long unsigned int", -10 }, /* fiddled to -32 if 64 bits */
+  { "void", -11 },
+  { "float", -12 },
+  { "double", -13 },
+  { "long double", -14 },
   /* Pascal and Fortran types run from -15 to -29.  */
-  assign_type_number (syms, "wchar", -30);
-  assign_type_number (syms, "long long int", -31);
-  assign_type_number (syms, "long long unsigned int", -32);
+  { "wchar", -30 },  /* XXX Should be "wchar_t" ? */
+  { "long long int", -31 },
+  { "long long unsigned int", -32 },
   /* Additional Fortran types run from -33 to -37.  */
 
   /* ??? Should also handle built-in C++ and Obj-C types.  There perhaps
      aren't any that C doesn't already have.  */
+};    
+
+/* Returns an XCOFF fundamental type number for DECL (assumed to be a
+   TYPE_DECL), or 0 if dbxout.c should assign a type number normally.  */
+int
+xcoff_assign_fundamental_type_number (tree decl)
+{
+  const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
+  size_t i;
+
+  /* Do not waste time searching the list for non-intrinsic types.  */
+  if (DECL_SOURCE_LINE (decl) > 0)
+    return 0;
+
+  /* Linear search, blech, but the list is too small to bother
+     doing anything else.  */
+  for (i = 0; i < ARRAY_SIZE (xcoff_type_numbers); i++)
+    if (!strcmp (xcoff_type_numbers[i].name, name))
+      goto found;
+  return 0;
+
+ found:
+  /* -4 and -10 should be replaced with -31 and -32, respectively,
+     when used for a 64-bit type.  */
+  if (int_size_in_bytes (TREE_TYPE (decl)) == 8)
+    {
+      if (xcoff_type_numbers[i].number == -4)
+       return -31;
+      if (xcoff_type_numbers[i].number == -10)
+       return -32;
+    }
+  return xcoff_type_numbers[i].number;
 }
 
 /* Print an error message for unrecognized stab codes.  */
index 2b830484febfe96eb4f86fd454bbb85b8df1a8c9..1a0cf652c48e239b20f2e71f785c4e228cef50b2 100644 (file)
@@ -29,15 +29,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 
 /* Use the XCOFF predefined type numbers.  */
 
-/* ??? According to metin, typedef stabx must go in text control section,
-   but he did not make this changes everywhere where such typedef stabx
-   can be emitted, so it is really needed or not?  */
-
-#define DBX_OUTPUT_STANDARD_TYPES(SYMS)                \
-{                                              \
-  text_section ();                             \
-  xcoff_output_standard_types (SYMS);          \
-}
+#define DBX_ASSIGN_FUNDAMENTAL_TYPE_NUMBER(TYPE) \
+  xcoff_assign_fundamental_type_number (TYPE)
 
 /* Any type with a negative type index has already been output.  */
 
@@ -183,23 +176,11 @@ extern const char *xcoff_lastfile;
 /* Prototype functions in xcoffout.c.  */
 
 extern int stab_to_sclass (int);
-#ifdef BUFSIZ
 extern void xcoffout_begin_prologue (unsigned int, const char *);
 extern void xcoffout_begin_block (unsigned, unsigned);
 extern void xcoffout_end_epilogue (unsigned int, const char *);
 extern void xcoffout_end_function (unsigned int);
 extern void xcoffout_end_block (unsigned, unsigned);
-#endif /* BUFSIZ */
-
-#ifdef TREE_CODE
-extern void xcoff_output_standard_types (tree);
-#ifdef BUFSIZ
+extern int xcoff_assign_fundamental_type_number (tree);
 extern void xcoffout_declare_function (FILE *, tree, const char *);
-#endif /* BUFSIZ */
-#endif /* TREE_CODE */
-
-#ifdef RTX_CODE
-#ifdef BUFSIZ
 extern void xcoffout_source_line (unsigned int, const char *);
-#endif /* BUFSIZ */
-#endif /* RTX_CODE */