This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: debug/12066


This patch fixes a regression in the STABS debugging output that I
introduced a little while back.

The fundamental issue is that dbxout.c was assuming that built-in
types have a TYPE_DECL in the outermost scope.  That's a bogus
assumption; in C and C++, for example, the names for the builtin-types
are keywords, and really should not appear in the outermost scope.
When I fixed this in the C++ front end, I broke dbxout.c.

This patch creates a hook so tahat dbxout.c can get at the builtin
types.

Tested on i686-pc-linux-gnu, applied on the mainline.

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2003-09-17  Mark Mitchell  <mark@codesourcery.com>

	PR debug/12066
	* dbxout.c (dbxout_init): Use a langhook to find builtin types.
	* langhooks-def.h (lhd_return_null_tree_v): New function.
	(LANG_HOOKS_BUILTIN_TYPE_DECLS): New macro.
	(LANG_HOOKS_DECLS): Add it to the intializer.
	* langhooks.c (lhd_return_null_tree_v): New function.
	* langhooks.h (lang_hooks_for_decls): Add builtin_type_decls.

2003-09-17  Mark Mitchell  <mark@codesourcery.com>

	PR debug/12066
	* cp-lang.c (LANG_HOOKS_BUILTIN_TYPE_DECLS): Define.
	* cp-tree.h (cxx_builtin_type_decls): Declare.
	* decl.c (builtin_type_decls): New variables.
	(cxx_builtin_type_decls): New function.
	(record_builtin_type): Add to builtin_type_decls.

Index: dbxout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dbxout.c,v
retrieving revision 1.157
diff -c -5 -p -r1.157 dbxout.c
*** dbxout.c	5 Aug 2003 21:15:56 -0000	1.157
--- dbxout.c	17 Sep 2003 20:42:03 -0000
*************** dbxout_init (const char *input_file_name
*** 533,545 ****
  
  #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.  */
! 
    dbxout_typedefs (syms);
  }
  
  /* Output any typedef names for types described by TYPE_DECLs in SYMS,
     in the reverse order from that which is found in SYMS.  */
--- 533,546 ----
  
  #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) ());
    dbxout_typedefs (syms);
  }
  
  /* Output any typedef names for types described by TYPE_DECLs in SYMS,
     in the reverse order from that which is found in SYMS.  */
Index: langhooks-def.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks-def.h,v
retrieving revision 1.67
diff -c -5 -p -r1.67 langhooks-def.h
*** langhooks-def.h	15 Sep 2003 00:59:25 -0000	1.67
--- langhooks-def.h	17 Sep 2003 20:42:03 -0000
*************** extern void lhd_do_nothing_t (tree);
*** 44,53 ****
--- 44,54 ----
  extern void lhd_do_nothing_i (int);
  extern void lhd_do_nothing_f (struct function *);
  extern bool lhd_post_options (const char **);
  extern HOST_WIDE_INT lhd_get_alias_set (tree);
  extern tree lhd_return_tree (tree);
+ extern tree lhd_return_null_tree_v (void);
  extern tree lhd_return_null_tree (tree);
  extern tree lhd_do_nothing_iii_return_null_tree (int, int, int);
  extern int lhd_safe_from_p (rtx, tree);
  extern int lhd_staticp (tree);
  extern int lhd_unsafe_for_reeval (tree);
*************** extern int lhd_tree_dump_type_quals (tre
*** 237,246 ****
--- 238,248 ----
  #define LANG_HOOKS_GLOBAL_BINDINGS_P global_bindings_p
  #define LANG_HOOKS_INSERT_BLOCK	insert_block
  #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
  #define LANG_HOOKS_DECL_OK_FOR_SIBCALL	lhd_decl_ok_for_sibcall
  
*************** extern int lhd_tree_dump_type_quals (tre
*** 250,259 ****
--- 252,262 ----
    LANG_HOOKS_GLOBAL_BINDINGS_P, \
    LANG_HOOKS_INSERT_BLOCK, \
    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, \
    LANG_HOOKS_DECL_OK_FOR_SIBCALL, \
  }
Index: langhooks.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks.c,v
retrieving revision 1.53
diff -c -5 -p -r1.53 langhooks.c
*** langhooks.c	15 Sep 2003 00:59:25 -0000	1.53
--- langhooks.c	17 Sep 2003 20:42:03 -0000
*************** lhd_return_tree (tree t)
*** 82,91 ****
--- 82,99 ----
  }
  
  /* Do nothing (return NULL_TREE).  */
  
  tree
+ lhd_return_null_tree_v (void)
+ {
+   return NULL_TREE;
+ }
+ 
+ /* Do nothing (return NULL_TREE).  */
+ 
+ tree
  lhd_return_null_tree (tree t ATTRIBUTE_UNUSED)
  {
    return NULL_TREE;
  }
  
Index: langhooks.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks.h,v
retrieving revision 1.74
diff -c -5 -p -r1.74 langhooks.h
*** langhooks.h	10 Sep 2003 19:16:15 -0000	1.74
--- langhooks.h	17 Sep 2003 20:42:03 -0000
*************** struct lang_hooks_for_decls
*** 187,196 ****
--- 187,199 ----
    tree (*pushdecl) (tree);
  
    /* 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);
  
    /* Obtain a list of globals and do final output on them at end
Index: stor-layout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/stor-layout.c,v
retrieving revision 1.167
diff -c -5 -p -r1.167 stor-layout.c
*** stor-layout.c	4 Sep 2003 03:17:50 -0000	1.167
--- stor-layout.c	17 Sep 2003 20:42:05 -0000
*************** void
*** 665,675 ****
  normalize_rli (record_layout_info rli)
  {
    normalize_offset (&rli->offset, &rli->bitpos, rli->offset_align);
  }
  
! /* Returns the size in bytes allocated so far.  */
  
  tree
  rli_size_unit_so_far (record_layout_info rli)
  {
    return byte_from_pos (rli->offset, rli->bitpos);
--- 665,677 ----
  normalize_rli (record_layout_info rli)
  {
    normalize_offset (&rli->offset, &rli->bitpos, rli->offset_align);
  }
  
! /* Returns the number of whole bytes allocated so far.  If some, but
!    not all, bits have been allocated in the last byte, then the value
!    returned does not include the last byte.  */
  
  tree
  rli_size_unit_so_far (record_layout_info rli)
  {
    return byte_from_pos (rli->offset, rli->bitpos);
Index: cp/cp-lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-lang.c,v
retrieving revision 1.66
diff -c -5 -p -r1.66 cp-lang.c
*** cp/cp-lang.c	15 Sep 2003 00:59:27 -0000	1.66
--- cp/cp-lang.c	17 Sep 2003 20:42:06 -0000
*************** static void cxx_initialize_diagnostics (
*** 100,109 ****
--- 100,111 ----
  #define LANG_HOOKS_PRINT_IDENTIFIER cxx_print_identifier
  #undef LANG_HOOKS_DECL_PRINTABLE_NAME
  #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
  #define LANG_HOOKS_POPLEVEL lhd_do_nothing_iii_return_null_tree
  #undef LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL
Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.916
diff -c -5 -p -r1.916 cp-tree.h
*** cp/cp-tree.h	15 Sep 2003 00:59:27 -0000	1.916
--- cp/cp-tree.h	17 Sep 2003 20:42:06 -0000
*************** extern int nonstatic_local_decl_p       
*** 3750,3759 ****
--- 3750,3761 ----
  extern tree declare_global_var                  (tree, tree);
  extern void register_dtor_fn                    (tree);
  extern tmpl_spec_kind current_tmpl_spec_kind    (int);
  extern tree cp_fname_init			(const char *);
  extern tree check_elaborated_type_specifier     (enum tag_types, tree, bool);
+ extern tree cxx_builtin_type_decls              (void);
+ 
  extern bool have_extern_spec;
  
  /* in decl2.c */
  extern bool check_java_method (tree);
  extern int grok_method_quals (tree, tree, tree);
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1126
diff -c -5 -p -r1.1126 decl.c
*** cp/decl.c	15 Sep 2003 00:59:27 -0000	1.1126
--- cp/decl.c	17 Sep 2003 20:42:08 -0000
*************** lookup_type_current_level (tree name)
*** 5909,5918 ****
--- 5909,5931 ----
  
    POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, t);
  }
  
  
+ 
+ /* 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 ()
+ {
+   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
     type.  TYPE is the _TYPE node for the builtin type.  */
  
*************** record_builtin_type (enum rid rid_index,
*** 5950,5959 ****
--- 5963,5978 ----
        SET_IDENTIFIER_GLOBAL_VALUE (rname, tdecl);
      }
  
    if (!TYPE_NAME (type))
      TYPE_NAME (type) = tdecl;
+ 
+   if (tdecl)
+     {
+       TREE_CHAIN (tdecl) = builtin_type_decls;
+       builtin_type_decls = tdecl;
+     }
  }
  
  /* Record one of the standard Java types.
   * Declare it as having the given NAME.
   * If SIZE > 0, it is the size of one of the integral types;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]