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]

PATCH: Lazy name-mangling



This patch implements lazy name-mangling.

On a randomly selected C++ source file from POOMA, this patch reduced
the total number of IDENTIFIER_NODEs from 19060 to 7502, a savings of
about 60%.  I didn't measure the exact number of bytes saved, but
mangled names are generally the longest identifiers in the program, so
I would expect that more than 60% of the space used by identifiers was
eliminated by this patch.

Note that the reduction in mangled names is greater than that
percentage would indicate; many of the remaining IDENTIFIER_NODEs
correspond to ordinary user variables.

The basic techniques are similar to those in the lazy DECL_RTL patch.
Here there is no ambiguity -- DECL_ASSEMBLER_NAME is NULL_TREE until
it is set, which it must be for any entity that is going to be emitted
in assembly code.

In addition to the memory savings, the front-end code is simplified by
removing many of the places that explicitly set the mangled name of
various entities.

I only changed the C++ front-end; other languages should operate no
differently than they did before at this point.  However, the
mechanism is language-independent, and it might well make sense for
the Java front-end to use similar techniques.

As part of this patch, the C++ front-end no longer enters things in
the symbol table using their DECL_ASSEMBLER_NAME.  That always struck
me as a penetration of an important abstraction barrier.  In any case,
that means that we will now catch clashes between mangled names and
(invalid) user names in the assembler, rather than the compiler.

I've only installed this patch on the mainline for now; I'll put in on
the branch once I've tested it there, and after any near-term bug
reports are resolved.

Bootstrapped, tested on i686-pc-linux-gnu; installed on the mainline.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com

2001-03-19  Mark Mitchell  <mark@codesourcery.com>

	Compute DECL_ASSEMBLER_NAME lazily.
	* tree.h (DECL_ASSEMBLER_NAME): Compute it lazily.
	(DECL_ASSEMBLER_NAME_SET_P): New macro.
	(SET_DECL_ASSEMBLER_NAME): Likewise.
	(COPY_DECL_ASSEMBLER_NAME): Likewise.
	(set_decl_assembler_name): Declare.
	(lang_set_decl_assembler_name): Likewise.
	* tree.c (lang_set_decl_assembler_name): New variab.e
	(set_decl_assembler_name): New function.
	(init_obstacks): Set lang_set_decl_assembler_name.
	(build_decl): Don't set DECL_ASSEMBLER_NAME.
	* c-decl.c (duplicate_decls): Use SET_DECL_ASSEMBLER_NAME,
	COPY_DECL_ASSEMBLER_NAME, etc.  Don't set DECL_ASSEMBLER_NAME
	where it's not necessary.
	(builtin_function): Likewise.
	(finish_decl): Likewise.
	* dbxout.c (dbxout_type_methods): Likewise.
	* ggc-common.c (ggc_mark_trees): Likewise.
	* profile.c (output_func_start_profiler): Likewise.
	* varasm.c (make_decl_rtl): Likewise.

2001-03-19  Mark Mitchell  <mark@codesourcery.com>

	* class.c (get_vtable_decl): Use SET_DECL_ASSEMBLER_NAME,
	COPY_DECL_ASSEMBLER_NAME, etc.  Don't set DECL_ASSEMBLER_NAME
	where it's not necessary.
	(add_method): Remove optimization involving comparison of
	DECL_ASSEMBLER_NAME.
	(build_vtbl_or_vbase_field): Use SET_DECL_ASSEMBLER_NAME,
	COPY_DECL_ASSEMBLER_NAME, etc.  Don't set DECL_ASSEMBLER_NAME
	where it's not necessary.
	(check_methods): Likewise.
	(build_clone): Likewise.
	(built_vtt): Likewise.
	* cp-tree.h (DECL_NEEDED_P): Likewise.
	* decl.c (pushtag): Likewise.
	(duplicate_decls): Likewise.
	(pushdecl): Likewise.
	(builtin_function): Likewise.
	(build_library_fn_1): Set DECL_LANGUAGE for library functions.
	(build_cp_library_fn): Likewise.
	(maybe_commonize_var): Use SET_DECL_ASSEMBLER_NAME,
	COPY_DECL_ASSEMBLER_NAME, etc.  Don't set DECL_ASSEMBLER_NAME
	where it's not necessary.
	(make_rtl_for_nonlocal_decl): Likewise.
	(cp_finish_decl): Likewise.
	(grokfndecl): Likewise.
	(grokvardecl): Likewise.
	(grokdeclarator): Likewise.
	(start_function): Likewise.
	(cp_missing_return_ok_p): Likewise.
	* decl2.c (grokclassfn): Likewise.
	(check_classfn): Likewise.
	(finish_static_data_member_decl): Likewise.
	(grokfield): Likewise.
	* error.c (GLOBAL_IORD_P): Remove.
	(dump_global_iord): Improve output.
	(dump_decl): Avoid using DECL_ASSEMBLER_NAME.
	* except.c (nothrow_libfn_p): Summarily reject any function not in
	namespace-scope.
	* init.c (build_java_class_ref): Don't explicitly set
	DECL_ASSEMBLER_NAME after calling mangle_decl.
	* mangle.c (mangle_decl_string): Handle extern "C" functions.
	(mangle_decl): Set the DECL_ASSEMBLER_NAME for the decl.
	* method.c (set_mangled_name_for_decl): Don't explicitly set
	DECL_ASSEMBLER_NAME after calling mangle_decl.
	(make_thunk): Explicitly set the DECL_ASSEMBLER_NAME and
	IDENTIFIER_GLOBAL_VALUE for the thunk.
	* pt.c (set_mangled_name_for_template_decl): Remove.
	(check_explicit_specialization): Don't use it.
	(looup_template_class): Don't set DECL_ASSEMBLER_NAME.
	(tsubst_friend_function): Likewise.
	(tsubst_decl): Likewise.
	(regenerate_decl_from_template): Use COPY_DECL_ASSEMBLER_NAME.
	* rtti.c (get_tinfo_decl): Use SET_DECL_ASSEMBLER_NAME,
	COPY_DECL_ASSEMBLER_NAME, etc.  Don't set DECL_ASSEMBLER_NAME
	where it's not necessary.
	(tinfo_base_init): Likewise.
	(create_real_tinfo_var): Likewise.
	* search.c (looup_field_1): Likewise.
	* semantics.c (finish_named_return_value): Likewise.
	* tree.c (init_tree): Set lang_set_decl_assembler_name.
	
Mon Mar 19 15:05:39 2001  Mark Mitchell  <mark@codesourcery.com>

	* com.c (builtin_function): Use SET_DECL_ASSEMBLER_NAME.

2001-03-19  Mark Mitchell  <mark@codesourcery.com>

	* class.c (build_class_ref): Use SET_DECL_ASSEMBLER_NAME.
	(layout_class): Likewise.
	(layout_class_method): Likewise.
	(emit_register_classes): Likewise.
	* decl.c (builtin_function): Likewise.
	(give_name_to_locals): Likewise.

Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.214
diff -c -p -r1.214 c-decl.c
*** c-decl.c	2001/03/15 02:50:48	1.214
--- c-decl.c	2001/03/19 23:05:30
*************** duplicate_decls (newdecl, olddecl, diffe
*** 1902,1908 ****
  
        /* Copy the assembler name.
  	 Currently, it can only be defined in the prototype.  */
!       DECL_ASSEMBLER_NAME (newdecl) = DECL_ASSEMBLER_NAME (olddecl);
  
        if (TREE_CODE (newdecl) == FUNCTION_DECL)
  	{
--- 1902,1908 ----
  
        /* Copy the assembler name.
  	 Currently, it can only be defined in the prototype.  */
!       COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl);
  
        if (TREE_CODE (newdecl) == FUNCTION_DECL)
  	{
*************** builtin_function (name, type, function_c
*** 3186,3192 ****
    if (flag_traditional && name[0] != '_')
      DECL_BUILT_IN_NONANSI (decl) = 1;
    if (library_name)
!     DECL_ASSEMBLER_NAME (decl) = get_identifier (library_name);
    make_decl_rtl (decl, NULL_PTR);
    pushdecl (decl);
    DECL_BUILT_IN_CLASS (decl) = class;
--- 3186,3192 ----
    if (flag_traditional && name[0] != '_')
      DECL_BUILT_IN_NONANSI (decl) = 1;
    if (library_name)
!     SET_DECL_ASSEMBLER_NAME (decl, get_identifier (library_name));
    make_decl_rtl (decl, NULL_PTR);
    pushdecl (decl);
    DECL_BUILT_IN_CLASS (decl) = class;
*************** finish_decl (decl, init, asmspec_tree)
*** 3599,3605 ****
      {
        DECL_BUILT_IN_CLASS (decl) = NOT_BUILT_IN;
        SET_DECL_RTL (decl, NULL_RTX);
!       DECL_ASSEMBLER_NAME (decl) = get_identifier (asmspec);
      }
  
    /* Output the assembler code and/or RTL code for variables and functions,
--- 3599,3605 ----
      {
        DECL_BUILT_IN_CLASS (decl) = NOT_BUILT_IN;
        SET_DECL_RTL (decl, NULL_RTX);
!       SET_DECL_ASSEMBLER_NAME (decl, get_identifier (asmspec));
      }
  
    /* Output the assembler code and/or RTL code for variables and functions,
*************** finish_decl (decl, init, asmspec_tree)
*** 3627,3633 ****
  	{
  	  if (asmspec)
  	    {
! 	      DECL_ASSEMBLER_NAME (decl) = get_identifier (asmspec);
  	      DECL_C_HARD_REGISTER (decl) = 1;
  	    }
  	  add_decl_stmt (decl);
--- 3627,3633 ----
  	{
  	  if (asmspec)
  	    {
! 	      SET_DECL_ASSEMBLER_NAME (decl, get_identifier (asmspec));
  	      DECL_C_HARD_REGISTER (decl) = 1;
  	    }
  	  add_decl_stmt (decl);
Index: dbxout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dbxout.c,v
retrieving revision 1.74
diff -c -p -r1.74 dbxout.c
*** dbxout.c	2001/03/15 02:50:48	1.74
--- dbxout.c	2001/03/19 23:05:32
*************** dbxout_type_methods (type)
*** 833,841 ****
  	{
  	  /* This is the "mangled" name of the method.
  	     It encodes the argument types.  */
! 	  const char *debug_name =
! 	    IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
  	  int show_arg_types = 0;
  
  	  CONTIN;
  
--- 833,849 ----
  	{
  	  /* This is the "mangled" name of the method.
  	     It encodes the argument types.  */
! 	  const char *debug_name;
  	  int show_arg_types = 0;
+ 
+ 	  /* Skip methods that aren't FUNCTION_DECLs.  (In C++, these
+ 	     include TEMPLATE_DECLs.)  The debugger doesn't know what
+ 	     to do with such entities anyhow.  */
+ 	  if (TREE_CODE (fndecl) != FUNCTION_DECL)
+ 	    continue;
+ 
+ 	  debug_name =
+ 	    IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
  
  	  CONTIN;
  
Index: ggc-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ggc-common.c,v
retrieving revision 1.37
diff -c -p -r1.37 ggc-common.c
*** ggc-common.c	2001/03/15 02:50:49	1.37
--- ggc-common.c	2001/03/19 23:05:33
*************** ggc_mark_trees ()
*** 373,385 ****
  	  ggc_mark_tree (DECL_RESULT_FLD (t));
  	  ggc_mark_tree (DECL_INITIAL (t));
  	  ggc_mark_tree (DECL_ABSTRACT_ORIGIN (t));
- 	  ggc_mark_tree (DECL_ASSEMBLER_NAME (t));
  	  ggc_mark_tree (DECL_SECTION_NAME (t));
  	  ggc_mark_tree (DECL_MACHINE_ATTRIBUTES (t));
  	  if (DECL_RTL_SET_P (t))
  	    ggc_mark_rtx (DECL_RTL (t));
  	  ggc_mark_rtx (DECL_LIVE_RANGE_RTL (t));
  	  ggc_mark_tree (DECL_VINDEX (t));
  	  lang_mark_tree (t);
  	  break;
  
--- 373,386 ----
  	  ggc_mark_tree (DECL_RESULT_FLD (t));
  	  ggc_mark_tree (DECL_INITIAL (t));
  	  ggc_mark_tree (DECL_ABSTRACT_ORIGIN (t));
  	  ggc_mark_tree (DECL_SECTION_NAME (t));
  	  ggc_mark_tree (DECL_MACHINE_ATTRIBUTES (t));
  	  if (DECL_RTL_SET_P (t))
  	    ggc_mark_rtx (DECL_RTL (t));
  	  ggc_mark_rtx (DECL_LIVE_RANGE_RTL (t));
  	  ggc_mark_tree (DECL_VINDEX (t));
+ 	  if (DECL_ASSEMBLER_NAME_SET_P (t))
+ 	    ggc_mark_tree (DECL_ASSEMBLER_NAME (t));
  	  lang_mark_tree (t);
  	  break;
  
Index: profile.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/profile.c,v
retrieving revision 1.53
diff -c -p -r1.53 profile.c
*** profile.c	2001/02/04 22:43:59	1.53
--- profile.c	2001/03/19 23:05:33
*************** output_func_start_profiler ()
*** 1108,1114 ****
    TREE_PUBLIC (fndecl) = 1;
  #endif
  
-   DECL_ASSEMBLER_NAME (fndecl) = fnname;
    DECL_RESULT (fndecl) = build_decl (RESULT_DECL, NULL_TREE, void_type_node);
  
    fndecl = pushdecl (fndecl);
--- 1108,1113 ----
Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.c,v
retrieving revision 1.189
diff -c -p -r1.189 tree.c
*** tree.c	2001/03/15 02:50:50	1.189
--- tree.c	2001/03/19 23:05:36
*************** void (*lang_unsave_expr_now) PARAMS ((tr
*** 182,191 ****
--- 182,223 ----
  /* If non-null, these are language-specific helper functions for
     unsafe_for_reeval.  Return negative to not handle some tree.  */
  int (*lang_unsafe_for_reeval) PARAMS ((tree));
+ 
+ /* Set the DECL_ASSEMBLER_NAME for a node.  If it is the sort of thing
+    that the assembler should talk about, set DECL_ASSEMBLER_NAME to an
+    appropriate IDENTIFIER_NODE.  Otherwise, set it to the
+    ERROR_MARK_NODE to ensure that the assembler does not talk about
+    it.  */
+ void (*lang_set_decl_assembler_name)     PARAMS ((tree));
  
  tree global_trees[TI_MAX];
  tree integer_types[itk_none];
  
+ /* Set the DECL_ASSEMBLER_NAME for DECL.  */
+ void
+ set_decl_assembler_name (decl)
+      tree decl;
+ {
+   /* The language-independent code should never use the
+      DECL_ASSEMBLER_NAME for lots of DECLs.  Only FUNCTION_DECLs and
+      VAR_DECLs for variables with static storage duration need a real
+      DECL_ASSEMBLER_NAME.  */
+   if (TREE_CODE (decl) == FUNCTION_DECL
+       || (TREE_CODE (decl) == VAR_DECL 
+ 	  && (TREE_STATIC (decl) || DECL_EXTERNAL (decl))))
+     /* By default, assume the name to use in assembly code is the
+        same as that used in the source language.  (That's correct
+        for C, and GCC used to set DECL_ASSEMBLER_NAME to the same
+        value as DECL_NAME in build_decl, so this choice provides
+        backwards compatibility with existing front-ends.  */
+     SET_DECL_ASSEMBLER_NAME (decl, DECL_NAME (decl));
+   else
+     /* Nobody should ever be asking for the DECL_ASSEMBLER_NAME of
+        these DECLs -- unless they're in language-dependent code, in
+        which case lang_set_decl_assembler_name should handle things.  */
+     abort ();
+ }
+ 
  /* Init the principal obstacks.  */
  
  void
*************** init_obstacks ()
*** 199,204 ****
--- 231,239 ----
    ggc_add_root (&type_hash_table, 1, sizeof type_hash_table, mark_type_hash);
    ggc_add_tree_root (global_trees, TI_MAX);
    ggc_add_tree_root (integer_types, itk_none);
+ 
+   /* Set lang_set_decl_set_assembler_name to a default value.  */
+   lang_set_decl_assembler_name = set_decl_assembler_name;
  }
  
  void
*************** build_decl (code, name, type)
*** 2557,2563 ****
     as the type can suppress useless errors in the use of this variable.  */
  
    DECL_NAME (t) = name;
-   DECL_ASSEMBLER_NAME (t) = name;
    TREE_TYPE (t) = type;
  
    if (code == VAR_DECL || code == PARM_DECL || code == RESULT_DECL)
--- 2592,2597 ----
Index: tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree.h,v
retrieving revision 1.231
diff -c -p -r1.231 tree.h
*** tree.h	2001/03/15 02:50:50	1.231
--- tree.h	2001/03/19 23:05:38
*************** struct tree_type
*** 1255,1265 ****
  /* This is the name of the object as written by the user.
     It is an IDENTIFIER_NODE.  */
  #define DECL_NAME(NODE) (DECL_CHECK (NODE)->decl.name)
! /* This is the name of the object as the assembler will see it
!    (but before any translations made by ASM_OUTPUT_LABELREF).
!    Often this is the same as DECL_NAME.
!    It is an IDENTIFIER_NODE.  */
! #define DECL_ASSEMBLER_NAME(NODE) (DECL_CHECK (NODE)->decl.assembler_name)
  /* Records the section name in a section attribute.  Used to pass
     the name from decl_attributes to make_function_rtl and make_decl_rtl.  */
  #define DECL_SECTION_NAME(NODE) (DECL_CHECK (NODE)->decl.section_name)
--- 1255,1291 ----
  /* This is the name of the object as written by the user.
     It is an IDENTIFIER_NODE.  */
  #define DECL_NAME(NODE) (DECL_CHECK (NODE)->decl.name)
! /* The name of the object as the assembler will see it (but before any
!    translations made by ASM_OUTPUT_LABELREF).  Often this is the same
!    as DECL_NAME.  It is an IDENTIFIER_NODE.  */
! #define DECL_ASSEMBLER_NAME(NODE)		\
!   ((DECL_ASSEMBLER_NAME_SET_P (NODE)		\
!     ? (void) 0					\
!     : (*lang_set_decl_assembler_name) (NODE)),	\
!    DECL_CHECK (NODE)->decl.assembler_name)
! /* Returns non-zero if the DECL_ASSEMBLER_NAME for NODE has been 
!    set.  If zero, the NODE might still have a DECL_ASSEMBLER_NAME --
!    it just hasn't been set yet.  */
! #define DECL_ASSEMBLER_NAME_SET_P(NODE) \
!   (DECL_CHECK (NODE)->decl.assembler_name != NULL_TREE)
! /* Set the DECL_ASSEMBLER_NAME for NODE to NAME.  */
! #define SET_DECL_ASSEMBLER_NAME(NODE, NAME) \
!   (DECL_CHECK (NODE)->decl.assembler_name = (NAME))
! /* Copy the DECL_ASSEMBLER_NAME from DECL1 to DECL2.  Note that if
!    DECL1's DECL_ASSEMBLER_NAME has not yet been set, using this macro
!    will not cause the DECL_ASSEMBLER_NAME of either DECL to be set.
!    In other words, the semantics of using this macro, are different
!    than saying:
!      
!      SET_DECL_ASSEMBLER_NAME(DECL2, DECL_ASSEMBLER_NAME (DECL1))
! 
!    which will try to set the DECL_ASSEMBLER_NAME for DECL1.  */
! #define COPY_DECL_ASSEMBLER_NAME(DECL1, DECL2)				\
!   (DECL_ASSEMBLER_NAME_SET_P (DECL1)					\
!    ? (void) SET_DECL_ASSEMBLER_NAME (DECL2, 				\
!                                      DECL_ASSEMBLER_NAME (DECL1))	\
!    : (void) 0)
! 
  /* Records the section name in a section attribute.  Used to pass
     the name from decl_attributes to make_function_rtl and make_decl_rtl.  */
  #define DECL_SECTION_NAME(NODE) (DECL_CHECK (NODE)->decl.section_name)
*************** extern tree get_set_constructor_bits		PA
*** 2497,2502 ****
--- 2523,2529 ----
  extern tree get_set_constructor_bytes		PARAMS ((tree,
  						       unsigned char *, int));
  extern tree get_callee_fndecl                   PARAMS ((tree));
+ extern void set_decl_assembler_name             PARAMS ((tree));
  
  /* In stmt.c */
  
*************** extern int objects_must_conflict_p		PARA
*** 2665,2670 ****
--- 2692,2704 ----
  
  /* In c-common.c */
  extern HOST_WIDE_INT lang_get_alias_set		PARAMS ((tree));
+ 
+ /* Set the DECL_ASSEMBLER_NAME for a node.  If it is the sort of thing
+    that the assembler should talk about, set DECL_ASSEMBLER_NAME to an
+    appropriate IDENTIFIER_NODE.  Otherwise, set it to the
+    ERROR_MARK_NODE to ensure that the assembler does not talk about
+    it.  */
+ extern void (*lang_set_decl_assembler_name)     PARAMS ((tree));
  
  struct obstack;
  
Index: varasm.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/varasm.c,v
retrieving revision 1.166
diff -c -p -r1.166 varasm.c
*** varasm.c	2001/03/15 09:58:58	1.166
--- varasm.c	2001/03/19 23:05:41
*************** make_decl_rtl (decl, asmspec)
*** 738,744 ****
  
    if (name != new_name)
      {
!       DECL_ASSEMBLER_NAME (decl) = get_identifier (new_name);
        name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
      }
  
--- 738,744 ----
  
    if (name != new_name)
      {
!       SET_DECL_ASSEMBLER_NAME (decl, get_identifier (new_name));
        name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
      }
  
Index: cp/ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/ChangeLog,v
retrieving revision 1.2287
diff -c -p -r1.2287 ChangeLog
*** ChangeLog	2001/03/15 07:59:52	1.2287
--- ChangeLog	2001/03/19 23:05:47
***************
*** 1,3 ****
--- 1,65 ----
+ 2001-03-19  Mark Mitchell  <mark@codesourcery.com>
+ 
+ 	* class.c (get_vtable_decl): Use SET_DECL_ASSEMBLER_NAME,
+ 	COPY_DECL_ASSEMBLER_NAME, etc.  Don't set DECL_ASSEMBLER_NAME
+ 	where it's not necessary.
+ 	(add_method): Remove optimization involving comparison of
+ 	DECL_ASSEMBLER_NAME.
+ 	(build_vtbl_or_vbase_field): Use SET_DECL_ASSEMBLER_NAME,
+ 	COPY_DECL_ASSEMBLER_NAME, etc.  Don't set DECL_ASSEMBLER_NAME
+ 	where it's not necessary.
+ 	(check_methods): Likewise.
+ 	(build_clone): Likewise.
+ 	(built_vtt): Likewise.
+ 	* cp-tree.h (DECL_NEEDED_P): Likewise.
+ 	* decl.c (pushtag): Likewise.
+ 	(duplicate_decls): Likewise.
+ 	(pushdecl): Likewise.
+ 	(builtin_function): Likewise.
+ 	(build_library_fn_1): Set DECL_LANGUAGE for library functions.
+ 	(build_cp_library_fn): Likewise.
+ 	(maybe_commonize_var): Use SET_DECL_ASSEMBLER_NAME,
+ 	COPY_DECL_ASSEMBLER_NAME, etc.  Don't set DECL_ASSEMBLER_NAME
+ 	where it's not necessary.
+ 	(make_rtl_for_nonlocal_decl): Likewise.
+ 	(cp_finish_decl): Likewise.
+ 	(grokfndecl): Likewise.
+ 	(grokvardecl): Likewise.
+ 	(grokdeclarator): Likewise.
+ 	(start_function): Likewise.
+ 	(cp_missing_return_ok_p): Likewise.
+ 	* decl2.c (grokclassfn): Likewise.
+ 	(check_classfn): Likewise.
+ 	(finish_static_data_member_decl): Likewise.
+ 	(grokfield): Likewise.
+ 	* error.c (GLOBAL_IORD_P): Remove.
+ 	(dump_global_iord): Improve output.
+ 	(dump_decl): Avoid using DECL_ASSEMBLER_NAME.
+ 	* except.c (nothrow_libfn_p): Summarily reject any function not in
+ 	namespace-scope.
+ 	* init.c (build_java_class_ref): Don't explicitly set
+ 	DECL_ASSEMBLER_NAME after calling mangle_decl.
+ 	* mangle.c (mangle_decl_string): Handle extern "C" functions.
+ 	(mangle_decl): Set the DECL_ASSEMBLER_NAME for the decl.
+ 	* method.c (set_mangled_name_for_decl): Don't explicitly set
+ 	DECL_ASSEMBLER_NAME after calling mangle_decl.
+ 	(make_thunk): Explicitly set the DECL_ASSEMBLER_NAME and
+ 	IDENTIFIER_GLOBAL_VALUE for the thunk.
+ 	* pt.c (set_mangled_name_for_template_decl): Remove.
+ 	(check_explicit_specialization): Don't use it.
+ 	(looup_template_class): Don't set DECL_ASSEMBLER_NAME.
+ 	(tsubst_friend_function): Likewise.
+ 	(tsubst_decl): Likewise.
+ 	(regenerate_decl_from_template): Use COPY_DECL_ASSEMBLER_NAME.
+ 	* rtti.c (get_tinfo_decl): Use SET_DECL_ASSEMBLER_NAME,
+ 	COPY_DECL_ASSEMBLER_NAME, etc.  Don't set DECL_ASSEMBLER_NAME
+ 	where it's not necessary.
+ 	(tinfo_base_init): Likewise.
+ 	(create_real_tinfo_var): Likewise.
+ 	* search.c (looup_field_1): Likewise.
+ 	* semantics.c (finish_named_return_value): Likewise.
+ 	* tree.c (init_tree): Set lang_set_decl_assembler_name.
+ 	
  2001-03-15  Gabriel Dos Reis  <gdr@codesourcery.com>
  
  	Correct semantics restrictions checking in throw-expression.
Index: cp/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.367
diff -c -p -r1.367 class.c
*** class.c	2001/03/15 02:50:51	1.367
--- class.c	2001/03/19 23:05:52
*************** get_vtable_decl (type, complete)
*** 760,765 ****
--- 760,766 ----
      }
    
    decl = build_vtable (type, name, void_type_node);
+   SET_DECL_ASSEMBLER_NAME (decl, name);
    decl = pushdecl_top_level (decl);
    my_friendly_assert (IDENTIFIER_GLOBAL_VALUE (name) == decl,
  		      20000517);
*************** add_method (type, method, error_p)
*** 1310,1326 ****
  				  fn, method);
  		    }
  		}
- 
- 	      /* Since this is an ordinary function in a
- 		 non-template class, it's mangled name can be used
- 		 as a unique identifier.  This technique is only
- 		 an optimization; we would get the same results if
- 		 we just used decls_match here.  */
- 	      if (DECL_ASSEMBLER_NAME (fn) 
- 		  != DECL_ASSEMBLER_NAME (method))
- 		continue;
  	    }
! 	  else if (!decls_match (fn, method))
  	    continue;
  
  	  /* There has already been a declaration of this method
--- 1311,1319 ----
  				  fn, method);
  		    }
  		}
  	    }
! 
! 	  if (!decls_match (fn, method))
  	    continue;
  
  	  /* There has already been a declaration of this method
*************** build_vtbl_or_vbase_field (name, assembl
*** 3693,3699 ****
  
    /* Build the FIELD_DECL.  */
    field = build_decl (FIELD_DECL, name, type);
!   DECL_ASSEMBLER_NAME (field) = assembler_name;
    DECL_VIRTUAL_P (field) = 1;
    DECL_ARTIFICIAL (field) = 1;
    DECL_FIELD_CONTEXT (field) = class_type;
--- 3686,3692 ----
  
    /* Build the FIELD_DECL.  */
    field = build_decl (FIELD_DECL, name, type);
!   SET_DECL_ASSEMBLER_NAME (field, assembler_name);
    DECL_VIRTUAL_P (field) = 1;
    DECL_ARTIFICIAL (field) = 1;
    DECL_FIELD_CONTEXT (field) = class_type;
*************** check_methods (t)
*** 4120,4126 ****
        GNU_xref_member (current_class_name, x);
  
        /* If this was an evil function, don't keep it in class.  */
!       if (IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (x)))
  	continue;
  
        check_for_override (x, t);
--- 4113,4120 ----
        GNU_xref_member (current_class_name, x);
  
        /* If this was an evil function, don't keep it in class.  */
!       if (DECL_ASSEMBLER_NAME_SET_P (x) 
! 	  && IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (x)))
  	continue;
  
        check_for_override (x, t);
*************** build_clone (fn, name)
*** 4184,4190 ****
    DECL_ABSTRACT_ORIGIN (clone) = fn;
    /* Reset the function name.  */
    DECL_NAME (clone) = name;
-   DECL_ASSEMBLER_NAME (clone) = DECL_NAME (clone);
    /* There's no pending inline data for this function.  */
    DECL_PENDING_INLINE_INFO (clone) = NULL;
    DECL_PENDING_INLINE_P (clone) = 0;
--- 4178,4183 ----
*************** build_clone (fn, name)
*** 4261,4269 ****
  	}
      }
  
-   /* Mangle the function name.  */
-   set_mangled_name_for_decl (clone);
- 
    /* Create the RTL for this function.  */
    SET_DECL_RTL (clone, NULL_RTX);
    rest_of_decl_compilation (clone, NULL, /*top_level=*/1, at_eof);
--- 4254,4259 ----
*************** build_vtt (t)
*** 6823,6828 ****
--- 6813,6819 ----
  				 
    /* Now, build the VTT object itself.  */
    vtt = build_vtable (t, get_vtt_name (t), type);
+   SET_DECL_ASSEMBLER_NAME (vtt, DECL_NAME (vtt));
    pushdecl_top_level (vtt);
    initialize_array (vtt, inits);
  }
Index: cp/cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.585
diff -c -p -r1.585 cp-tree.h
*** cp-tree.h	2001/03/15 02:50:52	1.585
--- cp-tree.h	2001/03/19 23:05:55
*************** struct lang_decl
*** 1904,1912 ****
     just been used somewhere, even if it's not really needed.  We need
     anything that isn't comdat, but we don't know for sure whether or
     not something is comdat until end-of-file.  */
! #define DECL_NEEDED_P(DECL)					\
!   ((at_eof && TREE_PUBLIC (DECL) && !DECL_COMDAT (DECL))	\
!    || (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME ((DECL))))	\
     || (flag_syntax_only && TREE_USED ((DECL))))
  
  /* Non-zero iff DECL is memory-based.  The DECL_RTL of
--- 1904,1913 ----
     just been used somewhere, even if it's not really needed.  We need
     anything that isn't comdat, but we don't know for sure whether or
     not something is comdat until end-of-file.  */
! #define DECL_NEEDED_P(DECL)						\
!   ((at_eof && TREE_PUBLIC (DECL) && !DECL_COMDAT (DECL))		\
!    || (DECL_ASSEMBLER_NAME_SET_P (DECL)					\
!        && TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME ((DECL))))	\
     || (flag_syntax_only && TREE_USED ((DECL))))
  
  /* Non-zero iff DECL is memory-based.  The DECL_RTL of
*************** extern void GNU_xref_member			PARAMS ((t
*** 4531,4537 ****
  
  /* in mangle.c */
  extern void init_mangle                         PARAMS ((void));
! extern tree mangle_decl                         PARAMS ((tree));
  extern const char *mangle_type_string           PARAMS ((tree));
  extern tree mangle_type                         PARAMS ((tree));
  extern tree mangle_typeinfo_for_type            PARAMS ((tree));
--- 4532,4538 ----
  
  /* in mangle.c */
  extern void init_mangle                         PARAMS ((void));
! extern void mangle_decl                         PARAMS ((tree));
  extern const char *mangle_type_string           PARAMS ((tree));
  extern tree mangle_type                         PARAMS ((tree));
  extern tree mangle_typeinfo_for_type            PARAMS ((tree));
Index: cp/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.758
diff -c -p -r1.758 decl.c
*** decl.c	2001/03/15 03:37:14	1.758
--- decl.c	2001/03/19 23:06:04
*************** pushtag (name, type, globalize)
*** 2827,2833 ****
  	    DECL_IGNORED_P (d) = 1;
  
  	  TYPE_CONTEXT (type) = DECL_CONTEXT (d);
- 	  DECL_ASSEMBLER_NAME (d) = DECL_NAME (d);
  
  	  /* If this is a local class, keep track of it.  We need this
  	     information for name-mangling, and so that it is possible to find
--- 2827,2832 ----
*************** pushtag (name, type, globalize)
*** 2838,2846 ****
  	      && TREE_CODE (TYPE_CONTEXT (type)) == FUNCTION_DECL
  	      && !processing_template_decl)
  	    VARRAY_PUSH_TREE (local_classes, type);
- 
- 	  if (!uses_template_parms (type))
- 	    DECL_ASSEMBLER_NAME (d) = mangle_type (type);
          }
        if (b->parm_flag == 2)
  	{
--- 2837,2842 ----
*************** duplicate_decls (newdecl, olddecl)
*** 3161,3167 ****
  	     will be banished.  */
  	  DECL_LANGUAGE (olddecl) = DECL_LANGUAGE (newdecl);
  	  SET_DECL_RTL (olddecl, DECL_RTL (newdecl));
! 	  DECL_ASSEMBLER_NAME (olddecl) = DECL_ASSEMBLER_NAME (newdecl);
  	  SET_IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (newdecl),
  				       newdecl);
  	}
--- 3157,3163 ----
  	     will be banished.  */
  	  DECL_LANGUAGE (olddecl) = DECL_LANGUAGE (newdecl);
  	  SET_DECL_RTL (olddecl, DECL_RTL (newdecl));
! 	  COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl);
  	  SET_IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (newdecl),
  				       newdecl);
  	}
*************** duplicate_decls (newdecl, olddecl)
*** 3633,3639 ****
        if (! types_match)
  	{
  	  DECL_LANGUAGE (olddecl) = DECL_LANGUAGE (newdecl);
! 	  DECL_ASSEMBLER_NAME (olddecl) = DECL_ASSEMBLER_NAME (newdecl);
  	  SET_DECL_RTL (olddecl, DECL_RTL (newdecl));
  	}
        if (! types_match || new_defines_function)
--- 3629,3635 ----
        if (! types_match)
  	{
  	  DECL_LANGUAGE (olddecl) = DECL_LANGUAGE (newdecl);
! 	  COPY_DECL_ASSEMBLER_NAME (newdecl, olddecl);
  	  SET_DECL_RTL (olddecl, DECL_RTL (newdecl));
  	}
        if (! types_match || new_defines_function)
*************** duplicate_decls (newdecl, olddecl)
*** 3683,3689 ****
    TREE_ADDRESSABLE (newdecl) = TREE_ADDRESSABLE (olddecl);
    TREE_ASM_WRITTEN (newdecl) = TREE_ASM_WRITTEN (olddecl);
    DECL_COMMON (newdecl) = DECL_COMMON (olddecl);
!   DECL_ASSEMBLER_NAME (newdecl) = DECL_ASSEMBLER_NAME (olddecl);
  
    if (TREE_CODE (newdecl) == FUNCTION_DECL)
      {
--- 3679,3685 ----
    TREE_ADDRESSABLE (newdecl) = TREE_ADDRESSABLE (olddecl);
    TREE_ASM_WRITTEN (newdecl) = TREE_ASM_WRITTEN (olddecl);
    DECL_COMMON (newdecl) = DECL_COMMON (olddecl);
!   COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl);
  
    if (TREE_CODE (newdecl) == FUNCTION_DECL)
      {
*************** pushdecl (x)
*** 3846,3853 ****
  	  if (TREE_CODE (x) == FUNCTION_DECL)
  	    for (match = t; match; match = OVL_NEXT (match))
  	      {
! 		if (DECL_ASSEMBLER_NAME (OVL_CURRENT (t))
! 		    == DECL_ASSEMBLER_NAME (x))
  		  break;
  	      }
  	  else
--- 3842,3848 ----
  	  if (TREE_CODE (x) == FUNCTION_DECL)
  	    for (match = t; match; match = OVL_NEXT (match))
  	      {
! 		if (decls_match (OVL_CURRENT (match), x))
  		  break;
  	      }
  	  else
*************** pushdecl (x)
*** 4028,4060 ****
  	  if (IDENTIFIER_GLOBAL_VALUE (name) == NULL_TREE && TREE_PUBLIC (x))
  	    TREE_PUBLIC (name) = 1;
  
! 	  /* Bind the mangled name for the entity.  In the future, we
! 	     should not need to do this; mangled names are an
! 	     implementation detail of which the front-end should not
! 	     need to be aware.  */
! 	  if (!(TREE_CODE (x) == TYPE_DECL && DECL_ARTIFICIAL (x)
! 		&& t != NULL_TREE)
! 	      /* For an ordinary function, we create a binding from
! 		 the mangled name (i.e., NAME) to the DECL.  But, for
! 		 an `extern "C"' function, the mangled name and the
! 		 ordinary name are the same so we need not do this.  */
! 	      && !DECL_EXTERN_C_FUNCTION_P (x))
! 	    {
! 	      tree mangled_name;
! 
! 	      if (TREE_CODE (x) == TYPE_DECL || TREE_CODE (x) == VAR_DECL
! 		  || TREE_CODE (x) == NAMESPACE_DECL)
! 		mangled_name = name;
! 	      else
! 		mangled_name = DECL_ASSEMBLER_NAME (x);
  
- 	      if (TREE_CODE (x) == FUNCTION_DECL)
- 		my_friendly_assert
- 		  ((IDENTIFIER_GLOBAL_VALUE (mangled_name) == NULL_TREE)
- 		  || (IDENTIFIER_GLOBAL_VALUE (mangled_name) == x), 378);
- 	      SET_IDENTIFIER_NAMESPACE_VALUE (mangled_name, x);
- 	    }
- 
  	  /* Don't forget if the function was used via an implicit decl.  */
  	  if (IDENTIFIER_IMPLICIT_DECL (name)
  	      && TREE_USED (IDENTIFIER_IMPLICIT_DECL (name)))
--- 4023,4038 ----
  	  if (IDENTIFIER_GLOBAL_VALUE (name) == NULL_TREE && TREE_PUBLIC (x))
  	    TREE_PUBLIC (name) = 1;
  
!  	  /* Bind the name for the entity.  */
!  	  if (!(TREE_CODE (x) == TYPE_DECL && DECL_ARTIFICIAL (x)
!   		&& t != NULL_TREE)
!  	      && (TREE_CODE (x) == TYPE_DECL
!  		  || TREE_CODE (x) == VAR_DECL
!  		  || TREE_CODE (x) == NAMESPACE_DECL
!  		  || TREE_CODE (x) == CONST_DECL
!  		  || TREE_CODE (x) == TEMPLATE_DECL))
!  	    SET_IDENTIFIER_NAMESPACE_VALUE (name, x);
  
  	  /* Don't forget if the function was used via an implicit decl.  */
  	  if (IDENTIFIER_IMPLICIT_DECL (name)
  	      && TREE_USED (IDENTIFIER_IMPLICIT_DECL (name)))
*************** builtin_function (name, type, code, clas
*** 6670,6676 ****
       we cannot change DECL_ASSEMBLER_NAME until we have installed this
       function in the namespace.  */
    if (libname)
!     DECL_ASSEMBLER_NAME (decl) = get_identifier (libname);
  
    /* Warn if a function in the namespace for users
       is used without an occasion to consider it declared.  */
--- 6648,6655 ----
       we cannot change DECL_ASSEMBLER_NAME until we have installed this
       function in the namespace.  */
    if (libname)
!     SET_DECL_ASSEMBLER_NAME (decl, get_identifier (libname));
!   make_decl_rtl (decl, NULL);
  
    /* Warn if a function in the namespace for users
       is used without an occasion to consider it declared.  */
*************** build_library_fn_1 (name, operator_code,
*** 6695,6700 ****
--- 6674,6680 ----
    DECL_ARTIFICIAL (fn) = 1;
    TREE_NOTHROW (fn) = 1;
    SET_OVERLOADED_OPERATOR_CODE (fn, operator_code);
+   DECL_LANGUAGE (fn) = lang_c;
    return fn;
  }
  
*************** build_cp_library_fn (name, operator_code
*** 6721,6726 ****
--- 6701,6707 ----
    tree fn = build_library_fn_1 (name, operator_code, type);
    TREE_NOTHROW (fn) = TYPE_NOTHROW_P (type);
    DECL_CONTEXT (fn) = FROB_CONTEXT (current_namespace);
+   DECL_LANGUAGE (fn) = lang_cplusplus;
    set_mangled_name_for_decl (fn);
    return fn;
  }
*************** maybe_commonize_var (decl)
*** 7534,7542 ****
  	  /* else we lose. We can only do this if we can use common,
  	     which we can't if it has been initialized.  */
  
! 	  if (TREE_PUBLIC (decl))
! 	    DECL_ASSEMBLER_NAME (decl) = mangle_decl (decl);
! 	  else
  	    {
  	      cp_warning_at ("sorry: semantics of inline function static data `%#D' are wrong (you'll wind up with multiple copies)", decl);
  	      cp_warning_at ("  you can work around this by removing the initializer", decl);
--- 7515,7521 ----
  	  /* else we lose. We can only do this if we can use common,
  	     which we can't if it has been initialized.  */
  
! 	  if (!TREE_PUBLIC (decl))
  	    {
  	      cp_warning_at ("sorry: semantics of inline function static data `%#D' are wrong (you'll wind up with multiple copies)", decl);
  	      cp_warning_at ("  you can work around this by removing the initializer", decl);
*************** make_rtl_for_nonlocal_decl (decl, init, 
*** 7721,7727 ****
  
    /* Set the DECL_ASSEMBLER_NAME for the variable.  */
    if (asmspec)
!     DECL_ASSEMBLER_NAME (decl) = get_identifier (asmspec);
  
    /* We don't create any RTL for local variables.  */
    if (DECL_FUNCTION_SCOPE_P (decl) && !TREE_STATIC (decl))
--- 7700,7706 ----
  
    /* Set the DECL_ASSEMBLER_NAME for the variable.  */
    if (asmspec)
!     SET_DECL_ASSEMBLER_NAME (decl, get_identifier (asmspec));
  
    /* We don't create any RTL for local variables.  */
    if (DECL_FUNCTION_SCOPE_P (decl) && !TREE_STATIC (decl))
*************** make_rtl_for_nonlocal_decl (decl, init, 
*** 7751,7762 ****
        defer_p = 1;
      }
  
!   /* If we're deferring the variable, just make RTL.  Do not actually
!      emit the variable.  */
!   if (defer_p)
      make_decl_rtl (decl, asmspec);
    /* If we're not deferring, go ahead and assemble the variable.  */
!   else
      rest_of_decl_compilation (decl, asmspec, toplev, at_eof);
  }
  
--- 7730,7744 ----
        defer_p = 1;
      }
  
!   /* If we're deferring the variable, we only need to make RTL if
!      there's an ASMSPEC.  Otherwise, we'll lazily create it later when
!      we need it.  (There's no way to lazily create RTL for things that
!      have assembly specs because the information about the specifier
!      isn't stored in the tree, yet)  */
!   if (defer_p && asmspec)
      make_decl_rtl (decl, asmspec);
    /* If we're not deferring, go ahead and assemble the variable.  */
!   else if (!defer_p)
      rest_of_decl_compilation (decl, asmspec, toplev, at_eof);
  }
  
*************** cp_finish_decl (decl, init, asmspec_tree
*** 8034,8040 ****
        /* This must override the asm specifier which was placed by
  	 grokclassfn.  Lay this out fresh.  */
        SET_DECL_RTL (TREE_TYPE (decl), NULL_RTX);
!       DECL_ASSEMBLER_NAME (decl) = get_identifier (asmspec);
        make_decl_rtl (decl, asmspec);
      }
  
--- 8016,8022 ----
        /* This must override the asm specifier which was placed by
  	 grokclassfn.  Lay this out fresh.  */
        SET_DECL_RTL (TREE_TYPE (decl), NULL_RTX);
!       SET_DECL_ASSEMBLER_NAME (decl, get_identifier (asmspec));
        make_decl_rtl (decl, asmspec);
      }
  
*************** grokfndecl (ctype, type, declarator, ori
*** 8858,8869 ****
    if (has_default_arg)
      add_defarg_fn (decl);
  
-   /* Plain overloading: will not be grok'd by grokclassfn.  */
-   if (! ctype && ! processing_template_decl
-       && (! DECL_EXTERN_C_P (decl) || DECL_OVERLOADED_OPERATOR_P (decl))
-       && ! DECL_USE_TEMPLATE (decl))
-     set_mangled_name_for_decl (decl);
- 
    if (funcdef_flag)
      /* Make the init_value nonzero so pushdecl knows this is not
         tentative.  error_mark_node is replaced later with the BLOCK.  */
--- 8840,8845 ----
*************** grokvardecl (type, declarator, specbits_
*** 8968,8977 ****
        type = TREE_TYPE (type);
        decl = build_lang_decl (VAR_DECL, declarator, type);
        DECL_CONTEXT (decl) = basetype;
-       /* DECL_ASSEMBLER_NAME is needed only for full-instantiated
- 	 templates.  */
-       if (!uses_template_parms (decl))
- 	DECL_ASSEMBLER_NAME (decl) = mangle_decl (decl);
      }
    else
      {
--- 8944,8949 ----
*************** grokvardecl (type, declarator, specbits_
*** 8996,9002 ****
  
        context = DECL_CONTEXT (decl);
        if (declarator && context && current_lang_name != lang_name_c)
! 	DECL_ASSEMBLER_NAME (decl) = mangle_decl (decl);
      }
  
    if (in_namespace)
--- 8968,8977 ----
  
        context = DECL_CONTEXT (decl);
        if (declarator && context && current_lang_name != lang_name_c)
! 	/* We can't mangle lazily here because we don't have any
! 	   way to recover whether or not a variable was `extern
! 	   "C"' later.  */
! 	mangle_decl (decl);
      }
  
    if (in_namespace)
*************** grokdeclarator (declarator, declspecs, d
*** 11005,11012 ****
  	    DECL_NAME (CLASSTYPE_TI_TEMPLATE (type))
  	      = TYPE_IDENTIFIER (type);
  
- 	  DECL_ASSEMBLER_NAME (decl) = mangle_type (type);
- 
  	  /* FIXME remangle member functions; member functions of a
  	     type with external linkage have external linkage.  */
  	}
--- 10980,10985 ----
*************** start_function (declspecs, declarator, a
*** 13537,13555 ****
    if (attrs)
      cplus_decl_attributes (decl1, NULL_TREE, attrs);
  
-   /* We need to do this even if we aren't expanding yet so that
-      assemble_external works.  */
-   make_decl_rtl (decl1, NULL);
- 
    /* Promote the value to int before returning it.  */
    if (C_PROMOTING_INTEGER_TYPE_P (restype))
      restype = type_promotes_to (restype);
  
-   /* If this fcn was already referenced via a block-scope `extern' decl
-      (or an implicit decl), propagate certain information about the usage.  */
-   if (TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl1)))
-     TREE_ADDRESSABLE (decl1) = 1;
- 
    if (DECL_RESULT (decl1) == NULL_TREE)
      {
        DECL_RESULT (decl1)
--- 13510,13519 ----
*************** cp_missing_noreturn_ok_p (decl)
*** 14488,14492 ****
       tree decl;
  {
    /* A missing noreturn is ok for the `main' function.  */
!   return MAIN_NAME_P (DECL_ASSEMBLER_NAME (decl));
  }
--- 14452,14456 ----
       tree decl;
  {
    /* A missing noreturn is ok for the `main' function.  */
!   return DECL_MAIN_P (decl);
  }
Index: cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.446
diff -c -p -r1.446 decl2.c
*** decl2.c	2001/03/15 02:50:52	1.446
--- decl2.c	2001/03/19 23:06:07
*************** grokclassfn (ctype, function, flags, qua
*** 1061,1077 ****
    DECL_ARGUMENTS (function) = last_function_parms;
    DECL_CONTEXT (function) = ctype;
  
    if (flags == DTOR_FLAG || DECL_CONSTRUCTOR_P (function))
      maybe_retrofit_in_chrg (function);
  
    if (flags == DTOR_FLAG)
      {
        DECL_DESTRUCTOR_P (function) = 1;
-       set_mangled_name_for_decl (function);
        TYPE_HAS_DESTRUCTOR (ctype) = 1;
      }
-   else
-     set_mangled_name_for_decl (function);
  }
  
  /* Work on the expr used by alignof (this is only called by the parser).  */
--- 1061,1077 ----
    DECL_ARGUMENTS (function) = last_function_parms;
    DECL_CONTEXT (function) = ctype;
  
+   if (flags == DTOR_FLAG)
+     DECL_DESTRUCTOR_P (function) = 1;
+ 
    if (flags == DTOR_FLAG || DECL_CONSTRUCTOR_P (function))
      maybe_retrofit_in_chrg (function);
  
    if (flags == DTOR_FLAG)
      {
        DECL_DESTRUCTOR_P (function) = 1;
        TYPE_HAS_DESTRUCTOR (ctype) = 1;
      }
  }
  
  /* Work on the expr used by alignof (this is only called by the parser).  */
*************** check_classfn (ctype, function)
*** 1436,1457 ****
  		   fndecls = OVL_NEXT (fndecls))
  		{
  		  fndecl = OVL_CURRENT (fndecls);
- 		  /* The DECL_ASSEMBLER_NAME for a TEMPLATE_DECL, or
- 		     for a for member function of a template class, is
- 		     not mangled, so the check below does not work
- 		     correctly in that case.  Since mangled destructor
- 		     names do not include the type of the arguments,
- 		     we can't use this short-cut for them, either.
- 		     (It's not legal to declare arguments for a
- 		     destructor, but some people try.)  */
- 		  if (!DECL_DESTRUCTOR_P (function)
- 		      && (DECL_ASSEMBLER_NAME (function)
- 			  != DECL_NAME (function))
- 		      && (DECL_ASSEMBLER_NAME (fndecl)
- 			  != DECL_NAME (fndecl))
- 		      && (DECL_ASSEMBLER_NAME (function) 
- 			  == DECL_ASSEMBLER_NAME (fndecl)))
- 		    return fndecl;
  
  		  /* We cannot simply call decls_match because this
  		     doesn't work for static member functions that are 
--- 1436,1441 ----
*************** finish_static_data_member_decl (decl, in
*** 1525,1535 ****
       tree asmspec_tree;
       int flags;
  {
-   const char *asmspec = 0;
- 
-   if (asmspec_tree)
-     asmspec = TREE_STRING_POINTER (asmspec_tree);
- 
    my_friendly_assert (TREE_PUBLIC (decl), 0);
  
    DECL_CONTEXT (decl) = current_class_type;
--- 1509,1514 ----
*************** finish_static_data_member_decl (decl, in
*** 1538,1548 ****
       decl of our TREE_CHAIN.  Instead, we modify cp_finish_decl to do
       the right thing, namely, to put this decl out straight away.  */
    /* current_class_type can be NULL_TREE in case of error.  */
!   if (!asmspec && current_class_type)
!     {
!       DECL_INITIAL (decl) = error_mark_node;
!       DECL_ASSEMBLER_NAME (decl) = mangle_decl (decl);
!     }
    if (! processing_template_decl)
      {
        if (!pending_statics)
--- 1517,1525 ----
       decl of our TREE_CHAIN.  Instead, we modify cp_finish_decl to do
       the right thing, namely, to put this decl out straight away.  */
    /* current_class_type can be NULL_TREE in case of error.  */
!   if (!asmspec_tree && current_class_type)
!     DECL_INITIAL (decl) = error_mark_node;
! 
    if (! processing_template_decl)
      {
        if (!pending_statics)
*************** grokfield (declarator, declspecs, init, 
*** 1672,1683 ****
        if (CLASS_TYPE_P (TREE_TYPE (value)))
          CLASSTYPE_GOT_SEMICOLON (TREE_TYPE (value)) = 1;
        
-       /* Now that we've updated the context, we need to remangle the
- 	 name for this TYPE_DECL.  */
-       DECL_ASSEMBLER_NAME (value) = DECL_NAME (value);
-       if (!uses_template_parms (value)) 
- 	DECL_ASSEMBLER_NAME (value) = mangle_type (TREE_TYPE (value));
- 
        if (processing_template_decl)
  	value = push_template_decl (value);
  
--- 1649,1654 ----
*************** grokfield (declarator, declspecs, init, 
*** 1776,1782 ****
  	  /* This must override the asm specifier which was placed
  	     by grokclassfn.  Lay this out fresh.  */
  	  SET_DECL_RTL (value, NULL_RTX);
! 	  DECL_ASSEMBLER_NAME (value) = get_identifier (asmspec);
  	}
        cp_finish_decl (value, init, asmspec_tree, flags);
  
--- 1747,1753 ----
  	  /* This must override the asm specifier which was placed
  	     by grokclassfn.  Lay this out fresh.  */
  	  SET_DECL_RTL (value, NULL_RTX);
! 	  SET_DECL_ASSEMBLER_NAME (value, get_identifier (asmspec));
  	}
        cp_finish_decl (value, init, asmspec_tree, flags);
  
Index: cp/error.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/error.c,v
retrieving revision 1.150
diff -c -p -r1.150 error.c
*** error.c	2001/02/18 19:07:59	1.150
--- error.c	2001/03/19 23:06:09
*************** ident_fndecl (t)
*** 883,901 ****
  #  endif
  #endif
  
- #define GLOBAL_IORD_P(NODE) \
-   ! strncmp (IDENTIFIER_POINTER(NODE), GLOBAL_THING, sizeof (GLOBAL_THING) - 1)
- 
  static void
  dump_global_iord (t)
       tree t;
  {
-   const char *name = IDENTIFIER_POINTER (t);
    const char *p = NULL;
  
!   if (name [sizeof (GLOBAL_THING) - 1] == 'I')
      p = "initializers";
!   else if (name [sizeof (GLOBAL_THING) - 1] == 'D')
      p = "destructors";
    else
      my_friendly_abort (352);
--- 883,897 ----
  #  endif
  #endif
  
  static void
  dump_global_iord (t)
       tree t;
  {
    const char *p = NULL;
  
!   if (DECL_GLOBAL_CTOR_P (t))
      p = "initializers";
!   else if (DECL_GLOBAL_DTOR_P (t))
      p = "destructors";
    else
      my_friendly_abort (352);
*************** dump_decl (t, flags)
*** 1041,1048 ****
        /* Fall through.  */
  
      case FUNCTION_DECL:
!       if (GLOBAL_IORD_P (DECL_ASSEMBLER_NAME (t)))
! 	dump_global_iord (DECL_ASSEMBLER_NAME (t));
        else if (! DECL_LANG_SPECIFIC (t))
  	print_identifier (scratch_buffer, "<internal>");
        else
--- 1037,1044 ----
        /* Fall through.  */
  
      case FUNCTION_DECL:
!       if (DECL_GLOBAL_CTOR_P (t) || DECL_GLOBAL_DTOR_P (t))
! 	dump_global_iord (t);
        else if (! DECL_LANG_SPECIFIC (t))
  	print_identifier (scratch_buffer, "<internal>");
        else
Index: cp/except.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/except.c,v
retrieving revision 1.123
diff -c -p -r1.123 except.c
*** except.c	2001/03/15 07:59:53	1.123
--- except.c	2001/03/19 23:06:09
*************** nothrow_libfn_p (fn)
*** 1121,1126 ****
--- 1121,1127 ----
  
    if (TREE_PUBLIC (fn)
        && DECL_EXTERNAL (fn)
+       && DECL_NAMESPACE_SCOPE_P (fn)
        && DECL_EXTERN_C_P (fn))
      /* OK */;
    else
Index: cp/init.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/init.c,v
retrieving revision 1.239
diff -c -p -r1.239 init.c
*** init.c	2001/03/15 02:50:53	1.239
--- init.c	2001/03/19 23:06:11
*************** build_java_class_ref (type)
*** 2219,2225 ****
      for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
        if (DECL_NAME (field) == CL_suffix)
  	{
! 	  name = mangle_decl (field);
  	  break;
  	}
      if (!field)
--- 2219,2226 ----
      for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
        if (DECL_NAME (field) == CL_suffix)
  	{
! 	  mangle_decl (field);
! 	  name = DECL_ASSEMBLER_NAME (field);
  	  break;
  	}
      if (!field)
Index: cp/mangle.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/mangle.c,v
retrieving revision 1.27
diff -c -p -r1.27 mangle.c
*** mangle.c	2001/02/22 21:46:06	1.27
--- mangle.c	2001/03/19 23:06:13
*************** mangle_decl_string (decl)
*** 2069,2074 ****
--- 2069,2085 ----
  
    if (TREE_CODE (decl) == TYPE_DECL)
      write_type (TREE_TYPE (decl));
+   else if (/* The names of `extern "C"' functions are not mangled.  */
+ 	   (TREE_CODE (decl) == FUNCTION_DECL 
+ 	    /* If there's no DECL_LANG_SPECIFIC, it's a function built
+ 	       by language-independent code, which never builds
+ 	       functions with C++ linkage.  */
+ 	    && (!DECL_LANG_SPECIFIC (decl) 
+ 		|| DECL_EXTERN_C_FUNCTION_P (decl)))
+ 	   /* The names of global variables aren't mangled either.  */
+ 	   || (TREE_CODE (decl) == VAR_DECL
+ 	       && CP_DECL_CONTEXT (decl) == global_namespace))
+     write_string (IDENTIFIER_POINTER (DECL_NAME (decl)));
    else
      {
        write_mangled_name (decl);
*************** mangle_decl_string (decl)
*** 2089,2099 ****
  
  /* Create an identifier for the external mangled name of DECL.  */
  
! tree
  mangle_decl (decl)
       tree decl;
  {
!   return get_identifier (mangle_decl_string (decl));
  }
  
  /* Generate the mangled representation of TYPE.  */
--- 2100,2112 ----
  
  /* Create an identifier for the external mangled name of DECL.  */
  
! void
  mangle_decl (decl)
       tree decl;
  {
!   tree id = get_identifier (mangle_decl_string (decl));
! 
!   SET_DECL_ASSEMBLER_NAME (decl, id);
  }
  
  /* Generate the mangled representation of TYPE.  */
Index: cp/method.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/method.c,v
retrieving revision 1.194
diff -c -p -r1.194 method.c
*** method.c	2001/03/15 02:50:53	1.194
--- method.c	2001/03/19 23:06:13
*************** set_mangled_name_for_decl (decl)
*** 90,96 ****
      /* There's no need to mangle the name of a template function.  */
      return;
  
!   DECL_ASSEMBLER_NAME (decl) = mangle_decl (decl);
  }
  
  
--- 90,96 ----
      /* There's no need to mangle the name of a template function.  */
      return;
  
!   mangle_decl (decl);
  }
  
  
*************** make_thunk (function, delta, vcall_index
*** 346,351 ****
--- 346,352 ----
        thunk = build_decl (FUNCTION_DECL, thunk_id, TREE_TYPE (func_decl));
        DECL_LANG_SPECIFIC (thunk) = DECL_LANG_SPECIFIC (func_decl);
        copy_lang_decl (func_decl);
+       SET_DECL_ASSEMBLER_NAME (thunk, thunk_id);
        DECL_CONTEXT (thunk) = DECL_CONTEXT (func_decl);
        TREE_READONLY (thunk) = TREE_READONLY (func_decl);
        TREE_THIS_VOLATILE (thunk) = TREE_THIS_VOLATILE (func_decl);
*************** make_thunk (function, delta, vcall_index
*** 373,378 ****
--- 374,380 ----
        DECL_DEFERRED_FN (thunk) = 0;
        /* So that finish_file can write out any thunks that need to be: */
        pushdecl_top_level (thunk);
+       SET_IDENTIFIER_GLOBAL_VALUE (thunk_id, thunk);
      }
    return thunk;
  }
Index: cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.525
diff -c -p -r1.525 pt.c
*** pt.c	2001/03/15 02:50:54	1.525
--- pt.c	2001/03/19 23:06:19
*************** static tree tsubst_template_parms PARAMS
*** 144,150 ****
  static void regenerate_decl_from_template PARAMS ((tree, tree));
  static tree most_specialized PARAMS ((tree, tree, tree));
  static tree most_specialized_class PARAMS ((tree, tree));
- static void set_mangled_name_for_template_decl PARAMS ((tree));
  static int template_class_depth_real PARAMS ((tree, int));
  static tree tsubst_aggr_type PARAMS ((tree, tree, int, tree, int));
  static tree tsubst_decl PARAMS ((tree, tree, tree));
--- 144,149 ----
*************** check_explicit_specialization (declarato
*** 1678,1701 ****
  	  TREE_PRIVATE (decl) = TREE_PRIVATE (gen_tmpl);
  	  TREE_PROTECTED (decl) = TREE_PROTECTED (gen_tmpl);
  
- 	  /* Mangle the function name appropriately.  Note that we do
- 	     not mangle specializations of non-template member
- 	     functions of template classes, e.g. with
- 
- 	       template <class T> struct S { void f(); }
- 
- 	     and given the specialization 
- 
- 	       template <> void S<int>::f() {}
- 
- 	     we do not mangle S<int>::f() here.  That's because it's
- 	     just an ordinary member function and doesn't need special
- 	     treatment.  We do this here so that the ordinary,
- 	     non-template, name-mangling algorithm will not be used
- 	     later.  */
- 	  if (is_member_template (tmpl) || ctype == NULL_TREE)
- 	    set_mangled_name_for_template_decl (decl);
- 
  	  if (is_friend && !have_def)
  	    /* This is not really a declaration of a specialization.
  	       It's just the name of an instantiation.  But, it's not
--- 1677,1682 ----
*************** lookup_template_class (d1, arglist, in_d
*** 4220,4230 ****
  	 is set up.  */
        if (TREE_CODE (t) != ENUMERAL_TYPE)
  	DECL_NAME (type_decl) = classtype_mangled_name (t);
-       DECL_ASSEMBLER_NAME (type_decl) = DECL_NAME (type_decl);
        if (!is_partial_instantiation)
  	{
- 	  DECL_ASSEMBLER_NAME (type_decl) = mangle_decl (type_decl);
- 
  	  /* For backwards compatibility; code that uses
  	     -fexternal-templates expects looking up a template to
  	     instantiate it.  I think DDD still relies on this.
--- 4201,4208 ----
*************** tsubst_friend_function (decl, args)
*** 4606,4623 ****
  	= DECL_SAVED_TREE (DECL_TEMPLATE_RESULT (decl));
      }
  
!   /* The mangled name for the NEW_FRIEND is incorrect.  The call to
!      tsubst will have resulted in a call to
!      set_mangled_name_for_template_decl.  But, the function is not a
!      template instantiation and should not be mangled like one.
!      Therefore, we remangle the function name.  We don't have to do
!      this if the NEW_FRIEND is a template since
!      set_mangled_name_for_template_decl doesn't do anything if the
!      function declaration still uses template arguments.  */
    if (TREE_CODE (new_friend) != TEMPLATE_DECL)
      {
-       set_mangled_name_for_decl (new_friend);
        SET_DECL_RTL (new_friend, NULL_RTX);
      }
        
    if (DECL_NAMESPACE_SCOPE_P (new_friend))
--- 4584,4597 ----
  	= DECL_SAVED_TREE (DECL_TEMPLATE_RESULT (decl));
      }
  
!   /* The mangled name for the NEW_FRIEND is incorrect.  The function
!      is not a template instantiation and should not be mangled like
!      one.  Therefore, we forget the mangling here; we'll recompute it
!      later if we need it.  */
    if (TREE_CODE (new_friend) != TEMPLATE_DECL)
      {
        SET_DECL_RTL (new_friend, NULL_RTX);
+       SET_DECL_ASSEMBLER_NAME (new_friend, NULL_TREE);
      }
        
    if (DECL_NAMESPACE_SCOPE_P (new_friend))
*************** tsubst_decl (t, args, type)
*** 5805,5810 ****
--- 5779,5787 ----
  	r = copy_decl (t);
  	DECL_USE_TEMPLATE (r) = 0;
  	TREE_TYPE (r) = type;
+ 	/* Clear out the mangled name and RTL for the instantiation.  */
+ 	SET_DECL_ASSEMBLER_NAME (r, NULL_TREE);
+ 	SET_DECL_RTL (r, NULL_RTX);
  
  	DECL_CONTEXT (r) = ctx;
  	DECL_VIRTUAL_CONTEXT (r)
*************** tsubst_decl (t, args, type)
*** 5839,5847 ****
  	    TREE_CHAIN (DECL_CLONED_FUNCTION (r)) = r;
  	  }
  
! 	/* Set up the DECL_TEMPLATE_INFO for R and compute its mangled
! 	   name.  There's no need to do this in the special friend
! 	   case mentioned above where GEN_TMPL is NULL.  */
  	if (gen_tmpl)
  	  {
  	    DECL_TEMPLATE_INFO (r) 
--- 5816,5824 ----
  	    TREE_CHAIN (DECL_CLONED_FUNCTION (r)) = r;
  	  }
  
! 	/* Set up the DECL_TEMPLATE_INFO for R.  There's no need to do
! 	   this in the special friend case mentioned above where
! 	   GEN_TMPL is NULL.  */
  	if (gen_tmpl)
  	  {
  	    DECL_TEMPLATE_INFO (r) 
*************** tsubst_decl (t, args, type)
*** 5849,5885 ****
  	    SET_DECL_IMPLICIT_INSTANTIATION (r);
  	    register_specialization (r, gen_tmpl, argvec);
  
- 	    /* Set the mangled name for R.  */
- 	    if (DECL_DESTRUCTOR_P (t)) 
- 	      set_mangled_name_for_decl (r);
- 	    else 
- 	      {
- 		/* Instantiations of template functions must be mangled
- 		   specially, in order to conform to 14.5.5.1
- 		   [temp.over.link].  */
- 		tree tmpl = DECL_TI_TEMPLATE (t);
- 		
- 		/* TMPL will be NULL if this is a specialization of a
- 		   member function of a template class.  */
- 		if (tmpl == NULL_TREE
- 		    || (member && !is_member_template (tmpl)
- 			&& !DECL_TEMPLATE_INFO (tmpl)))
- 		  set_mangled_name_for_decl (r);
- 		else
- 		  set_mangled_name_for_template_decl (r);
- 	      }
- 	    
- 	    SET_DECL_RTL (r, NULL_RTX);
- 	    
- 	    /* Like grokfndecl.  If we don't do this, pushdecl will
- 	       mess up our TREE_CHAIN because it doesn't find a
- 	       previous decl.  Sigh.  */
- 	    if (member
- 		&& ! uses_template_parms (r)
- 		&& (IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (r)) 
- 		    == NULL_TREE))
- 	      SET_IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (r), r);
- 
  	    /* We're not supposed to instantiate default arguments
  	       until they are called, for a template.  But, for a
  	       declaration like:
--- 5826,5831 ----
*************** tsubst_decl (t, args, type)
*** 6032,6037 ****
--- 5978,5986 ----
  	TREE_TYPE (r) = type;
  	c_apply_type_quals_to_decl (CP_TYPE_QUALS (type), r);
  	DECL_CONTEXT (r) = ctx;
+ 	/* Clear out the mangled name and RTL for the instantiation.  */
+ 	SET_DECL_ASSEMBLER_NAME (r, NULL_TREE);
+ 	SET_DECL_RTL (r, NULL_RTX);
  
  	/* Don't try to expand the initializer until someone tries to use
  	   this variable; otherwise we run into circular dependencies.  */
*************** regenerate_decl_from_template (decl, tmp
*** 9762,9768 ****
       functions, this is not so.  See tsubst_friend_function for
       details.  */
    DECL_TI_TEMPLATE (new_decl) = DECL_TI_TEMPLATE (decl);
!   DECL_ASSEMBLER_NAME (new_decl) = DECL_ASSEMBLER_NAME (decl);
    COPY_DECL_RTL (decl, new_decl);
    DECL_USE_TEMPLATE (new_decl) = DECL_USE_TEMPLATE (decl);
  
--- 9711,9717 ----
       functions, this is not so.  See tsubst_friend_function for
       details.  */
    DECL_TI_TEMPLATE (new_decl) = DECL_TI_TEMPLATE (decl);
!   COPY_DECL_ASSEMBLER_NAME (decl, new_decl);
    COPY_DECL_RTL (decl, new_decl);
    DECL_USE_TEMPLATE (new_decl) = DECL_USE_TEMPLATE (decl);
  
*************** get_mostly_instantiated_function_type (d
*** 10290,10310 ****
      *tparmsp = tparms;
  
    return fn_type;
- }
- 
- /* Set the DECL_ASSEMBLER_NAME for DECL, which is a FUNCTION_DECL that
-    is either an instantiation or specialization of a template
-    function.  */
- 
- static void
- set_mangled_name_for_template_decl (decl)
-      tree decl;
- {
-   my_friendly_assert (TREE_CODE (decl) == FUNCTION_DECL, 0);
-   my_friendly_assert (DECL_TEMPLATE_INFO (decl) != NULL_TREE, 0);
- 
-   /* Under the new ABI, we don't need special machinery.  */
-   set_mangled_name_for_decl (decl);
  }
  
  /* Return truthvalue if we're processing a template different from
--- 10239,10244 ----
Index: cp/rtti.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/rtti.c,v
retrieving revision 1.110
diff -c -p -r1.110 rtti.c
*** rtti.c	2001/02/18 20:31:44	1.110
--- rtti.c	2001/03/19 23:06:20
*************** get_tinfo_decl (type)
*** 354,360 ****
        TREE_PUBLIC (d) = 1;
        if (flag_weak || !typeinfo_in_lib_p (d))
  	comdat_linkage (d);
!       DECL_ASSEMBLER_NAME (d) = DECL_NAME (d);
        cp_finish_decl (d, NULL_TREE, NULL_TREE, 0);
  
        pushdecl_top_level (d);
--- 354,360 ----
        TREE_PUBLIC (d) = 1;
        if (flag_weak || !typeinfo_in_lib_p (d))
  	comdat_linkage (d);
!       SET_DECL_ASSEMBLER_NAME (d, name);
        cp_finish_decl (d, NULL_TREE, NULL_TREE, 0);
  
        pushdecl_top_level (d);
*************** tinfo_base_init (desc, target)
*** 837,844 ****
      comdat_linkage (name_decl);
      /* The new ABI specifies the external name of the string
         containing the type's name.  */
!     DECL_ASSEMBLER_NAME (name_decl) 
!       = mangle_typeinfo_string_for_type (target);
      DECL_INITIAL (name_decl) = name_string;
      cp_finish_decl (name_decl, name_string, NULL_TREE, 0);
      pushdecl_top_level (name_decl);
--- 837,844 ----
      comdat_linkage (name_decl);
      /* The new ABI specifies the external name of the string
         containing the type's name.  */
!     SET_DECL_ASSEMBLER_NAME (name_decl,
! 			     mangle_typeinfo_string_for_type (target));
      DECL_INITIAL (name_decl) = name_string;
      cp_finish_decl (name_decl, name_string, NULL_TREE, 0);
      pushdecl_top_level (name_decl);
*************** create_real_tinfo_var (target_type, name
*** 1243,1249 ****
        if (flag_weak || !typeinfo_in_lib_p (target_type))
  	comdat_linkage (decl);
      }
!   DECL_ASSEMBLER_NAME (decl) = name;
    DECL_INITIAL (decl) = init;
    cp_finish_decl (decl, init, NULL_TREE, 0);
    pushdecl_top_level (decl);
--- 1243,1249 ----
        if (flag_weak || !typeinfo_in_lib_p (target_type))
  	comdat_linkage (decl);
      }
!   SET_DECL_ASSEMBLER_NAME (decl, name);
    DECL_INITIAL (decl) = init;
    cp_finish_decl (decl, init, NULL_TREE, 0);
    pushdecl_top_level (decl);
Index: cp/search.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/search.c,v
retrieving revision 1.204
diff -c -p -r1.204 search.c
*** search.c	2001/02/18 19:08:00	1.204
--- search.c	2001/03/19 23:06:22
*************** lookup_field_1 (type, name)
*** 649,656 ****
  	;
        else if (DECL_NAME (field) == name)
  	{
! 	  if ((TREE_CODE(field) == VAR_DECL || TREE_CODE(field) == CONST_DECL)
! 	      && DECL_ASSEMBLER_NAME (field) != NULL)
  	    GNU_xref_ref(current_function_decl,
  			 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (field)));
  	  return field;
--- 649,656 ----
  	;
        else if (DECL_NAME (field) == name)
  	{
! 	  if (TREE_CODE(field) == VAR_DECL 
! 	      && (TREE_STATIC (field) || DECL_EXTERNAL (field)))
  	    GNU_xref_ref(current_function_decl,
  			 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (field)));
  	  return field;
Index: cp/semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v
retrieving revision 1.192
diff -c -p -r1.192 semantics.c
*** semantics.c	2001/03/15 02:50:55	1.192
--- semantics.c	2001/03/19 23:06:23
*************** finish_named_return_value (return_id, in
*** 1033,1042 ****
    if (return_id != NULL_TREE)
      {
        if (DECL_NAME (decl) == NULL_TREE)
! 	{
! 	  DECL_NAME (decl) = return_id;
! 	  DECL_ASSEMBLER_NAME (decl) = return_id;
! 	}
        else
  	{
  	  cp_error ("return identifier `%D' already in place", return_id);
--- 1033,1039 ----
    if (return_id != NULL_TREE)
      {
        if (DECL_NAME (decl) == NULL_TREE)
! 	DECL_NAME (decl) = return_id;
        else
  	{
  	  cp_error ("return identifier `%D' already in place", return_id);
Index: cp/tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/tree.c,v
retrieving revision 1.235
diff -c -p -r1.235 tree.c
*** tree.c	2001/03/15 02:50:55	1.235
--- tree.c	2001/03/19 23:06:25
*************** init_tree ()
*** 2319,2324 ****
--- 2319,2325 ----
    make_lang_type_fn = cp_make_lang_type;
    lang_unsave = cp_unsave;
    lang_statement_code_p = cp_statement_code_p;
+   lang_set_decl_assembler_name = mangle_decl;
    list_hash_table = htab_create (31, list_hash, list_hash_eq, NULL);
    ggc_add_root (&list_hash_table, 1, 
  		sizeof (list_hash_table),
Index: f/ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/f/ChangeLog,v
retrieving revision 1.326
diff -c -p -r1.326 ChangeLog
*** ChangeLog	2001/03/15 02:50:55	1.326
--- ChangeLog	2001/03/19 23:06:26
***************
*** 1,3 ****
--- 1,7 ----
+ Mon Mar 19 15:05:39 2001  Mark Mitchell  <mark@codesourcery.com>
+ 
+ 	* com.c (builtin_function): Use SET_DECL_ASSEMBLER_NAME.
+ 
  Wed Mar 14 09:29:27 2001  Mark Mitchell  <mark@codesourcery.com>
  
  	* com.c (ffecom_member_phase_2): Use COPY_DECL_RTL,
Index: f/com.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/f/com.c,v
retrieving revision 1.115
diff -c -p -r1.115 com.c
*** com.c	2001/03/15 02:50:56	1.115
--- com.c	2001/03/19 23:06:34
*************** builtin_function (const char *name, tree
*** 13497,13503 ****
    DECL_EXTERNAL (decl) = 1;
    TREE_PUBLIC (decl) = 1;
    if (library_name)
!     DECL_ASSEMBLER_NAME (decl) = get_identifier (library_name);
    make_decl_rtl (decl, NULL_PTR);
    pushdecl (decl);
    DECL_BUILT_IN_CLASS (decl) = class;
--- 13497,13503 ----
    DECL_EXTERNAL (decl) = 1;
    TREE_PUBLIC (decl) = 1;
    if (library_name)
!     SET_DECL_ASSEMBLER_NAME (decl, get_identifier (library_name));
    make_decl_rtl (decl, NULL_PTR);
    pushdecl (decl);
    DECL_BUILT_IN_CLASS (decl) = class;
Index: java/ChangeLog
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/ChangeLog,v
retrieving revision 1.681
diff -c -p -r1.681 ChangeLog
*** ChangeLog	2001/03/19 16:41:59	1.681
--- ChangeLog	2001/03/19 23:06:44
***************
*** 1,3 ****
--- 1,12 ----
+ 2001-03-19  Mark Mitchell  <mark@codesourcery.com>
+ 
+ 	* class.c (build_class_ref): Use SET_DECL_ASSEMBLER_NAME.
+ 	(layout_class): Likewise.
+ 	(layout_class_method): Likewise.
+ 	(emit_register_classes): Likewise.
+ 	* decl.c (builtin_function): Likewise.
+ 	(give_name_to_locals): Likewise.
+ 
  2001-03-19  Per Bothner  <per@bothner.com>
  
  	* jvspec.c (lang_specific_driver):  Check for .zip and .jar files.
Index: java/class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/class.c,v
retrieving revision 1.93
diff -c -p -r1.93 class.c
*** class.c	2001/03/19 16:14:14	1.93
--- class.c	2001/03/19 23:06:45
*************** build_class_ref (type)
*** 899,906 ****
  	      TREE_PUBLIC (decl) = 1;
  	      DECL_IGNORED_P (decl) = 1;
  	      DECL_ARTIFICIAL (decl) = 1;
! 	      DECL_ASSEMBLER_NAME (decl) = 
! 		java_mangle_class_field (&temporary_obstack, type);
  	      make_decl_rtl (decl, NULL);
  	      pushdecl_top_level (decl);
  	      if (is_compiled == 1)
--- 899,907 ----
  	      TREE_PUBLIC (decl) = 1;
  	      DECL_IGNORED_P (decl) = 1;
  	      DECL_ARTIFICIAL (decl) = 1;
! 	      SET_DECL_ASSEMBLER_NAME (decl, 
! 				       java_mangle_class_field
! 				       (&temporary_obstack, type));
  	      make_decl_rtl (decl, NULL);
  	      pushdecl_top_level (decl);
  	      if (is_compiled == 1)
*************** layout_class (this_class)
*** 1701,1708 ****
        if (FIELD_STATIC (field))
  	{
  	  /* Set DECL_ASSEMBLER_NAME to something suitably mangled. */
! 	  DECL_ASSEMBLER_NAME (field) = 
! 	    java_mangle_decl (&temporary_obstack, field);
  	}
      }
  
--- 1702,1710 ----
        if (FIELD_STATIC (field))
  	{
  	  /* Set DECL_ASSEMBLER_NAME to something suitably mangled. */
! 	  SET_DECL_ASSEMBLER_NAME (field,
! 				   java_mangle_decl
! 				   (&temporary_obstack, field));
  	}
      }
  
*************** layout_class_method (this_class, super_c
*** 1797,1804 ****
    TREE_PUBLIC (method_decl) = 1;
  
    /* This is a good occasion to mangle the method's name */
!   DECL_ASSEMBLER_NAME (method_decl) = 
!     java_mangle_decl (&temporary_obstack, method_decl);
    /* We don't generate a RTL for the method if it's abstract, or if
       it's an interface method that isn't clinit. */
    if (! METHOD_ABSTRACT (method_decl) 
--- 1799,1807 ----
    TREE_PUBLIC (method_decl) = 1;
  
    /* This is a good occasion to mangle the method's name */
!   SET_DECL_ASSEMBLER_NAME (method_decl,
! 			   java_mangle_decl (&temporary_obstack, 
! 					     method_decl));
    /* We don't generate a RTL for the method if it's abstract, or if
       it's an interface method that isn't clinit. */
    if (! METHOD_ABSTRACT (method_decl) 
*************** emit_register_classes ()
*** 1878,1884 ****
    tree t;
  
    init_decl = build_decl (FUNCTION_DECL, init_name, init_type);
!   DECL_ASSEMBLER_NAME (init_decl) = init_name;
    TREE_STATIC (init_decl) = 1;
    current_function_decl = init_decl;
    DECL_RESULT (init_decl) = build_decl(RESULT_DECL, NULL_TREE, void_type_node);
--- 1881,1887 ----
    tree t;
  
    init_decl = build_decl (FUNCTION_DECL, init_name, init_type);
!   SET_DECL_ASSEMBLER_NAME (init_decl, init_name);
    TREE_STATIC (init_decl) = 1;
    current_function_decl = init_decl;
    DECL_RESULT (init_decl) = build_decl(RESULT_DECL, NULL_TREE, void_type_node);
Index: java/decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/decl.c,v
retrieving revision 1.94
diff -c -p -r1.94 decl.c
*** decl.c	2001/03/17 20:48:35	1.94
--- decl.c	2001/03/19 23:06:46
*************** builtin_function (name, type, function_c
*** 377,383 ****
    DECL_EXTERNAL (decl) = 1;
    TREE_PUBLIC (decl) = 1;
    if (library_name)
!     DECL_ASSEMBLER_NAME (decl) = get_identifier (library_name);
    make_decl_rtl (decl, NULL_PTR);
    pushdecl (decl);
    DECL_BUILT_IN_CLASS (decl) = class;
--- 377,383 ----
    DECL_EXTERNAL (decl) = 1;
    TREE_PUBLIC (decl) = 1;
    if (library_name)
!     SET_DECL_ASSEMBLER_NAME (decl, get_identifier (library_name));
    make_decl_rtl (decl, NULL_PTR);
    pushdecl (decl);
    DECL_BUILT_IN_CLASS (decl) = class;
*************** give_name_to_locals (jcf)
*** 1569,1575 ****
  	{
  	  tree decl = TREE_VEC_ELT (decl_map, slot);
  	  DECL_NAME (decl) = name;
! 	  DECL_ASSEMBLER_NAME (decl) = name;
  	  if (TREE_CODE (decl) != PARM_DECL || TREE_TYPE (decl) != type)
  	    warning ("bad type in parameter debug info");
  	}
--- 1569,1575 ----
  	{
  	  tree decl = TREE_VEC_ELT (decl_map, slot);
  	  DECL_NAME (decl) = name;
! 	  SET_DECL_ASSEMBLER_NAME (decl, name);
  	  if (TREE_CODE (decl) != PARM_DECL || TREE_TYPE (decl) != type)
  	    warning ("bad type in parameter debug info");
  	}
*************** give_name_to_locals (jcf)
*** 1636,1642 ****
  	      sprintf (buffer, "ARG_%d", arg_i);
  	      DECL_NAME (parm) = get_identifier (buffer);
  	    }
! 	  DECL_ASSEMBLER_NAME (parm) = DECL_NAME (parm);
  	}
      }
  }
--- 1636,1642 ----
  	      sprintf (buffer, "ARG_%d", arg_i);
  	      DECL_NAME (parm) = get_identifier (buffer);
  	    }
! 	  SET_DECL_ASSEMBLER_NAME (parm, DECL_NAME (parm));
  	}
      }
  }
Index: testsuite/g++.old-deja/g++.other/mangle1.C
===================================================================
RCS file: mangle1.C
diff -N mangle1.C
*** /sourceware/cvs-tmp/cvsc9FlGc	Mon Mar 19 15:06:54 2001
--- /dev/null	Tue May  5 13:32:27 1998
***************
*** 1,57 ****
- // Test for proper mangling by setting up name clashes.
- 
- #if (!defined (__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100)
- #define NAME(OLD, NEW) OLD
- #else
- #define NAME(OLD, NEW) NEW
- #endif /* (!defined (__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100) */
- 
- class A { };
- typedef A A2;
- typedef int I;
- typedef void V;
- typedef I I2;
- 
- void f (const A2&, int, const A2&, const A&) { } // ERROR - name clash
- int NAME (f__FRC1AiT0T0, _Z1fRK1AiS1_S1_) = 0; // ERROR - name clash
- 
- void f (int, long, int, I) { } // ERROR - name clash
- int NAME (f__Filii, _Z1filii) = 0; // ERROR - name clash
- 
- void f (I, float, I, I2) { } // ERROR - name clash
- int NAME (f__Fifii, _Z1fifii) = 0; // ERROR - name clash
- 
- void f (void*, float, void*, V*) { } // ERROR - name clash
- int NAME (f__FPvfT0T0, _Z1fPvfS_S_) = 0; // ERROR - name clash
- 
- void f (wchar_t) { } // ERROR - name clash
- int NAME (f__Fw, _Z1fw) = 0; // ERROR - name clash
- 
- void f(int, A, A2, A) { } // ERROR - name clash
- int NAME (f__FiG1AN21, _Z1fi1AS_S_) = 0; // ERROR - name clash
- 
- void f(const A2&, const A2&, const A2&, const A2&,
-        int&) { } // ERROR - name clash
- int NAME (f__FRC1AN30Ri, _Z1fRK1AS1_S1_S1_Ri) = 0; // ERROR - name clash
- 
- void f(const A2&, int, const A2&, const A2&, const A2&,
-        int&) { } // ERROR - name clash
- int NAME (f__FRC1AiT0N20Ri, _Z1fRK1AiS1_S1_S1_Ri) = 0; // ERROR - name clash
- 
- void f(const A2&, int, const A2&, const A2&, const A2&, int&, int&,
-        int&) { } // ERROR - name clash
- int NAME (f__FRC1AiT0N20RiN25, _Z1fRK1AiS1_S1_S1_RiS2_S2_) = 0; // ERROR - name clash
- 
- void f(const A2&, int, const A2&, const A2&, const A2&, int, int,
-        int) { } // ERROR - name clash
- int NAME (f__FRC1AiT0N20iii, _Z1fRK1AiS1_S1_S1_iii) = 0; // ERROR - name clash
- 
- void f(bool, bool) {} // ERROR - name clash
- int NAME (f__FbT0, _Z1fbb) = 0; // ERROR - name clash
- 
- int
- main ()
- {
-   return 0;
- }
- 
--- 0 ----
Index: testsuite/g++.old-deja/g++.other/mangle2.C
===================================================================
RCS file: mangle2.C
diff -N mangle2.C
*** /sourceware/cvs-tmp/cvsNTwgfe	Mon Mar 19 15:06:54 2001
--- /dev/null	Tue May  5 13:32:27 1998
***************
*** 1,24 ****
- // Test for overloaded operators in "C" linkage
- // Build don't link:
- 
- extern "C" {
- typedef struct b
- {
-   int a;
- } c;
- 
- extern const c z;
- 
- inline bool operator!=(const c& x, const c& y)
- {
-   return x.a != y.a;
- }
- };
- 
- void foo();
- 
- void bar(c x)
- {
-   if (x != z)
-     foo();
- }
--- 0 ----
Index: testsuite/g++.old-deja/g++.other/static8.C
===================================================================
RCS file: static8.C
diff -N static8.C
*** /sourceware/cvs-tmp/cvsIWJy5g	Mon Mar 19 15:06:54 2001
--- /dev/null	Tue May  5 13:32:27 1998
***************
*** 1,12 ****
- // Build don't link:
- // Origin: Mark Mitchell <mark@codesourcery.com>
- 
- #if (!defined (__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100)
- #define NAME(OLD, NEW) OLD
- #else
- #define NAME(OLD, NEW) NEW
- #endif /* (!defined (__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100) */
- 
- static unsigned int strlen (const char*) {return 0;} // ERROR - previous declaration
- 
- int NAME (strlen__FPCc, _Z6strlenPKc) = 0; // ERROR - duplicate declaration
--- 0 ----


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