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.

	* 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.

	* com.c (builtin_function): Use SET_DECL_ASSEMBLER_NAME.

	* 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.

From-SVN: r40642
This commit is contained in:
Mark Mitchell 2001-03-19 23:50:04 +00:00 committed by Mark Mitchell
parent b90f4049d3
commit 92643fea93
31 changed files with 300 additions and 346 deletions

View File

@ -1,5 +1,26 @@
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.
* cse.c (find_comparison_args): Update documentation. Fix
mishandling of COMPARE operations.

View File

@ -1902,7 +1902,7 @@ duplicate_decls (newdecl, olddecl, different_binding_level)
/* Copy the assembler name.
Currently, it can only be defined in the prototype. */
DECL_ASSEMBLER_NAME (newdecl) = DECL_ASSEMBLER_NAME (olddecl);
COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl);
if (TREE_CODE (newdecl) == FUNCTION_DECL)
{
@ -3186,7 +3186,7 @@ builtin_function (name, type, function_code, class, library_name)
if (flag_traditional && name[0] != '_')
DECL_BUILT_IN_NONANSI (decl) = 1;
if (library_name)
DECL_ASSEMBLER_NAME (decl) = get_identifier (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;
@ -3599,7 +3599,7 @@ finish_decl (decl, init, asmspec_tree)
{
DECL_BUILT_IN_CLASS (decl) = NOT_BUILT_IN;
SET_DECL_RTL (decl, NULL_RTX);
DECL_ASSEMBLER_NAME (decl) = get_identifier (asmspec);
SET_DECL_ASSEMBLER_NAME (decl, get_identifier (asmspec));
}
/* Output the assembler code and/or RTL code for variables and functions,
@ -3627,7 +3627,7 @@ finish_decl (decl, init, asmspec_tree)
{
if (asmspec)
{
DECL_ASSEMBLER_NAME (decl) = get_identifier (asmspec);
SET_DECL_ASSEMBLER_NAME (decl, get_identifier (asmspec));
DECL_C_HARD_REGISTER (decl) = 1;
}
add_decl_stmt (decl);

View File

@ -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.

View File

@ -760,6 +760,7 @@ get_vtable_decl (type, complete)
}
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);
@ -1310,17 +1311,9 @@ add_method (type, method, error_p)
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))
if (!decls_match (fn, method))
continue;
/* There has already been a declaration of this method
@ -3693,7 +3686,7 @@ build_vtbl_or_vbase_field (name, assembler_name, type, class_type, fcontext,
/* Build the FIELD_DECL. */
field = build_decl (FIELD_DECL, name, type);
DECL_ASSEMBLER_NAME (field) = assembler_name;
SET_DECL_ASSEMBLER_NAME (field, assembler_name);
DECL_VIRTUAL_P (field) = 1;
DECL_ARTIFICIAL (field) = 1;
DECL_FIELD_CONTEXT (field) = class_type;
@ -4120,7 +4113,8 @@ check_methods (t)
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)))
if (DECL_ASSEMBLER_NAME_SET_P (x)
&& IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (x)))
continue;
check_for_override (x, t);
@ -4184,7 +4178,6 @@ build_clone (fn, name)
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;
@ -4261,9 +4254,6 @@ build_clone (fn, name)
}
}
/* 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);
@ -6823,6 +6813,7 @@ build_vtt (t)
/* 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);
}

View File

@ -1904,9 +1904,10 @@ struct lang_decl
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)))) \
#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
@ -4531,7 +4532,7 @@ extern void GNU_xref_member PARAMS ((tree, tree));
/* in mangle.c */
extern void init_mangle PARAMS ((void));
extern tree mangle_decl PARAMS ((tree));
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));

View File

@ -2827,7 +2827,6 @@ pushtag (name, type, globalize)
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
@ -2838,9 +2837,6 @@ pushtag (name, type, globalize)
&& 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)
{
@ -3161,7 +3157,7 @@ duplicate_decls (newdecl, olddecl)
will be banished. */
DECL_LANGUAGE (olddecl) = DECL_LANGUAGE (newdecl);
SET_DECL_RTL (olddecl, DECL_RTL (newdecl));
DECL_ASSEMBLER_NAME (olddecl) = DECL_ASSEMBLER_NAME (newdecl);
COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl);
SET_IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (newdecl),
newdecl);
}
@ -3633,7 +3629,7 @@ duplicate_decls (newdecl, olddecl)
if (! types_match)
{
DECL_LANGUAGE (olddecl) = DECL_LANGUAGE (newdecl);
DECL_ASSEMBLER_NAME (olddecl) = DECL_ASSEMBLER_NAME (newdecl);
COPY_DECL_ASSEMBLER_NAME (newdecl, olddecl);
SET_DECL_RTL (olddecl, DECL_RTL (newdecl));
}
if (! types_match || new_defines_function)
@ -3683,7 +3679,7 @@ duplicate_decls (newdecl, olddecl)
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);
COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl);
if (TREE_CODE (newdecl) == FUNCTION_DECL)
{
@ -3846,8 +3842,7 @@ pushdecl (x)
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))
if (decls_match (OVL_CURRENT (match), x))
break;
}
else
@ -4028,32 +4023,15 @@ pushdecl (x)
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);
}
/* 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)
@ -6670,7 +6648,8 @@ builtin_function (name, type, code, class, libname)
we cannot change DECL_ASSEMBLER_NAME until we have installed this
function in the namespace. */
if (libname)
DECL_ASSEMBLER_NAME (decl) = get_identifier (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. */
@ -6695,6 +6674,7 @@ build_library_fn_1 (name, operator_code, type)
DECL_ARTIFICIAL (fn) = 1;
TREE_NOTHROW (fn) = 1;
SET_OVERLOADED_OPERATOR_CODE (fn, operator_code);
DECL_LANGUAGE (fn) = lang_c;
return fn;
}
@ -6721,6 +6701,7 @@ build_cp_library_fn (name, operator_code, type)
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;
}
@ -7534,9 +7515,7 @@ maybe_commonize_var (decl)
/* 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
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);
@ -7721,7 +7700,7 @@ make_rtl_for_nonlocal_decl (decl, init, asmspec)
/* Set the DECL_ASSEMBLER_NAME for the variable. */
if (asmspec)
DECL_ASSEMBLER_NAME (decl) = get_identifier (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))
@ -7751,12 +7730,15 @@ make_rtl_for_nonlocal_decl (decl, init, asmspec)
defer_p = 1;
}
/* If we're deferring the variable, just make RTL. Do not actually
emit the variable. */
if (defer_p)
/* 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
else if (!defer_p)
rest_of_decl_compilation (decl, asmspec, toplev, at_eof);
}
@ -8034,7 +8016,7 @@ cp_finish_decl (decl, init, asmspec_tree, flags)
/* 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);
SET_DECL_ASSEMBLER_NAME (decl, get_identifier (asmspec));
make_decl_rtl (decl, asmspec);
}
@ -8858,12 +8840,6 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
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. */
@ -8968,10 +8944,6 @@ grokvardecl (type, declarator, specbits_in, initialized, constp, in_namespace)
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
{
@ -8996,7 +8968,10 @@ grokvardecl (type, declarator, specbits_in, initialized, constp, in_namespace)
context = DECL_CONTEXT (decl);
if (declarator && context && current_lang_name != lang_name_c)
DECL_ASSEMBLER_NAME (decl) = mangle_decl (decl);
/* 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)
@ -11005,8 +10980,6 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
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. */
}
@ -13537,19 +13510,10 @@ start_function (declspecs, declarator, attrs, flags)
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)
@ -14488,5 +14452,5 @@ cp_missing_noreturn_ok_p (decl)
tree decl;
{
/* A missing noreturn is ok for the `main' function. */
return MAIN_NAME_P (DECL_ASSEMBLER_NAME (decl));
return DECL_MAIN_P (decl);
}

View File

@ -1061,17 +1061,17 @@ grokclassfn (ctype, function, flags, quals)
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;
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). */
@ -1436,22 +1436,6 @@ check_classfn (ctype, function)
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
@ -1525,11 +1509,6 @@ finish_static_data_member_decl (decl, init, asmspec_tree, flags)
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;
@ -1538,11 +1517,9 @@ finish_static_data_member_decl (decl, init, asmspec_tree, flags)
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 (!asmspec_tree && current_class_type)
DECL_INITIAL (decl) = error_mark_node;
if (! processing_template_decl)
{
if (!pending_statics)
@ -1672,12 +1649,6 @@ grokfield (declarator, declspecs, init, asmspec_tree, attrlist)
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);
@ -1776,7 +1747,7 @@ grokfield (declarator, declspecs, init, asmspec_tree, attrlist)
/* 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);
SET_DECL_ASSEMBLER_NAME (value, get_identifier (asmspec));
}
cp_finish_decl (value, init, asmspec_tree, flags);

View File

@ -883,19 +883,15 @@ ident_fndecl (t)
# 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')
if (DECL_GLOBAL_CTOR_P (t))
p = "initializers";
else if (name [sizeof (GLOBAL_THING) - 1] == 'D')
else if (DECL_GLOBAL_DTOR_P (t))
p = "destructors";
else
my_friendly_abort (352);
@ -1041,8 +1037,8 @@ dump_decl (t, flags)
/* Fall through. */
case FUNCTION_DECL:
if (GLOBAL_IORD_P (DECL_ASSEMBLER_NAME (t)))
dump_global_iord (DECL_ASSEMBLER_NAME (t));
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

View File

@ -1121,6 +1121,7 @@ nothrow_libfn_p (fn)
if (TREE_PUBLIC (fn)
&& DECL_EXTERNAL (fn)
&& DECL_NAMESPACE_SCOPE_P (fn)
&& DECL_EXTERN_C_P (fn))
/* OK */;
else

View File

@ -2219,7 +2219,8 @@ build_java_class_ref (type)
for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
if (DECL_NAME (field) == CL_suffix)
{
name = mangle_decl (field);
mangle_decl (field);
name = DECL_ASSEMBLER_NAME (field);
break;
}
if (!field)

View File

@ -2069,6 +2069,17 @@ mangle_decl_string (decl)
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);
@ -2089,11 +2100,13 @@ mangle_decl_string (decl)
/* Create an identifier for the external mangled name of DECL. */
tree
void
mangle_decl (decl)
tree decl;
{
return get_identifier (mangle_decl_string (decl));
tree id = get_identifier (mangle_decl_string (decl));
SET_DECL_ASSEMBLER_NAME (decl, id);
}
/* Generate the mangled representation of TYPE. */

View File

@ -90,7 +90,7 @@ set_mangled_name_for_decl (decl)
/* There's no need to mangle the name of a template function. */
return;
DECL_ASSEMBLER_NAME (decl) = mangle_decl (decl);
mangle_decl (decl);
}
@ -346,6 +346,7 @@ make_thunk (function, delta, vcall_index, generate_with_vtable_p)
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);
@ -373,6 +374,7 @@ make_thunk (function, delta, vcall_index, generate_with_vtable_p)
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;
}

View File

@ -144,7 +144,6 @@ static tree tsubst_template_parms PARAMS ((tree, tree, int));
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));
@ -1678,24 +1677,6 @@ check_explicit_specialization (declarator, decl, template_count, flags)
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
@ -4220,11 +4201,8 @@ lookup_template_class (d1, arglist, in_decl, context, entering_scope, complain)
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.
@ -4606,18 +4584,14 @@ tsubst_friend_function (decl, args)
= 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. */
/* 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_mangled_name_for_decl (new_friend);
SET_DECL_RTL (new_friend, NULL_RTX);
SET_DECL_ASSEMBLER_NAME (new_friend, NULL_TREE);
}
if (DECL_NAMESPACE_SCOPE_P (new_friend))
@ -5805,6 +5779,9 @@ tsubst_decl (t, args, type)
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)
@ -5839,9 +5816,9 @@ tsubst_decl (t, args, type)
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. */
/* 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)
@ -5849,37 +5826,6 @@ tsubst_decl (t, args, type)
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:
@ -6032,6 +5978,9 @@ tsubst_decl (t, args, type)
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. */
@ -9762,7 +9711,7 @@ regenerate_decl_from_template (decl, tmpl)
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_ASSEMBLER_NAME (decl, new_decl);
COPY_DECL_RTL (decl, new_decl);
DECL_USE_TEMPLATE (new_decl) = DECL_USE_TEMPLATE (decl);
@ -10292,21 +10241,6 @@ get_mostly_instantiated_function_type (decl, contextp, tparmsp)
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
the last one involved in diagnostics. */
int

View File

@ -354,7 +354,7 @@ get_tinfo_decl (type)
TREE_PUBLIC (d) = 1;
if (flag_weak || !typeinfo_in_lib_p (d))
comdat_linkage (d);
DECL_ASSEMBLER_NAME (d) = DECL_NAME (d);
SET_DECL_ASSEMBLER_NAME (d, name);
cp_finish_decl (d, NULL_TREE, NULL_TREE, 0);
pushdecl_top_level (d);
@ -837,8 +837,8 @@ tinfo_base_init (desc, target)
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);
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);
@ -1243,7 +1243,7 @@ create_real_tinfo_var (target_type, name, type, init, non_public)
if (flag_weak || !typeinfo_in_lib_p (target_type))
comdat_linkage (decl);
}
DECL_ASSEMBLER_NAME (decl) = name;
SET_DECL_ASSEMBLER_NAME (decl, name);
DECL_INITIAL (decl) = init;
cp_finish_decl (decl, init, NULL_TREE, 0);
pushdecl_top_level (decl);

View File

@ -649,8 +649,8 @@ lookup_field_1 (type, name)
;
else if (DECL_NAME (field) == name)
{
if ((TREE_CODE(field) == VAR_DECL || TREE_CODE(field) == CONST_DECL)
&& DECL_ASSEMBLER_NAME (field) != NULL)
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;

View File

@ -1033,10 +1033,7 @@ finish_named_return_value (return_id, init)
if (return_id != NULL_TREE)
{
if (DECL_NAME (decl) == NULL_TREE)
{
DECL_NAME (decl) = return_id;
DECL_ASSEMBLER_NAME (decl) = return_id;
}
DECL_NAME (decl) = return_id;
else
{
cp_error ("return identifier `%D' already in place", return_id);

View File

@ -2319,6 +2319,7 @@ init_tree ()
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),

View File

@ -833,10 +833,18 @@ dbxout_type_methods (type)
{
/* This is the "mangled" name of the method.
It encodes the argument types. */
const char *debug_name =
IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl));
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;
last = fndecl;

View File

@ -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,

View File

@ -13497,7 +13497,7 @@ builtin_function (const char *name, tree type, int function_code,
DECL_EXTERNAL (decl) = 1;
TREE_PUBLIC (decl) = 1;
if (library_name)
DECL_ASSEMBLER_NAME (decl) = get_identifier (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;

View File

@ -373,13 +373,14 @@ ggc_mark_trees ()
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));
if (DECL_ASSEMBLER_NAME_SET_P (t))
ggc_mark_tree (DECL_ASSEMBLER_NAME (t));
lang_mark_tree (t);
break;

View File

@ -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>
* jcf-parse.c (load_inner_classes): Check CLASS_LOADED_P

View File

@ -899,8 +899,9 @@ build_class_ref (type)
TREE_PUBLIC (decl) = 1;
DECL_IGNORED_P (decl) = 1;
DECL_ARTIFICIAL (decl) = 1;
DECL_ASSEMBLER_NAME (decl) =
java_mangle_class_field (&temporary_obstack, type);
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)
@ -1701,8 +1702,9 @@ layout_class (this_class)
if (FIELD_STATIC (field))
{
/* Set DECL_ASSEMBLER_NAME to something suitably mangled. */
DECL_ASSEMBLER_NAME (field) =
java_mangle_decl (&temporary_obstack, field);
SET_DECL_ASSEMBLER_NAME (field,
java_mangle_decl
(&temporary_obstack, field));
}
}
@ -1797,8 +1799,9 @@ layout_class_method (this_class, super_class, method_decl, dtable_count)
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);
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)
@ -1878,7 +1881,7 @@ emit_register_classes ()
tree t;
init_decl = build_decl (FUNCTION_DECL, init_name, init_type);
DECL_ASSEMBLER_NAME (init_decl) = init_name;
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);

View File

@ -377,7 +377,7 @@ builtin_function (name, type, function_code, class, library_name)
DECL_EXTERNAL (decl) = 1;
TREE_PUBLIC (decl) = 1;
if (library_name)
DECL_ASSEMBLER_NAME (decl) = get_identifier (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;
@ -1569,7 +1569,7 @@ give_name_to_locals (jcf)
{
tree decl = TREE_VEC_ELT (decl_map, slot);
DECL_NAME (decl) = name;
DECL_ASSEMBLER_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");
}
@ -1636,7 +1636,7 @@ give_name_to_locals (jcf)
sprintf (buffer, "ARG_%d", arg_i);
DECL_NAME (parm) = get_identifier (buffer);
}
DECL_ASSEMBLER_NAME (parm) = DECL_NAME (parm);
SET_DECL_ASSEMBLER_NAME (parm, DECL_NAME (parm));
}
}
}

View File

@ -1108,7 +1108,6 @@ output_func_start_profiler ()
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);

View File

@ -1,57 +0,0 @@
// 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;
}

View File

@ -1,24 +0,0 @@
// 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();
}

View File

@ -1,12 +0,0 @@
// 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

View File

@ -182,10 +182,42 @@ void (*lang_unsave_expr_now) PARAMS ((tree));
/* 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
@ -199,6 +231,9 @@ init_obstacks ()
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
@ -2557,7 +2592,6 @@ build_decl (code, name, type)
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)

View File

@ -1255,11 +1255,37 @@ struct tree_type
/* 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)
/* 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)
@ -2497,6 +2523,7 @@ extern tree get_set_constructor_bits PARAMS ((tree, char *, int));
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 */
@ -2666,6 +2693,13 @@ extern int objects_must_conflict_p PARAMS ((tree, tree));
/* 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;
/* In tree.c */

View File

@ -738,7 +738,7 @@ make_decl_rtl (decl, asmspec)
if (name != new_name)
{
DECL_ASSEMBLER_NAME (decl) = get_identifier (new_name);
SET_DECL_ASSEMBLER_NAME (decl, get_identifier (new_name));
name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
}