Make-lang.in (CXX_SRCS): Add mangle.c.

* Make-lang.in (CXX_SRCS): Add mangle.c.
	* Makefile.in (CXX_OBJS): Add mangle.o.
	(mangle.o): New rule.

Co-Authored-By: Mark Mitchell <mark@codesourcery.com>

From-SVN: r34394
This commit is contained in:
Alex Samuel 2000-06-04 21:12:27 +00:00 committed by Mark Mitchell
parent 031926e2a3
commit 1f6e1acc0f
18 changed files with 2616 additions and 337 deletions

View File

@ -1,66 +1,78 @@
2000-06-03 Mark Mitchell <mark@codesourcery.com>
2000-06-03 Alex Samuel <samuel@codesourcery.com>
Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (TMPL_ARGS_LEVEL): Clarify comment.
(INNERMOST_TEMPLATE_ARGS): New macro.
(innermost_args): Remove.
(get_innermost_template_args): New function.
* decl2.c (arg_assoc_class): Use INNERMOST_TEMPLATE_ARGS.
* error.c (dump_function_decl): Be caution when using
most_general_template.
* method.c (build_template_parm_names): Use
INNERMOST_TEMPLATE_ARGS.
* pt.c (add_to_template_args): Tidy comment
(get_innermost_template_args): New function.
(check_explicit_specialization): Clear DECL_INITIAL for a new
specialization.
(process_partial_specialization): Use INNERMOST_TEMPLATE_ARGS.
Tidy.
(push_template_decl): Always register specializations of the most
general template.
(convert_template_argument): Use INNERMOST_TEMPLATE_ARGS.
(coerce_template_parms): Likewise.
(lookup_template_class): Likewise.
(innermost_args): Remove.
(tsubst_decl): Use INNERMOST_TEMPLATE_ARGS.
(tsubst_decl): Handle tricky specializations. Use
get_innermost_template_args.
(instantiate_template): Simplify handling of partial
instantiations.
(get_class_bindings): Use INNERMOST_TEMPLATE_ARGS.
(most_general_template): Reimplement, in a more straightforward
manner.
(regenerate_decl_from_template): Tweak formatting. Use
TMPL_ARGS_DEPTH for clarity.
(set_mangled_name_for_template_decl): Use INNERMOST_ARGS.
* Make-lang.in (CXX_SRCS): Add mangle.c.
* Makefile.in (CXX_OBJS): Add mangle.o.
(mangle.o): New rule.
* class.c (local_classes): New variable.
* class.c (get_vtable_name): Use mangle_vtable_for_type for new ABI.
(get_vtt_name): Use mangle_vtt_name for new ABI.
(init_class_processing): Initialize local_classes.
(build_ctor_vtbl_group): Use mangle_ctor_vtbl_for_type for new ABI.
* cp-tree.h (cp_tree_index): Add CPTI_STD_IDENTIFIER.
(std_identifier): New macro.
(DECL_VOLATILE_MEMFUNC_P): New macro.
(DECL_NAMESPACE_STD_P): Likewise.
(local_classes): Declare.
(get_mostly_instantiated_function_type): Declare.
(init_mangle): Declare.
(mangle_decl): Likewise.
(mangle_type_string): Likewise.
(mangle_type): Likewise.
(mangle_typeinfo_for_type): Likewise.
(mangle_typeinfo_string_for_type): Likewise.
(mangle_vtbl_for_type): Likewise.
(mangle_vtt_for_type): Likewise.
(mangle_ctor_vtbl_for_type): Likewise.
(mangle_thunk): Likewise.
(mangle_conv_op_name_for_type): Likewise.
(mangle_guard_variable): Likewise.
* decl.c (pushtag): Keep track of local classes.
(initialize_predefined_identifiers): Initialize std_identifier.
(init_decl_processing): Use std_identifier.
(start_decl): Don't treat instantiations as specializations.
(grokdeclarator): Likewise.
(grokvardecl): Call mangle_decl for new ABI. Only set mangled
name for fully-instantiated templates.
* decl2.c (grokclassfn): Use set_mangled_name_for_decl for
destructors with the new ABI.
(finish_static_data_member_decl): Use mangle_decl under the new ABI.
(grokfield): Use mangle_type for new ABI.
(grokoptypename): Use mangle_conv_op_for_type for new ABI.
(get_sentry): Use mangle_guard_variable for new ABI.
(start_static_initialization_or_destruction): Likewise.
* expr.c (extract_aggr_init): Remove.
(extract_scalar_init): Likewise.
(extract_init): Remove #if 0'd code.
* mangle.c: New function.
* method.c (build_mangled_name): Assert not flag_new_abi.
(build_static_name): Likewise.
(build_decl_overload_real): Likewise.
(build_typename_overload): Likewise.
(build_overload_with_type): Likewise.
(build_overload_name): Likewise.
(get_ctor_vtbl_name): Likewise.
(start_squangling): Likewise.
(get_id_2): Likewise.
(set_mangled_name_for_decl): Call mangle_decl for new ABI.
(init_method): Call init_mangle for new ABI.
(make_thunk): Call mangle_thunk for new ABI.
* operators.def: Correct new ABI manglings for the `%' operator.
Add `::' operator.
* pt.c (build_template_decl): Copy DECL_OVERLOADED_OPERATOR_P and
DECL_ASSIGNMENT_OPERATOR_P to the TEMPLATE_DECL.
(lookup_template_class): Call mangle_decl for new ABI.
(get_mostly_instantiated_function_type): New function.
(set_mangled_name_for_template_decl): Use it.
(tsubst_decl): Use set_mangled_name_for_decl for destructors with
the new ABI. Use mangle_conv_op_name_for_type for instantiated
conversion op names.
* rtti.c (tinfo_name): Call mangle_type_string for new ABI.
(get_tinfo_decl): Call mangle_typeinfo_for_type for new ABI.
(tinfo_base_init): Likewise. Mangle typeinfo string name with
mangle_typeinfo_string_for_type.
* dump.c (dequeue_and_dump): Dump information about thunks.
2000-06-02 Jason Merrill <jason@casey.soma.redhat.com>
* exception.cc (__cp_pop_exception): If we aren't popping or
rethrowing, push down past any uncaught exceptions.
(__uncatch_exception): Rethrow the currently handled exception.
Move it to the top of the exception stack.
Fri Jun 2 19:38:57 2000 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
* cp-tree.h: Use struct tree_common instead of a char array.
* decl.c (grokdeclarator): Set DECL_NONADDRESSABLE_P instead
of TREE_ADDRESSABLE.
2000-06-02 Richard Henderson <rth@cygnus.com>
* decl.c (init_decl_processing): Don't set lang_get_alias_set.
2000-06-02 Jason Merrill <jason@casey.soma.redhat.com>
* decl.c (store_return_init): Call put_var_into_stack.
2000-06-01 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (lang_decl_flags): Add anticipated_p.
(DECL_ANTICIPATED): Use it.
2000-06-01 Richard Henderson <rth@cygnus.com>
* decl.c (init_decl_processing): Set lang_get_alias_set first thing.

View File

@ -115,11 +115,11 @@ CXX_SRCS = $(srcdir)/cp/call.c $(srcdir)/cp/class.c $(srcdir)/cp/cp-tree.def \
$(srcdir)/cp/errfn.c $(srcdir)/cp/error.c $(srcdir)/cp/except.c \
$(srcdir)/cp/expr.c $(srcdir)/cp/friend.c $(srcdir)/cp/init.c \
$(srcdir)/cp/input.c $(srcdir)/cp/lex.c $(srcdir)/cp/lex.h \
$(srcdir)/cp/method.c $(srcdir)/cp/optimize.c $(srcdir)/cp/parse.y \
$(srcdir)/cp/pt.c $(srcdir)/cp/ptree.c $(srcdir)/cp/repo.c \
$(srcdir)/cp/rtti.c $(srcdir)/cp/search.c $(srcdir)/cp/semantics.c \
$(srcdir)/cp/spew.c $(srcdir)/cp/tree.c $(srcdir)/cp/typeck.c \
$(srcdir)/cp/typeck2.c $(srcdir)/cp/xref.c
$(srcdir)/cp/mangle.c $(srcdir)/cp/method.c $(srcdir)/cp/optimize.c \
$(srcdir)/cp/parse.y $(srcdir)/cp/pt.c $(srcdir)/cp/ptree.c \
$(srcdir)/cp/repo.c $(srcdir)/cp/rtti.c $(srcdir)/cp/search.c \
$(srcdir)/cp/semantics.c $(srcdir)/cp/spew.c $(srcdir)/cp/tree.c \
$(srcdir)/cp/typeck.c $(srcdir)/cp/typeck2.c $(srcdir)/cp/xref.c
cc1plus$(exeext): $(P) $(CXX_SRCS) $(LIBDEPS) stamp-objlist c-common.o \
c-pragma.o $(srcdir)/cp/cp-tree.h $(srcdir)/cp/cp-tree.def \

View File

@ -176,7 +176,7 @@ INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../config -I$(srcdir)
CXX_OBJS = call.o decl.o errfn.o expr.o pt.o typeck2.o \
class.o decl2.o error.o lex.o parse.o ptree.o rtti.o spew.o typeck.o cvt.o \
except.o friend.o init.o method.o search.o semantics.o tree.o xref.o \
repo.o dump.o optimize.o @extra_cxx_objs@
repo.o dump.o optimize.o mangle.o @extra_cxx_objs@
# Language-independent object files.
OBJS = `cat ../stamp-objlist` ../c-common.o ../c-pragma.o
@ -311,6 +311,7 @@ dump.o: dump.c $(CXX_TREE_H)
optimize.o: optimize.c $(CXX_TREE_H) \
$(srcdir)/../rtl.h $(srcdir)/../integrate.h ../insn-config.h \
$(srcdir)/../input.h
mangle.o: mangle.c $(CXX_TREE_H) $(srcdir)/../toplev.h
#
# These exist for maintenance purposes.

View File

@ -83,6 +83,10 @@ typedef struct vcall_offset_data_s
static int current_class_stack_size;
static class_stack_node_t current_class_stack;
/* An array of all local classes present in this translation unit, in
declaration order. */
varray_type local_classes;
static tree get_vfield_name PARAMS ((tree));
static void finish_struct_anon PARAMS ((tree));
static tree build_vbase_pointer PARAMS ((tree, tree));
@ -630,8 +634,11 @@ static tree
get_vtable_name (type)
tree type;
{
return build_overload_with_type (get_identifier (VTABLE_NAME_PREFIX),
type);
if (flag_new_abi)
return mangle_vtbl_for_type (type);
else
return build_overload_with_type (get_identifier (VTABLE_NAME_PREFIX),
type);
}
/* Return an IDENTIFIER_NODE for the name of the virtual table table
@ -641,8 +648,11 @@ tree
get_vtt_name (type)
tree type;
{
return build_overload_with_type (get_identifier (VTT_NAME_PREFIX),
type);
if (flag_new_abi)
return mangle_vtt_for_type (type);
else
return build_overload_with_type (get_identifier (VTT_NAME_PREFIX),
type);
}
/* Return the offset to the main vtable for a given base BINFO. */
@ -5296,6 +5306,8 @@ init_class_processing ()
current_class_stack
= (class_stack_node_t) xmalloc (current_class_stack_size
* sizeof (struct class_stack_node));
VARRAY_TREE_INIT (local_classes, 8, "local_classes");
ggc_add_tree_varray_root (&local_classes, 1);
access_default_node = build_int_2 (0, 0);
access_public_node = build_int_2 (ak_public, 0);
@ -6698,7 +6710,10 @@ build_ctor_vtbl_group (binfo, t)
tree id;
/* See if we've already create this construction vtable group. */
id = get_ctor_vtbl_name (t, binfo);
if (flag_new_abi)
id = mangle_ctor_vtbl_for_type (t, binfo);
else
id = get_ctor_vtbl_name (t, binfo);
if (IDENTIFIER_GLOBAL_VALUE (id))
return;

View File

@ -588,6 +588,7 @@ enum cp_tree_index
CPTI_PFN_OR_DELTA2_IDENTIFIER,
CPTI_VPTR_IDENTIFIER,
CPTI_PUSH_EXCEPTION_IDENTIFIER,
CPTI_STD_IDENTIFIER,
CPTI_LANG_NAME_C,
CPTI_LANG_NAME_CPLUSPLUS,
@ -707,6 +708,8 @@ extern tree cp_global_trees[CPTI_MAX];
/* The name of the function to call to push an exception onto the
exception stack. */
#define cp_push_exception_identifier cp_global_trees[CPTI_PUSH_EXCEPTION_IDENTIFIER]
/* The name of the std namespace. */
#define std_identifier cp_global_trees[CPTI_STD_IDENTIFIER]
#define lang_name_c cp_global_trees[CPTI_LANG_NAME_C]
#define lang_name_cplusplus cp_global_trees[CPTI_LANG_NAME_CPLUSPLUS]
@ -1968,8 +1971,7 @@ struct lang_decl
#define DECL_COPY_CONSTRUCTOR_P(NODE) \
(DECL_CONSTRUCTOR_P (NODE) && copy_args_p (NODE))
/* There ought to be a better way to find out whether or not something is
a destructor. */
/* Nonzero if NODE is a destructor. */
#define DECL_DESTRUCTOR_P(NODE) \
(DECL_LANG_SPECIFIC (NODE)->decl_flags.destructor_attr)
@ -2118,6 +2120,13 @@ struct lang_decl
&& CP_TYPE_CONST_P (TREE_TYPE (TREE_VALUE \
(TYPE_ARG_TYPES (TREE_TYPE (NODE))))))
/* Nonzero for FUNCTION_DECL means that this member function
has `this' as volatile X *const. */
#define DECL_VOLATILE_MEMFUNC_P(NODE) \
(DECL_NONSTATIC_MEMBER_FUNCTION_P (NODE) \
&& CP_TYPE_VOLATILE_P (TREE_TYPE (TREE_VALUE \
(TYPE_ARG_TYPES (TREE_TYPE (NODE))))))
/* Nonzero for a DECL means that this member is a non-static member. */
#define DECL_NONSTATIC_MEMBER_P(NODE) \
((TREE_CODE (NODE) == FUNCTION_DECL \
@ -2209,7 +2218,7 @@ struct lang_decl
#define DECL_FUNCTION_SCOPE_P(NODE) \
(DECL_CONTEXT (NODE) \
&& TREE_CODE (DECL_CONTEXT (NODE)) == FUNCTION_DECL)
/* For a NAMESPACE_DECL: the list of using namespace directives
The PURPOSE is the used namespace, the value is the namespace
that is the common ancestor. */
@ -2226,6 +2235,12 @@ struct lang_decl
#define ORIGINAL_NAMESPACE(NODE) \
(DECL_NAMESPACE_ALIAS (NODE) ? DECL_NAMESPACE_ALIAS (NODE) : (NODE))
/* Non-zero if NODE is the std namespace. */
#define DECL_NAMESPACE_STD_P(NODE) \
(TREE_CODE (NODE) == NAMESPACE_DECL \
&& CP_DECL_CONTEXT (NODE) == global_namespace \
&& DECL_NAME (NODE) == std_identifier)
/* In a non-local VAR_DECL with static storage duration, this is the
initialization priority. If this value is zero, the NODE will be
initialized at the DEFAULT_INIT_PRIORITY. */
@ -3396,6 +3411,10 @@ extern int current_class_depth;
/* Points to the name of that function. May not be the DECL_NAME
of CURRENT_FUNCTION_DECL due to overloading */
extern tree original_function_name;
/* An array of all local classes present in this translation unit, in
declaration order. */
extern varray_type local_classes;
/* Here's where we control how name mangling takes place. */
@ -4355,7 +4374,7 @@ extern void print_candidates PARAMS ((tree));
extern int instantiate_pending_templates PARAMS ((void));
extern tree tsubst_default_argument PARAMS ((tree, tree, tree));
extern tree most_general_template PARAMS ((tree));
extern tree get_mostly_instantiated_function_type PARAMS ((tree, tree *, tree *));
extern int processing_template_parmlist;
/* in repo.c */
@ -4718,6 +4737,20 @@ extern void GNU_xref_member PARAMS ((tree, tree));
/* in dump.c */
extern void dump_node_to_file PARAMS ((tree, const char *));
/* 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));
extern tree mangle_typeinfo_string_for_type PARAMS ((tree));
extern tree mangle_vtbl_for_type PARAMS ((tree));
extern tree mangle_vtt_for_type PARAMS ((tree));
extern tree mangle_ctor_vtbl_for_type PARAMS ((tree, tree));
extern tree mangle_thunk PARAMS ((tree, int, int));
extern tree mangle_conv_op_name_for_type PARAMS ((tree));
extern tree mangle_guard_variable PARAMS ((tree));
/* -- end of C++ */
#endif /* not _CP_TREE_H */

View File

@ -2881,9 +2881,24 @@ pushtag (name, type, globalize)
TYPE_CONTEXT (type) = DECL_CONTEXT (d);
DECL_ASSEMBLER_NAME (d) = DECL_NAME (d);
if (!uses_template_parms (type))
DECL_ASSEMBLER_NAME (d)
= get_identifier (build_overload_name (type, 1, 1));
/* 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
all function definitions in a translation unit in a convenient
way. (It's otherwise tricky to find a member function definition
it's only pointed to from within a local class.) */
if (TYPE_CONTEXT (type)
&& TREE_CODE (TYPE_CONTEXT (type)) == FUNCTION_DECL)
VARRAY_PUSH_TREE (local_classes, type);
if (!uses_template_parms (type))
{
if (flag_new_abi)
DECL_ASSEMBLER_NAME (d) = mangle_type (type);
else
DECL_ASSEMBLER_NAME (d)
= get_identifier (build_overload_name (type, 1, 1));
}
}
if (b->parm_flag == 2)
{
@ -6229,6 +6244,7 @@ initialize_predefined_identifiers ()
{ "_vptr", &vptr_identifier, 0 },
{ "__cp_push_exception", &cp_push_exception_identifier, 0 },
{ "__vtt_parm", &vtt_parm_identifier, 0 },
{ "std", &std_identifier, 0 },
{ NULL, NULL, 0 }
};
@ -6577,7 +6593,8 @@ init_decl_processing ()
record_builtin_type (RID_MAX, NULL_PTR, vtbl_ptr_type_node);
std_node = build_decl (NAMESPACE_DECL,
get_identifier (flag_honor_std ? "fake std":"std"),
flag_honor_std
? get_identifier ("fake std") : std_identifier,
void_type_node);
pushdecl (std_node);
@ -7246,7 +7263,7 @@ start_decl (declarator, declspecs, initialized, attributes, prefix_attributes)
/* cp_finish_decl sets DECL_EXTERNAL if DECL_IN_AGGR_P is set. */
DECL_IN_AGGR_P (decl) = 0;
if ((DECL_LANG_SPECIFIC (decl) && DECL_USE_TEMPLATE (decl))
|| CLASSTYPE_USE_TEMPLATE (context))
|| CLASSTYPE_TEMPLATE_INSTANTIATION (context))
{
SET_DECL_TEMPLATE_SPECIALIZATION (decl);
/* [temp.expl.spec] An explicit specialization of a static data
@ -9086,7 +9103,16 @@ 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 (decl) = build_static_name (basetype, declarator);
/* DECL_ASSEMBLER_NAME is needed only for full-instantiated
templates. */
if (!uses_template_parms (decl))
{
if (flag_new_abi)
DECL_ASSEMBLER_NAME (decl) = mangle_decl (decl);
else
DECL_ASSEMBLER_NAME (decl) = build_static_name (basetype,
declarator);
}
}
else
{
@ -9110,8 +9136,14 @@ grokvardecl (type, declarator, specbits_in, initialized, constp, in_namespace)
set_decl_namespace (decl, context, 0);
context = DECL_CONTEXT (decl);
if (declarator && context && current_lang_name != lang_name_c)
DECL_ASSEMBLER_NAME (decl) = build_static_name (context, declarator);
if (declarator && context && current_lang_name != lang_name_c)
{
if (flag_new_abi)
DECL_ASSEMBLER_NAME (decl) = mangle_decl (decl);
else
DECL_ASSEMBLER_NAME (decl)
= build_static_name (context, declarator);
}
}
if (in_namespace)
@ -11146,19 +11178,24 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
DECL_NAME (CLASSTYPE_TI_TEMPLATE (type))
= TYPE_IDENTIFIER (type);
/* XXX Temporarily set the scope.
When returning, start_decl expects it as NULL_TREE,
and will then then set it using pushdecl. */
my_friendly_assert (DECL_CONTEXT (decl) == NULL_TREE, 980404);
if (current_class_type)
DECL_CONTEXT (decl) = current_class_type;
if (flag_new_abi)
DECL_ASSEMBLER_NAME (decl) = mangle_type (type);
else
DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace);
DECL_ASSEMBLER_NAME (decl) = DECL_NAME (decl);
DECL_ASSEMBLER_NAME (decl)
= get_identifier (build_overload_name (type, 1, 1));
DECL_CONTEXT (decl) = NULL_TREE;
{
/* XXX Temporarily set the scope.
When returning, start_decl expects it as NULL_TREE,
and will then then set it using pushdecl. */
my_friendly_assert (DECL_CONTEXT (decl) == NULL_TREE, 980404);
if (current_class_type)
DECL_CONTEXT (decl) = current_class_type;
else
DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace);
DECL_ASSEMBLER_NAME (decl) = DECL_NAME (decl);
DECL_ASSEMBLER_NAME (decl)
= get_identifier (build_overload_name (type, 1, 1));
DECL_CONTEXT (decl) = NULL_TREE;
}
/* FIXME remangle member functions; member functions of a
type with external linkage have external linkage. */

View File

@ -1116,7 +1116,12 @@ grokclassfn (ctype, function, flags, quals)
if (flags == DTOR_FLAG)
{
DECL_DESTRUCTOR_P (function) = 1;
DECL_ASSEMBLER_NAME (function) = build_destructor_name (ctype);
if (flag_new_abi)
set_mangled_name_for_decl (function);
else
DECL_ASSEMBLER_NAME (function) = build_destructor_name (ctype);
TYPE_HAS_DESTRUCTOR (ctype) = 1;
}
else
@ -1578,6 +1583,8 @@ finish_static_data_member_decl (decl, init, asmspec_tree, flags)
my_friendly_assert (TREE_PUBLIC (decl), 0);
DECL_CONTEXT (decl) = current_class_type;
/* We cannot call pushdecl here, because that would fill in the
decl of our TREE_CHAIN. Instead, we modify cp_finish_decl to do
the right thing, namely, to put this decl out straight away. */
@ -1585,8 +1592,11 @@ finish_static_data_member_decl (decl, init, asmspec_tree, flags)
if (!asmspec && current_class_type)
{
DECL_INITIAL (decl) = error_mark_node;
DECL_ASSEMBLER_NAME (decl)
= build_static_name (current_class_type, DECL_NAME (decl));
if (flag_new_abi)
DECL_ASSEMBLER_NAME (decl) = mangle_decl (decl);
else
DECL_ASSEMBLER_NAME (decl)
= build_static_name (current_class_type, DECL_NAME (decl));
}
if (! processing_template_decl)
{
@ -1611,7 +1621,6 @@ finish_static_data_member_decl (decl, init, asmspec_tree, flags)
TREE_USED (decl) = 1;
DECL_INITIAL (decl) = init;
DECL_IN_AGGR_P (decl) = 1;
DECL_CONTEXT (decl) = current_class_type;
cp_finish_decl (decl, init, asmspec_tree, flags);
}
@ -1717,9 +1726,14 @@ grokfield (declarator, declspecs, init, asmspec_tree, attrlist)
/* 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) =
get_identifier (build_overload_name (TREE_TYPE (value), 1, 1));
if (!uses_template_parms (value))
{
if (flag_new_abi)
DECL_ASSEMBLER_NAME (value) = mangle_type (TREE_TYPE (value));
else
DECL_ASSEMBLER_NAME (value) =
get_identifier (build_overload_name (TREE_TYPE (value), 1, 1));
}
if (processing_template_decl)
value = push_template_decl (value);
@ -1905,7 +1919,10 @@ grokoptypename (declspecs, declarator)
tree declspecs, declarator;
{
tree t = grokdeclarator (declarator, declspecs, TYPENAME, 0, NULL_TREE);
return build_typename_overload (t);
if (flag_new_abi)
return mangle_conv_op_name_for_type (t);
else
return build_typename_overload (t);
}
/* When a function is declared with an initializer,
@ -2856,16 +2873,25 @@ build_cleanup (decl)
return temp;
}
/* Returns the initialization guard variable for the non-local
variable DECL. */
static tree
get_sentry (base)
tree base;
get_sentry (decl)
tree decl;
{
tree sname = get_id_2 ("__sn", base);
tree sname;
tree sentry;
if (!flag_new_abi)
sname = get_id_2 ("__sn", DECL_ASSEMBLER_NAME (decl));
else
sname = mangle_guard_variable (decl);
/* For struct X foo __attribute__((weak)), there is a counter
__snfoo. Since base is already an assembler name, sname should
be globally unique */
tree sentry = IDENTIFIER_GLOBAL_VALUE (sname);
sentry = IDENTIFIER_GLOBAL_VALUE (sname);
if (! sentry)
{
sentry = build_decl (VAR_DECL, sname, integer_type_node);
@ -3239,7 +3265,9 @@ start_static_initialization_or_destruction (decl, initp)
cond = build_binary_op (TRUTH_ANDIF_EXPR, cond, init_cond);
/* We need a sentry if this is an object with external linkage that
might be initialized in more than one place. */
might be initialized in more than one place. (For example, a
static data member of a template, when the data member requires
construction.) */
if (TREE_PUBLIC (decl) && (DECL_COMMON (decl)
|| DECL_ONE_ONLY (decl)
|| DECL_WEAK (decl)))
@ -3247,7 +3275,7 @@ start_static_initialization_or_destruction (decl, initp)
tree sentry;
tree sentry_cond;
sentry = get_sentry (DECL_ASSEMBLER_NAME (decl));
sentry = get_sentry (decl);
/* We do initializations only if the SENTRY is zero, i.e., if we
are the first to initialize the variable. We do destructions

View File

@ -32,10 +32,6 @@ Boston, MA 02111-1307, USA. */
#include "except.h"
#include "tm_p.h"
#if 0
static tree extract_aggr_init PARAMS ((tree, tree));
static tree extract_scalar_init PARAMS ((tree, tree));
#endif
static rtx cplus_expand_expr PARAMS ((tree, rtx, enum machine_mode,
enum expand_modifier));
@ -202,86 +198,11 @@ fixup_result_decl (decl, result)
}
}
#if 0
/* Expand this initialization inline and see if it's simple enough that
it can be done at compile-time. */
static tree
extract_aggr_init (decl, init)
tree decl, init;
{
return 0;
}
static tree
extract_scalar_init (decl, init)
tree decl, init;
{
rtx value, insns, insn;
extern struct obstack temporary_obstack;
tree t = NULL_TREE;
start_sequence ();
value = expand_expr (init, NULL_RTX, VOIDmode, 0);
insns = get_insns ();
end_sequence ();
reg_scan (insns, max_reg_num (), 0);
jump_optimize (insns, 0, 0, 1);
for (insn = insns; insn; insn = NEXT_INSN (insn))
{
rtx r, to;
if (GET_CODE (insn) == NOTE)
continue;
else if (GET_CODE (insn) != INSN)
return 0;
r = PATTERN (insn);
if (GET_CODE (r) != SET)
return 0;
to = XEXP (r, 0);
if (! (to == value
|| (GET_CODE (to) == SUBREG && XEXP (to, 0) == value)))
return 0;
r = XEXP (r, 1);
switch (GET_CODE (r))
{
case CONST_INT:
t = build_int_2 (XEXP (r, 0), 0);
break;
default:
return 0;
}
}
return t;
}
#endif
int
extract_init (decl, init)
tree decl ATTRIBUTE_UNUSED, init ATTRIBUTE_UNUSED;
{
return 0;
#if 0
if (IS_AGGR_TYPE (TREE_TYPE (decl))
|| TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
init = extract_aggr_init (decl, init);
else
init = extract_scalar_init (decl, init);
if (init == NULL_TREE)
return 0;
DECL_INITIAL (decl) = init;
return 1;
#endif
}
void

2128
gcc/cp/mangle.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -137,6 +137,8 @@ init_method ()
ggc_add_tree_varray_root (&btypelist, 1);
ggc_add_tree_varray_root (&ktypelist, 1);
ggc_add_tree_varray_root (&typevec, 1);
if (flag_new_abi)
init_mangle ();
}
/* This must be large enough to hold any printed integer or floating-point
@ -156,6 +158,9 @@ static int numeric_output_need_bar;
static inline void
start_squangling ()
{
/* This function is obsoleted by the new ABI. */
my_friendly_assert (!flag_new_abi, 200005222);
if (flag_do_squangling)
{
nofold = 0;
@ -1125,6 +1130,10 @@ build_overload_name (parmtypes, begin, end)
int begin, end;
{
char *ret;
/* This function is obsoleted by the new ABI. */
my_friendly_assert (!flag_new_abi, 200005221);
start_squangling ();
ret = build_mangled_name (parmtypes, begin, end);
end_squangling ();
@ -1140,6 +1149,9 @@ build_mangled_name (parmtypes, begin, end)
tree parmtypes;
int begin, end;
{
/* This function is obsoleted by the new ABI. */
my_friendly_assert (!flag_new_abi, 200004105);
if (begin)
OB_INIT ();
@ -1549,6 +1561,9 @@ tree
build_static_name (context, name)
tree context, name;
{
/* This function is obsoleted by the new ABI. */
my_friendly_assert (!flag_new_abi, 200004106);
OB_INIT ();
numeric_output_need_bar = 0;
start_squangling ();
@ -1584,6 +1599,9 @@ build_decl_overload_real (decl, parms, ret_type, tparms, targs,
const char *name;
enum tree_code operator_code;
/* This function is obsoleted by the new ABI. */
my_friendly_assert (!flag_new_abi, 20000410);
operator_code = DECL_OVERLOADED_OPERATOR_P (decl);
if (!DECL_CONV_FN_P (decl) && operator_code)
{
@ -1719,6 +1737,12 @@ set_mangled_name_for_decl (decl)
/* There's no need to mangle the name of a template function. */
return;
if (flag_new_abi)
{
DECL_ASSEMBLER_NAME (decl) = mangle_decl (decl);
return;
}
parm_types = TYPE_ARG_TYPES (TREE_TYPE (decl));
if (DECL_STATIC_FUNCTION_P (decl))
@ -1748,6 +1772,9 @@ build_typename_overload (type)
{
tree id;
/* This function is obsoleted by the new ABI. */
my_friendly_assert (!flag_new_abi, 200004108);
OB_INIT ();
OB_PUTS (OPERATOR_TYPENAME_FORMAT);
nofold = 1;
@ -1765,6 +1792,9 @@ tree
build_overload_with_type (name, type)
tree name, type;
{
/* This function is obsoleted by the new ABI. */
my_friendly_assert (!flag_new_abi, 200004109);
OB_INIT ();
OB_PUTID (name);
nofold = 1;
@ -1780,6 +1810,9 @@ get_id_2 (name, name2)
const char *name;
tree name2;
{
/* This function is obsoleted by the new ABI. */
my_friendly_assert (!flag_new_abi, 20000411);
OB_INIT ();
OB_PUTCP (name);
OB_PUTID (name2);
@ -1796,6 +1829,9 @@ get_ctor_vtbl_name (type, binfo)
tree type;
tree binfo;
{
/* This function is obsoleted by the new ABI. */
my_friendly_assert (!flag_new_abi, 200005220);
start_squangling ();
OB_INIT ();
OB_PUTCP (CTOR_VTBL_NAME_PREFIX);
@ -2019,6 +2055,11 @@ hack_identifier (value, name)
}
/* Return a thunk to FUNCTION. For a virtual thunk, DELTA is the
offset to this used to locate the vptr, and VCALL_INDEX is used to
look up the eventual subobject location. For a non-virtual thunk,
DELTA is the offset to this and VCALL_INDEX is zero. */
tree
make_thunk (function, delta, vcall_index)
tree function;
@ -2028,6 +2069,7 @@ make_thunk (function, delta, vcall_index)
tree thunk_id;
tree thunk;
tree func_decl;
int vcall_offset = vcall_index * int_size_in_bytes (vtable_entry_type);
if (TREE_CODE (function) != ADDR_EXPR)
abort ();
@ -2035,24 +2077,29 @@ make_thunk (function, delta, vcall_index)
if (TREE_CODE (func_decl) != FUNCTION_DECL)
abort ();
OB_INIT ();
OB_PUTS ("__thunk_");
if (delta > 0)
{
OB_PUTC ('n');
icat (delta);
}
if (flag_new_abi)
thunk_id = mangle_thunk (TREE_OPERAND (function, 0), delta, vcall_offset);
else
icat (-delta);
OB_PUTC ('_');
if (vcall_index)
{
icat (vcall_index);
OB_INIT ();
OB_PUTS ("__thunk_");
if (delta > 0)
{
OB_PUTC ('n');
icat (delta);
}
else
icat (-delta);
OB_PUTC ('_');
if (vcall_index)
{
icat (vcall_index);
OB_PUTC ('_');
}
OB_PUTID (DECL_ASSEMBLER_NAME (func_decl));
OB_FINISH ();
thunk_id = get_identifier (obstack_base (&scratch_obstack));
}
OB_PUTID (DECL_ASSEMBLER_NAME (func_decl));
OB_FINISH ();
thunk_id = get_identifier (obstack_base (&scratch_obstack));
thunk = IDENTIFIER_GLOBAL_VALUE (thunk_id);
if (thunk && !DECL_THUNK_P (thunk))
@ -2073,8 +2120,7 @@ make_thunk (function, delta, vcall_index)
SET_DECL_THUNK_P (thunk);
DECL_INITIAL (thunk) = function;
THUNK_DELTA (thunk) = delta;
THUNK_VCALL_OFFSET (thunk)
= vcall_index * int_size_in_bytes (vtable_entry_type);
THUNK_VCALL_OFFSET (thunk) = vcall_offset;
/* The thunk itself is not a constructor or destructor, even if
the thing it is thunking to is. */
DECL_INTERFACE_KNOWN (thunk) = 1;

View File

@ -108,7 +108,7 @@ DEF_SIMPLE_OPERATOR ("+", PLUS_EXPR, "pl", "__pl", 2)
DEF_SIMPLE_OPERATOR ("-", MINUS_EXPR, "mi", "__mi", 2)
DEF_SIMPLE_OPERATOR ("*", MULT_EXPR, "ml", "__ml", 2)
DEF_SIMPLE_OPERATOR ("/", TRUNC_DIV_EXPR, "dv", "__dv", 2)
DEF_SIMPLE_OPERATOR ("%", TRUNC_MOD_EXPR, "md", "__md", 2)
DEF_SIMPLE_OPERATOR ("%", TRUNC_MOD_EXPR, "rm", "__md", 2)
DEF_SIMPLE_OPERATOR ("&", BIT_AND_EXPR, "an", "__ad", 2)
DEF_SIMPLE_OPERATOR ("|", BIT_IOR_EXPR, "or", "__or", 2)
DEF_SIMPLE_OPERATOR ("^", BIT_XOR_EXPR, "eo", "__er", 2)
@ -131,6 +131,8 @@ DEF_SIMPLE_OPERATOR ("--", POSTDECREMENT_EXPR, "mm", "__mm", 2)
/* These are extensions. */
DEF_SIMPLE_OPERATOR ("<?", MIN_EXPR, "vx3min", "__mn", 2)
DEF_SIMPLE_OPERATOR (">?", MAX_EXPR, "vx3max", "__mx", 2)
/* This one is needed for mangling. */
DEF_SIMPLE_OPERATOR ("::", SCOPE_REF, "sr", NULL, 2);
/* Assignment operators. */
DEF_ASSN_OPERATOR ("=", NOP_EXPR, "aS", "__as", 2)
@ -138,7 +140,7 @@ DEF_ASSN_OPERATOR ("+=", PLUS_EXPR, "pL", "__apl", 2)
DEF_ASSN_OPERATOR ("-=", MINUS_EXPR, "mI", "__ami", 2)
DEF_ASSN_OPERATOR ("*=", MULT_EXPR, "mL", "__aml", 2)
DEF_ASSN_OPERATOR ("/=", TRUNC_DIV_EXPR, "dV", "__adv", 2)
DEF_ASSN_OPERATOR ("%=", TRUNC_MOD_EXPR, "mD", "__amd", 2)
DEF_ASSN_OPERATOR ("%=", TRUNC_MOD_EXPR, "rM", "__amd", 2)
DEF_ASSN_OPERATOR ("&=", BIT_AND_EXPR, "aN", "__aad", 2)
DEF_ASSN_OPERATOR ("|=", BIT_IOR_EXPR, "oR", "__aor", 2)
DEF_ASSN_OPERATOR ("^=", BIT_XOR_EXPR, "eO", "__aer", 2)
@ -150,4 +152,3 @@ DEF_SIMPLE_OPERATOR ("?:", COND_EXPR, "qu", "__cn", 3)
/* Miscellaneous. */
DEF_SIMPLE_OPERATOR ("()", CALL_EXPR, "cl", "__cl", -1)

View File

@ -1984,6 +1984,10 @@ build_template_decl (decl, parms)
DECL_STATIC_FUNCTION_P (tmpl) = DECL_STATIC_FUNCTION_P (decl);
DECL_CONSTRUCTOR_P (tmpl) = DECL_CONSTRUCTOR_P (decl);
DECL_NONCONVERTING_P (tmpl) = DECL_NONCONVERTING_P (decl);
DECL_ASSIGNMENT_OPERATOR_P (tmpl) = DECL_ASSIGNMENT_OPERATOR_P (decl);
if (DECL_OVERLOADED_OPERATOR_P (decl))
SET_OVERLOADED_OPERATOR_CODE (tmpl,
DECL_OVERLOADED_OPERATOR_P (decl));
}
return tmpl;
@ -4047,8 +4051,11 @@ lookup_template_class (d1, arglist, in_decl, context, entering_scope)
DECL_ASSEMBLER_NAME (type_decl) = DECL_NAME (type_decl);
if (!is_partial_instantiation)
{
DECL_ASSEMBLER_NAME (type_decl)
= get_identifier (build_overload_name (t, 1, 1));
if (flag_new_abi)
DECL_ASSEMBLER_NAME (type_decl) = mangle_decl (type_decl);
else
DECL_ASSEMBLER_NAME (type_decl)
= get_identifier (build_overload_name (t, 1, 1));
/* For backwards compatibility; code that uses
-fexternal-templates expects looking up a template to
@ -5708,10 +5715,15 @@ tsubst_decl (t, args, type, in_decl)
/*complain=*/1, t,
/*entering_scope=*/1);
if (member && DECL_CONV_FN_P (r))
/* Type-conversion operator. Reconstruct the name, in
case it's the name of one of the template's parameters. */
DECL_NAME (r) = build_typename_overload (TREE_TYPE (type));
if (member && DECL_CONV_FN_P (r))
{
/* Type-conversion operator. Reconstruct the name, in
case it's the name of one of the template's parameters. */
if (flag_new_abi)
DECL_NAME (r) = mangle_conv_op_name_for_type (TREE_TYPE (type));
else
DECL_NAME (r) = build_typename_overload (TREE_TYPE (type));
}
DECL_ARGUMENTS (r) = tsubst (DECL_ARGUMENTS (t), args,
/*complain=*/1, t);
@ -5745,8 +5757,13 @@ tsubst_decl (t, args, type, in_decl)
register_specialization (r, gen_tmpl, argvec);
/* Set the mangled name for R. */
if (DECL_DESTRUCTOR_P (t))
DECL_ASSEMBLER_NAME (r) = build_destructor_name (ctx);
if (DECL_DESTRUCTOR_P (t))
{
if (flag_new_abi)
set_mangled_name_for_decl (r);
else
DECL_ASSEMBLER_NAME (r) = build_destructor_name (ctx);
}
else
{
/* Instantiations of template functions must be mangled
@ -7078,8 +7095,13 @@ tsubst_copy (t, args, complain, in_decl)
case IDENTIFIER_NODE:
if (IDENTIFIER_TYPENAME_P (t))
return (build_typename_overload
(tsubst (TREE_TYPE (t), args, complain, in_decl)));
{
tree new_type = tsubst (TREE_TYPE (t), args, complain, in_decl);
if (flag_new_abi)
return mangle_conv_op_name_for_type (new_type);
else
return (build_typename_overload (new_type));
}
else
return t;
@ -9911,42 +9933,29 @@ tsubst_enum (tag, newtag, args)
finish_enum (newtag);
}
/* Set the DECL_ASSEMBLER_NAME for DECL, which is a FUNCTION_DECL that
is either an instantiation or specialization of a template
function. */
/* DECL is a FUNCTION_DECL that is a template specialization. Return
its type -- but without substituting the innermost set of template
arguments. So, innermost set of template parameters will appear in
the type. If CONTEXTP is non-NULL, then the partially substituted
DECL_CONTEXT (if any) will also be filled in. Similarly, TPARMSP
will be filled in with the substituted template parameters, if it
is non-NULL. */
static void
set_mangled_name_for_template_decl (decl)
tree
get_mostly_instantiated_function_type (decl, contextp, tparmsp)
tree decl;
tree *contextp;
tree *tparmsp;
{
tree context = NULL_TREE;
tree fn_type;
tree ret_type;
tree parm_types;
tree tparms;
tree targs;
tree tmpl;
tree targs;
tree tparms;
int parm_depth;
my_friendly_assert (TREE_CODE (decl) == FUNCTION_DECL, 0);
my_friendly_assert (DECL_TEMPLATE_INFO (decl) != NULL_TREE, 0);
/* The names of template functions must be mangled so as to indicate
what template is being specialized with what template arguments.
For example, each of the following three functions must get
different mangled names:
void f(int);
template <> void f<7>(int);
template <> void f<8>(int); */
targs = DECL_TI_ARGS (decl);
if (uses_template_parms (targs))
/* This DECL is for a partial instantiation. There's no need to
mangle the name of such an entity. */
return;
tmpl = most_general_template (DECL_TI_TEMPLATE (decl));
targs = DECL_TI_ARGS (decl);
tparms = DECL_TEMPLATE_PARMS (tmpl);
parm_depth = TMPL_PARMS_DEPTH (tparms);
@ -9954,24 +9963,6 @@ set_mangled_name_for_template_decl (decl)
of parameters. */
my_friendly_assert (parm_depth == TMPL_ARGS_DEPTH (targs), 0);
/* We now compute the PARMS and RET_TYPE to give to
build_decl_overload_real. The PARMS and RET_TYPE are the
parameter and return types of the template, after all but the
innermost template arguments have been substituted, not the
parameter and return types of the function DECL. For example,
given:
template <class T> T f(T);
both PARMS and RET_TYPE should be `T' even if DECL is `int f(int)'.
A more subtle example is:
template <class T> struct S { template <class U> void f(T, U); }
Here, if DECL is `void S<int>::f(int, double)', PARMS should be
{int, U}. Thus, the args that we want to subsitute into the
return and parameter type for the function are those in TARGS,
with the innermost level omitted. */
fn_type = TREE_TYPE (tmpl);
if (DECL_STATIC_FUNCTION_P (decl))
context = DECL_CONTEXT (decl);
@ -9986,7 +9977,7 @@ set_mangled_name_for_template_decl (decl)
/* Replace the innermost level of the TARGS with NULL_TREEs to
let tsubst know not to subsitute for those parameters. */
partial_args = make_tree_vec (TMPL_ARGS_DEPTH (targs));
partial_args = make_tree_vec (TREE_VEC_LENGTH (targs));
for (i = 1; i < TMPL_ARGS_DEPTH (targs); ++i)
SET_TMPL_ARGS_LEVEL (partial_args, i,
TMPL_ARGS_LEVEL (targs, i));
@ -10008,6 +9999,74 @@ set_mangled_name_for_template_decl (decl)
tparms = tsubst_template_parms (tparms, partial_args, /*complain=*/1);
}
if (contextp)
*contextp = context;
if (tparmsp)
*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;
{
tree context = NULL_TREE;
tree fn_type;
tree ret_type;
tree parm_types;
tree tparms;
tree targs;
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. */
if (flag_new_abi)
{
set_mangled_name_for_decl (decl);
return;
}
/* The names of template functions must be mangled so as to indicate
what template is being specialized with what template arguments.
For example, each of the following three functions must get
different mangled names:
void f(int);
template <> void f<7>(int);
template <> void f<8>(int); */
targs = DECL_TI_ARGS (decl);
if (uses_template_parms (targs))
/* This DECL is for a partial instantiation. There's no need to
mangle the name of such an entity. */
return;
/* We now compute the PARMS and RET_TYPE to give to
build_decl_overload_real. The PARMS and RET_TYPE are the
parameter and return types of the template, after all but the
innermost template arguments have been substituted, not the
parameter and return types of the function DECL. For example,
given:
template <class T> T f(T);
both PARMS and RET_TYPE should be `T' even if DECL is `int f(int)'.
A more subtle example is:
template <class T> struct S { template <class U> void f(T, U); }
Here, if DECL is `void S<int>::f(int, double)', PARMS should be
{int, U}. Thus, the args that we want to subsitute into the
return and parameter type for the function are those in TARGS,
with the innermost level omitted. */
fn_type = get_mostly_instantiated_function_type (decl, &context, &tparms);
/* Now, get the innermost parameters and arguments, and figure out
the parameter and return types. */
tparms = INNERMOST_TEMPLATE_PARMS (tparms);
@ -10034,10 +10093,10 @@ set_mangled_name_for_template_decl (decl)
my_friendly_assert (TREE_VEC_LENGTH (tparms) == TREE_VEC_LENGTH (targs),
0);
/* Actually set the DCL_ASSEMBLER_NAME. */
/* Actually set the DECL_ASSEMBLER_NAME. */
DECL_ASSEMBLER_NAME (decl)
= build_decl_overload_real (decl, parm_types, ret_type,
tparms, targs,
DECL_FUNCTION_MEMBER_P (decl)
+ DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl));
+ DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl));
}

View File

@ -377,8 +377,14 @@ static tree
tinfo_name (type)
tree type;
{
const char *name = build_overload_name (type, 1, 1);
tree name_string = combine_strings (build_string (strlen (name) + 1, name));
const char *name;
tree name_string;
if (flag_new_abi)
name = mangle_type_string (type);
else
name = build_overload_name (type, 1, 1);
name_string = combine_strings (build_string (strlen (name) + 1, name));
return name_string;
}
@ -403,15 +409,18 @@ get_tinfo_decl (type)
type = build_function_type (TREE_TYPE (type),
TREE_CHAIN (TYPE_ARG_TYPES (type)));
name = build_overload_with_type (tinfo_decl_id, type);
if (flag_new_abi)
name = mangle_typeinfo_for_type (type);
else
name = build_overload_with_type (tinfo_decl_id, type);
d = IDENTIFIER_GLOBAL_VALUE (name);
if (d)
/* OK */;
else if (!new_abi_rtti_p ())
{
/* The tinfo decl is a function returning a reference to the type_info
object. */
/* The tinfo decl is a function returning a reference to the
type_info object. */
d = push_library_fn (name, tinfo_decl_type);
DECL_NOT_REALLY_EXTERN (d) = 1;
SET_DECL_TINFO_FN_P (d);
@ -1298,12 +1307,18 @@ tinfo_base_init (desc, target)
tree name_decl;
{
tree name_name;
/* Generate the NTBS array variable. */
tree name_name = build_overload_with_type (tinfo_var_id, target);
tree name_type = build_cplus_array_type
(build_qualified_type (char_type_node, TYPE_QUAL_CONST),
NULL_TREE);
tree name_string = tinfo_name (target);
if (flag_new_abi)
name_name = mangle_typeinfo_for_type (target);
else
name_name = build_overload_with_type (tinfo_var_id, target);
name_decl = build_lang_decl (VAR_DECL, name_name, name_type);
DECL_ARTIFICIAL (name_decl) = 1;
@ -1312,7 +1327,13 @@ tinfo_base_init (desc, target)
DECL_EXTERNAL (name_decl) = 0;
TREE_PUBLIC (name_decl) = 1;
comdat_linkage (name_decl);
DECL_ASSEMBLER_NAME (name_decl) = DECL_NAME (name_decl);
if (flag_new_abi)
/* 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);
else
DECL_ASSEMBLER_NAME (name_decl) = DECL_NAME (name_decl);
DECL_INITIAL (name_decl) = name_string;
cp_finish_decl (name_decl, name_string, NULL_TREE, 0);
}

View File

@ -26,9 +26,9 @@ struct T : public S
// Provide access to the raw function pointers. This is
// mangling-dependent.
extern "C" void f__1T ();
extern "C" void g__1T ();
extern "C" void h__1T ();
extern "C" void _ZN1T1fEv ();
extern "C" void _ZN1T1gEv ();
extern "C" void _ZN1T1hEv ();
// This structure is a C representation of a pointer-to-member.
@ -72,12 +72,12 @@ main ()
// There should be no adjustment for the `T' version, and an
// appropriate adjustment for the `S' version.
y = &T::f;
if (yp->ptr != &f__1T)
if (yp->ptr != &_ZN1T1fEv)
return 5;
if (yp->adj != 0)
return 6;
x = (sp) y;
if (xp->ptr != &f__1T)
if (xp->ptr != &_ZN1T1fEv)
return 7;
if (xp->adj != delta)
return 8;

View File

@ -122,8 +122,8 @@ void S4::s1 ()
// These are tricks to allow us to get raw function pointers for
// member functions.
extern "C" {
void s3__2S3 ();
void s1__2S4 ();
void _ZN2S32s3Ev ();
void _ZN2S42s1Ev ();
}
int main ()
@ -147,9 +147,9 @@ int main ()
return 4;
// Skip the RTTI entry.
vtbl++;
if (*vtbl++ != (ptrdiff_t) &s3__2S3)
if (*vtbl++ != (ptrdiff_t) &_ZN2S32s3Ev)
return 5;
if (*vtbl++ != (ptrdiff_t) &s1__2S4)
if (*vtbl++ != (ptrdiff_t) &_ZN2S42s1Ev)
return 6;
// The S1 vbase offset.
if (*vtbl++ != 0)

View File

@ -1,6 +1,12 @@
// Test for proper mangling by setting up name clashes.
// Special g++ Options: -fno-squangle
#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;
@ -8,38 +14,45 @@ typedef void V;
typedef I I2;
void f (const A2&, int, const A2&, const A&) { } // ERROR - name clash
int f__FRC1AiT0T0 = 0; // ERROR - name clash
int NAME (f__FRC1AiT0T0, _Z1fRK1AiS1_S1_) = 0; // ERROR - name clash
void f (int, long, int, I) { } // ERROR - name clash
int f__Filii = 0; // ERROR - name clash
int NAME (f__Filii, _Z1filii) = 0; // ERROR - name clash
void f (I, float, I, I2) { } // ERROR - name clash
int f__Fifii = 0; // ERROR - name clash
int NAME (f__Fifii, _Z1fifii) = 0; // ERROR - name clash
void f (void*, float, void*, V*) { } // ERROR - name clash
int f__FPvfT0T0 = 0; // ERROR - name clash
int NAME (f__FPvfT0T0, _Z1fPvfS_S_) = 0; // ERROR - name clash
void f (wchar_t) { } // ERROR - name clash
int f__Fw = 0; // ERROR - name clash
int NAME (f__Fw, _Z1fw) = 0; // ERROR - name clash
void f(int, A, A2, A) { } // ERROR - name clash
int f__FiG1AN21 = 0; // 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 f__FRC1AN30Ri = 0; // 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 f__FRC1AiT0N20Ri = 0; // 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 f__FRC1AiT0N20RiN25 = 0; // 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 f__FRC1AiT0N20iii = 0; // ERROR - name clash
int NAME (f__FRC1AiT0N20iii, _Z1fRK1AiS1_S1_S1_iii) = 0; // ERROR - name clash
void f(bool, bool) {} // ERROR - name clash
int f__FbT0 = 0; // ERROR - name clash
int NAME (f__FbT0, _Z1fbb) = 0; // ERROR - name clash
int
main ()
{
return 0;
}

View File

@ -1,42 +0,0 @@
// Test for proper mangling by setting up name clashes.
// Special g++ Options: -fsquangle
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 f__FRC1AiRCB0n1 = 0; // ERROR - name clash
void f (int, long, int, I) { } // ERROR - name clash
int f__Filii = 0; // ERROR - name clash
void f (I, float, I, I2) { } // ERROR - name clash
int f__Fifii = 0; // ERROR - name clash
void f (void*, float, void*, V*) { } // ERROR - name clash
int f__FPvfPvn1 = 0; // ERROR - name clash
void f (wchar_t) { } // ERROR - name clash
int f__Fw = 0; // ERROR - name clash
void f(int, A, A2, A) { } // ERROR - name clash
int f__FiG1An2 = 0; // ERROR - name clash
void f(const A2&, const A2&, const A2&, const A2&,
int&) { } // ERROR - name clash
int f__FRC1An3Ri = 0; // ERROR - name clash
void f(const A2&, int, const A2&, const A2&, const A2&,
int&) { } // ERROR - name clash
int f__FRC1AiRCB0n2Ri = 0; // ERROR - name clash
void f(const A2&, int, const A2&, const A2&, const A2&, int&, int&,
int&) { } // ERROR - name clash
int f__FRC1AiRCB0n2Rin2 = 0; // ERROR - name clash
void f(const A2&, int, const A2&, const A2&, const A2&, int, int,
int) { } // ERROR - name clash
int f__FRC1AiRCB0n2in2 = 0; // ERROR - name clash

View File

@ -2,6 +2,12 @@
// Special g++ Options: -fno-squangle
// 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*) {} // ERROR - previous declaration
int strlen__FPCc = 0; // ERROR - duplicate declaration
int NAME (strlen__FPCc, _Z6strlenPKc) = 0; // ERROR - duplicate declaration