aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog62
-rw-r--r--gcc/cp/class.c23
-rw-r--r--gcc/cp/cp-tree.h9
-rw-r--r--gcc/cp/decl.c100
-rw-r--r--gcc/cp/decl2.c43
-rw-r--r--gcc/cp/error.c12
-rw-r--r--gcc/cp/except.c1
-rw-r--r--gcc/cp/init.c3
-rw-r--r--gcc/cp/mangle.c17
-rw-r--r--gcc/cp/method.c4
-rw-r--r--gcc/cp/pt.c96
-rw-r--r--gcc/cp/rtti.c8
-rw-r--r--gcc/cp/search.c4
-rw-r--r--gcc/cp/semantics.c5
-rw-r--r--gcc/cp/tree.c1
15 files changed, 161 insertions, 227 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 429a570..15ff7b5 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 0828852..cf3b666 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -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);
}
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 19bb167..eb4bc7c 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -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));
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 8a5857a..f540cc5 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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);
}
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index b60b669..1487a5b 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -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);
diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 0ec7405..0ab06fa 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -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
diff --git a/gcc/cp/except.c b/gcc/cp/except.c
index 595d3d6..fd99a93 100644
--- a/gcc/cp/except.c
+++ b/gcc/cp/except.c
@@ -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
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index 61e2d4f..f680ee0 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -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)
diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index 6736d1e..4d63f76 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -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. */
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index dad5f7d..5f917d5 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -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;
}
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 3fa1cde..1644f73 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -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
diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c
index 315f23d..49fc1ba 100644
--- a/gcc/cp/rtti.c
+++ b/gcc/cp/rtti.c
@@ -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);
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index 6b13469..95ede8b 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -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;
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 97f0103..dec0e8d 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -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);
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 6a3de30..93e12be 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -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),