revert mangling patch

From-SVN: r34471
This commit is contained in:
Jason Merrill 2000-06-09 12:26:24 -04:00
parent ea11ca7ec1
commit 669ec2b4f0
16 changed files with 2281 additions and 318 deletions

View File

@ -41,11 +41,6 @@
(value_format, case dw_val_class_const): Use sdata format.
(output_die): Call output_sleb128.
2000-06-08 Mark Mitchell <mark@codesourcery.com>
* invoke.texi: Remove documentation for -fsquangle and
-fname-mangling-version.
2000-06-08 James E. Wilson <wilson@cygnus.com>
* dwarf2out.c (ASM_OUTPUT_DWARF_DATA8): Add new macro that uses

View File

@ -11,139 +11,6 @@
* lex.c (DEF_OPERATOR): Say `operator@' -not- `operator @'
whenever @ is a symbolic name.
2000-06-08 Mark Mitchell <mark@codesourcery.com>
Remove old ABI mangling code.
* cp-tree.h (cp_tree_index): Remove CPTI_TINFO_DECL_ID and
CPTI_TINFO_VAR_ID.
(tinfo_decl_id): Remove.
(tinfo_var_id): Likewise.
(name_mangling_version): Likewise.
(flag_do_squangling): Likewise.
(get_vtt_name): Likewise.
(init_method): Likewise.
(build_overload_name): Likewise.
(build_static_name): Likewise.
(build_decl_overload_real): Likewise.
(build_overload_with_type): Likewise.
(build_destructor_name): Likewise.
(get_id_2): Likewise.
(get_ctor_vtbl_name): Likewise.
(mangle_typeinfo_fn_for_type): New function.
(mangle_java_reflection_var_for_type): Likewise.
* call.c (build_new_method_call): Use mangle_vtt_for_type.
* class.c (get_vtable_name): Remove.
(get_vtt_name): Remove.
(get_vtable_decl): Use mangle_vtbl_for_type.
(build_vtt): Likewise.
(build_ctor_vtbl_group): Remove old ABI mangling support.
* decl.c (pushtag): Likewise.
(maybe_commonize_var): Use set_mangled_name_for_decl.
(grokfndecl): Remove old ABI mangling support.
(grokvardecl): Likewise.
(grokdeclarator): Likewise.
(grok_op_properties): Adjust use of DEF_OPERATOR.
* decl2.c (name_mangling_version): Remove.
(lang_f_options): Remove squangle.
(unsupported_options): Add squangle.
(lang_decode_options): Don't set flag_do_squangling. Issue a
warning for -fname-mangling-version.
(grokclassfn): Remove old ABI mangling support.
(finish_static_data_member_decl): Likewise.
(grokfield): Likewise.
(grokoptypename): Likewise.
(get_sentry): Likewise.
* init.c (build_java_class_ref): Use
mangle_java_reflection_var_for_type.
* lex.c (init_operators): Adjust use of DEF_OPERATOR.
(init_parse): Call init_mangle, not init_method.
* mangle.c (write_special_name_constructor): Handle
maybe-in-charge constructors.
(write_special_name_destructor): Handle
maybe-in-charge destructors.
(write_expression): Tweak code to handle non-type template
arguments with reference type.
(mangle_typeinfo_fn_for_type): New function.
(mangle_java_reflection_var_for_type): Likewise.
(mangle_conv_op_name_for_type): Don't use a name that the user
could type.
* method.c (enum mangling_flags): Remove.
(mangling_flags): Likewise.
(obstack_chunk_alloc): Likewise.
(obstack_chunk_free): Likewise.
(OB_INIT): Likewise.
(OB_PUTC): Likewise.
(OB_PUTC2): Likewise.
(OB_PUTS): Likewise.
(OB_PUTID): Likewise.
(OB_PUTCP): Likewise.
(OB_FINISH): Likewise.
(OB_LAST): Likewise.
(btypelist): Likewise.
(ktypelist): Likewise.
(maxbtype): Likewise.
(maxktype): Likewise.
(typevec): Likewise.
(maxtype): Likewise.
(init_method): Likewise.
(digit_buffer): Likewise.
(nofold): Likewise.
(start_squangling): Likewise.
(end_squangling): Likewise.
(icat): Likewise.
(dicat): Likewise.
(old_backref_index): Likewise.
(flush_repeats): Likewise.
(is_back_referenceable_type): Likewise.
(issue_nrepeats): Likewise.
(check_ktype): Likewise.
(issue_ktype): Likewise.
(build_overload_nested_name): Likewise.
(build_underscore_int): Likewise.
(build_overload_scope_ref): Likewise.
(mangle_expression): Likewise.
(build_overload_int): Likewise.
(mangled_C9x_name): Likewise.
(build_overload_value): Likewise.
(build_template_template_parm_names): Likewise.
(build_template_parm_names): Likewise.
(build_overload_identifier): Likewise.
(build_qualified_name): Likewise.
(build_mangled_name_for_type_with_Gcode): Likewise.
(build_mangled_name_for_type): Likewise.
(build_overload_name): Likewise.
(build_mangled_name): Likewise.
(process_modifiers): Likewise.
(check_btype): Likewise.
(process_overload_item): Likewise.
(build_static_name): Likewise.
(build_decl_overload_real): Likewise.
(set_mangled_name_for_decl): Remove old ABI mangling support.
(build_typename_overload): Remove.
(build_overload_with_type): Remove.
(get_id_2): Remove.
(get_ctor_vtbl_name): Remove.
(build_destructor_name): Likewise.
(set_mangled_name_for_decl): Likewise.
(make_thunk): Remove old ABI mangling support.
* operators.def: Likewise.
* pt.c (check_explicit_specialization): Don't call
set_mangled_name_for_template_decl.
(lookup_template_class): Remove old ABI mangling support.
(tsubst_friend_function): Update comment.
(tsubst_decl): Remove old ABI mangling support.
(tsubst_copy): Likewise.
(set_mangled_name_for_template_decl): Remove.
* rtti.c (init_rtti_processing): Use std_identifier. Don't set
tinfo_decl_id or tinfo_var_id.
(get_tinfo_var): Use mangle_typeinfo_for_type.
(tinfo_name): Remove old ABI mangling support.
(get_tinfo_decl): Likewise.
(tinfo_base_init): Likewise.
(create_real_tinfo_var): Use a name that the user can't type.
* tinfo2.cc (BUILTIN): Adjust to use new mangling.
2000-06-08 Jakub Jelinek <jakub@redhat.com>
* method.c (make_thunk): Clear DECL_VTT_PARM in thunk.

View File

@ -4332,8 +4332,7 @@ build_new_method_call (instance, name, args, basetype_path, flags)
/* If the current function is a complete object constructor
or destructor, then we fetch the VTT directly.
Otherwise, we look it up using the VTT we were given. */
vtt = IDENTIFIER_GLOBAL_VALUE (mangle_vtt_for_type
(current_class_type));
vtt = IDENTIFIER_GLOBAL_VALUE (get_vtt_name (current_class_type));
vtt = build_unary_op (ADDR_EXPR, vtt, /*noconvert=*/1);
vtt = build (COND_EXPR, TREE_TYPE (vtt),
DECL_USE_VTT_PARM (current_function_decl),

View File

@ -91,6 +91,7 @@ static tree get_vfield_name PARAMS ((tree));
static void finish_struct_anon PARAMS ((tree));
static tree build_vbase_pointer PARAMS ((tree, tree));
static tree build_vtable_entry PARAMS ((tree, tree, tree));
static tree get_vtable_name PARAMS ((tree));
static tree get_derived_offset PARAMS ((tree, tree));
static tree get_basefndecls PARAMS ((tree, tree));
static int build_primary_vtable PARAMS ((tree, tree));
@ -627,6 +628,34 @@ build_vfn_ref (ptr_to_instptr, instance, idx)
return build_component_ref (aref, pfn_identifier, NULL_TREE, 0);
}
/* Return the name of the virtual function table (as an IDENTIFIER_NODE)
for the given TYPE. */
static tree
get_vtable_name (type)
tree 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
for TYPE. */
tree
get_vtt_name (type)
tree 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. */
tree
@ -703,7 +732,7 @@ get_vtable_decl (type, complete)
tree type;
int complete;
{
tree name = mangle_vtbl_for_type (type);
tree name = get_vtable_name (type);
tree decl = IDENTIFIER_GLOBAL_VALUE (name);
if (decl)
@ -6558,7 +6587,7 @@ build_vtt (t)
type = build_cplus_array_type (const_ptr_type_node, type);
/* Now, build the VTT object itself. */
vtt = build_vtable (t, mangle_vtt_for_type (t), type);
vtt = build_vtable (t, get_vtt_name (t), type);
pushdecl_top_level (vtt);
initialize_array (vtt, inits);
}
@ -6742,7 +6771,10 @@ build_ctor_vtbl_group (binfo, t)
tree id;
/* See if we've already create this construction vtable group. */
id = mangle_ctor_vtbl_for_type (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

@ -555,7 +555,9 @@ enum cp_tree_index
CPTI_STD,
CPTI_ABI,
CPTI_TYPE_INFO_TYPE,
CPTI_TINFO_DECL_ID,
CPTI_TINFO_DECL_TYPE,
CPTI_TINFO_VAR_ID,
CPTI_ABORT_FNDECL,
CPTI_GLOBAL_DELETE_FNDECL,
@ -647,7 +649,9 @@ extern tree cp_global_trees[CPTI_MAX];
#define std_node cp_global_trees[CPTI_STD]
#define abi_node cp_global_trees[CPTI_ABI]
#define type_info_type_node cp_global_trees[CPTI_TYPE_INFO_TYPE]
#define tinfo_decl_id cp_global_trees[CPTI_TINFO_DECL_ID]
#define tinfo_decl_type cp_global_trees[CPTI_TINFO_DECL_TYPE]
#define tinfo_var_id cp_global_trees[CPTI_TINFO_VAR_ID]
#define abort_fndecl cp_global_trees[CPTI_ABORT_FNDECL]
#define global_delete_fndecl cp_global_trees[CPTI_GLOBAL_DELETE_FNDECL]
@ -1173,10 +1177,19 @@ extern int flag_ansi;
extern int flag_default_inline;
/* The name-mangling scheme to use. Versions of gcc before 2.8 use
version 0. */
extern int name_mangling_version;
/* Nonzero if wchar_t should be `unsigned short' instead of whatever it
would normally be, for use with WINE. */
extern int flag_short_wchar;
/* Nonzero if squashed mangling is to be performed.
This uses the B and K codes to reference previously seen class types
and class qualifiers. */
extern int flag_do_squangling;
/* Nonzero means generate separate instantiation control files and juggle
them at link time. */
extern int flag_use_repository;
@ -3912,6 +3925,7 @@ extern void maybe_note_name_used_in_class PARAMS ((tree, tree));
extern void note_name_declared_in_class PARAMS ((tree, tree));
extern tree get_vtbl_decl_for_binfo PARAMS ((tree));
extern tree in_charge_arg_for_name PARAMS ((tree));
extern tree get_vtt_name PARAMS ((tree));
/* in cvt.c */
extern tree convert_to_reference PARAMS ((tree, tree, int, int, tree));
@ -4278,14 +4292,23 @@ extern void yyhook PARAMS ((int));
extern int cp_type_qual_from_rid PARAMS ((tree));
/* in method.c */
extern void init_method PARAMS ((void));
extern char *build_overload_name PARAMS ((tree, int, int));
extern tree build_static_name PARAMS ((tree, tree));
extern tree build_decl_overload_real PARAMS ((tree, tree, tree, tree,
tree, int));
extern void set_mangled_name_for_decl PARAMS ((tree));
extern tree build_typename_overload PARAMS ((tree));
extern tree build_overload_with_type PARAMS ((tree, tree));
extern tree build_destructor_name PARAMS ((tree));
extern tree build_opfncall PARAMS ((enum tree_code, int, tree, tree, tree));
extern tree hack_identifier PARAMS ((tree, tree));
extern tree make_thunk PARAMS ((tree, int, int));
extern void emit_thunk PARAMS ((tree));
extern void synthesize_method PARAMS ((tree));
extern tree get_id_2 PARAMS ((const char *, tree));
extern tree implicitly_declare_fn PARAMS ((special_function_kind, tree, int));
extern tree get_ctor_vtbl_name PARAMS ((tree, tree));
/* In optimize.c */
extern void optimize_function PARAMS ((tree));
@ -4724,8 +4747,6 @@ 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));
extern tree mangle_typeinfo_fn_for_type PARAMS ((tree));
extern tree mangle_java_reflection_var_for_type PARAMS ((tree));
/* -- end of C++ */

View File

@ -254,7 +254,9 @@ tree error_mark_list;
tree global_delete_fndecl;
Used by RTTI
tree type_info_type_node, tinfo_decl_type;
tree type_info_type_node, tinfo_decl_id, tinfo_decl_type;
tree tinfo_var_id;
*/
tree cp_global_trees[CPTI_MAX];
@ -2890,7 +2892,13 @@ pushtag (name, type, globalize)
VARRAY_PUSH_TREE (local_classes, type);
if (!uses_template_parms (type))
DECL_ASSEMBLER_NAME (d) = mangle_type (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)
{
@ -7618,7 +7626,8 @@ maybe_commonize_var (decl)
which we can't if it has been initialized. */
if (TREE_PUBLIC (decl))
set_mangled_name_for_decl (decl);
DECL_ASSEMBLER_NAME (decl)
= build_static_name (current_function_decl, DECL_NAME (decl));
else
{
cp_warning_at ("sorry: semantics of inline function static data `%#D' are wrong (you'll wind up with multiple copies)", decl);
@ -8968,9 +8977,9 @@ grokfndecl (ctype, type, declarator, orig_declarator, virtualp, flags, quals,
add_defarg_fn (decl);
/* Plain overloading: will not be grok'd by grokclassfn. */
if (! ctype && ! processing_template_decl
if (! ctype && ! processing_template_decl
&& !DECL_EXTERN_C_P (decl)
&& !DECL_USE_TEMPLATE (decl))
&& (! DECL_USE_TEMPLATE (decl) || name_mangling_version < 1))
set_mangled_name_for_decl (decl);
if (funcdef_flag)
@ -9085,7 +9094,13 @@ grokvardecl (type, declarator, specbits_in, initialized, constp, in_namespace)
/* DECL_ASSEMBLER_NAME is needed only for full-instantiated
templates. */
if (!uses_template_parms (decl))
DECL_ASSEMBLER_NAME (decl) = mangle_decl (decl);
{
if (flag_new_abi)
DECL_ASSEMBLER_NAME (decl) = mangle_decl (decl);
else
DECL_ASSEMBLER_NAME (decl) = build_static_name (basetype,
declarator);
}
}
else
{
@ -9110,7 +9125,13 @@ 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);
{
if (flag_new_abi)
DECL_ASSEMBLER_NAME (decl) = mangle_decl (decl);
else
DECL_ASSEMBLER_NAME (decl)
= build_static_name (context, declarator);
}
}
if (in_namespace)
@ -11145,7 +11166,24 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
DECL_NAME (CLASSTYPE_TI_TEMPLATE (type))
= TYPE_IDENTIFIER (type);
DECL_ASSEMBLER_NAME (decl) = mangle_type (type);
if (flag_new_abi)
DECL_ASSEMBLER_NAME (decl) = mangle_type (type);
else
{
/* 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. */
@ -12298,17 +12336,17 @@ grok_op_properties (decl, virtualp, friendp)
else
do
{
#define DEF_OPERATOR(NAME, CODE, MANGLING, ARITY, ASSN_P) \
if (ansi_opname (CODE) == name) \
{ \
operator_code = CODE; \
break; \
} \
else if (ansi_assopname (CODE) == name) \
{ \
operator_code = CODE; \
DECL_ASSIGNMENT_OPERATOR_P (decl) = 1; \
break; \
#define DEF_OPERATOR(NAME, CODE, NEW_MANGLING, OLD_MANGING, ARITY, ASSN_P) \
if (ansi_opname (CODE) == name) \
{ \
operator_code = CODE; \
break; \
} \
else if (ansi_assopname (CODE) == name) \
{ \
operator_code = CODE; \
DECL_ASSIGNMENT_OPERATOR_P (decl) = 1; \
break; \
}
#include "operators.def"

View File

@ -466,6 +466,11 @@ int flag_inline_trees = 0;
int max_tinst_depth = 17;
/* The name-mangling scheme to use. Must be 1 or greater to support
template functions with identical types, but different template
arguments. */
int name_mangling_version = 2;
/* Nonzero if wchar_t should be `unsigned short' instead of whatever it
would normally be, for use with WINE. */
int flag_short_wchar;
@ -547,6 +552,7 @@ lang_f_options[] =
{"permissive", &flag_permissive, 1},
{"repo", &flag_use_repository, 1},
{"rtti", &flag_rtti, 1},
{"squangle", &flag_do_squangling, 1},
{"stats", &flag_detailed_statistics, 1},
{"strict-prototype", &flag_strict_prototype, 1},
{"use-cxa-atexit", &flag_use_cxa_atexit, 1},
@ -564,8 +570,7 @@ static const char * const unsupported_options[] = {
"enum-int-equiv",
"guiding-decls",
"nonnull-objects",
"squangle",
"this-is-variable"
"this-is-variable",
};
/* Compare two option strings, pointed two by P1 and P2, for use with
@ -660,20 +665,22 @@ lang_decode_option (argc, argv)
else if (!strcmp (p, "new-abi"))
{
flag_new_abi = 1;
flag_do_squangling = 1;
flag_vtable_thunks = 1;
}
else if (!strcmp (p, "no-new-abi"))
flag_new_abi = 0;
{
flag_new_abi = 0;
flag_do_squangling = 0;
}
else if ((option_value
= skip_leading_substring (p, "template-depth-")))
max_tinst_depth
= read_integral_parameter (option_value, p - 2, max_tinst_depth);
else if ((option_value
= skip_leading_substring (p, "name-mangling-version-")))
{
warning ("-f%s is no longer supported", p);
return 1;
}
name_mangling_version
= read_integral_parameter (option_value, p - 2, name_mangling_version);
else if ((option_value
= skip_leading_substring (p, "dump-translation-unit-")))
{
@ -1097,10 +1104,16 @@ grokclassfn (ctype, function, flags, quals)
if (flags == DTOR_FLAG)
{
DECL_DESTRUCTOR_P (function) = 1;
if (flag_new_abi)
set_mangled_name_for_decl (function);
else
DECL_ASSEMBLER_NAME (function) = build_destructor_name (ctype);
TYPE_HAS_DESTRUCTOR (ctype) = 1;
}
set_mangled_name_for_decl (function);
else
set_mangled_name_for_decl (function);
}
/* Work on the expr used by alignof (this is only called by the parser). */
@ -1567,7 +1580,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) = mangle_decl (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)
{
@ -1698,7 +1715,13 @@ grokfield (declarator, declspecs, init, asmspec_tree, attrlist)
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 (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);
@ -1884,7 +1907,10 @@ grokoptypename (declspecs, declarator)
tree declspecs, declarator;
{
tree t = grokdeclarator (declarator, declspecs, TYPENAME, 0, NULL_TREE);
return mangle_conv_op_name_for_type (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,
@ -2845,7 +2871,10 @@ get_sentry (decl)
tree sname;
tree sentry;
sname = mangle_guard_variable (decl);
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

View File

@ -2138,6 +2138,9 @@ build_java_class_ref (type)
tree type;
{
tree name, class_decl;
static tree CL_prefix = NULL_TREE;
if (CL_prefix == NULL_TREE)
CL_prefix = get_identifier("_CL_");
if (jclass_node == NULL_TREE)
{
jclass_node = IDENTIFIER_GLOBAL_VALUE (get_identifier("jclass"));
@ -2145,7 +2148,7 @@ build_java_class_ref (type)
fatal("call to Java constructor, while `jclass' undefined");
jclass_node = TREE_TYPE (jclass_node);
}
name = mangle_java_reflection_var_for_type (type);
name = build_overload_with_type (CL_prefix, type);
class_decl = IDENTIFIER_GLOBAL_VALUE (name);
if (class_decl == NULL_TREE)
{

View File

@ -466,7 +466,7 @@ init_operators ()
char buffer[256];
struct operator_name_info_t *oni;
#define DEF_OPERATOR(NAME, CODE, MANGLING, ARITY, ASSN_P) \
#define DEF_OPERATOR(NAME, CODE, NEW_MANGLING, OLD_MANGLING, ARITY, ASSN_P) \
my_friendly_assert ((strlen ("operator ") + strlen (NAME) + 1 \
+ ISALPHA (NAME[0]) <= 256), \
20000526); \
@ -479,7 +479,7 @@ init_operators ()
: &operator_name_info[(int) CODE]); \
oni->identifier = identifier; \
oni->name = NAME; \
oni->mangled_name = MANGLING;
oni->mangled_name = flag_new_abi ? NEW_MANGLING : OLD_MANGLING;
#include "operators.def"
#undef DEF_OPERATOR
@ -592,7 +592,7 @@ init_parse (filename)
(LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
init_operators ();
init_mangle ();
init_method ();
init_error ();
gcc_obstack_init (&inline_text_obstack);
inline_text_firstobj = (char *) obstack_alloc (&inline_text_obstack, 0);

View File

@ -998,10 +998,8 @@ write_special_name_constructor (ctor)
write_string ("C1");
else if (DECL_BASE_CONSTRUCTOR_P (ctor))
write_string ("C2");
else if (flag_new_abi)
write_string ("C*INTERNAL*");
else
write_string ("C1");
write_string ("C*INTERNAL*");
}
/* Handle destructor productions of non-terminal <special-name>.
@ -1025,10 +1023,9 @@ write_special_name_destructor (dtor)
write_string ("D1");
else if (DECL_BASE_DESTRUCTOR_P (dtor))
write_string ("D2");
else if (flag_new_abi)
write_string ("D*INTERNAL*");
else
write_string ("D0");
/* Old-ABI destructor. */
write_string ("D*INTERNAL*");
}
/* Return the discriminator for ENTITY appearing inside
@ -1567,17 +1564,8 @@ write_expression (expr)
if (TREE_CODE (expr) == ADDR_EXPR
&& TREE_TYPE (expr)
&& TREE_CODE (TREE_TYPE (expr)) == REFERENCE_TYPE)
{
expr = TREE_OPERAND (expr, 0);
if (DECL_P (expr))
{
write_expression (expr);
return;
}
expr = TREE_OPERAND (expr, 0);
code = TREE_CODE (expr);
}
/* If it wasn't any of those, recursively expand the expression. */
write_string (operator_name_info[(int) code].mangled_name);
@ -1981,27 +1969,6 @@ mangle_typeinfo_for_type (type)
return mangle_special_for_type (type, "TI");
}
/* Return the mangled name of the function that returns the typeinfo
for TYPE. */
tree
mangle_typeinfo_fn_for_type (type)
tree type;
{
my_friendly_assert (!new_abi_rtti_p (), 20000608);
return mangle_special_for_type (type, "TF");
}
/* Return the name of the variable that represents TYPE at runtime in
Java. */
tree
mangle_java_reflection_var_for_type (type)
tree type;
{
return mangle_special_for_type (type, "TJ");
}
/* Create an identifier for the mangled name of the NTBS containing
the mangled name of TYPE. */
@ -2118,7 +2085,15 @@ mangle_thunk (fn_decl, offset, vcall_offset)
/* Return an identifier for the mangled unqualified name for a
conversion operator to TYPE. This mangling is not specified by the
ABI spec; it is only used internally. */
ABI spec; it is only used internally.
For compatibility with existing conversion operator mechanisms,
the mangled form is `__op<type>' where <type> is the mangled
representation of TYPE.
FIXME: Though identifiers with starting with __op are reserved for
the implementation, it would eventually be nice to use inaccessible
names for these operators. */
tree
mangle_conv_op_name_for_type (type)
@ -2129,10 +2104,11 @@ mangle_conv_op_name_for_type (type)
/* Build the mangling for TYPE. */
const char *mangled_type = mangle_type_string (type);
/* Allocate a temporary buffer for the complete name. */
char *op_name = (char *) xmalloc (strlen ("operator ")
char *op_name = (char *) xmalloc (strlen (OPERATOR_TYPENAME_FORMAT)
+ strlen (mangled_type) + 1);
/* Assemble the mangling. */
sprintf (op_name, "operator %s", mangled_type);
strcpy (op_name, OPERATOR_TYPENAME_FORMAT);
strcat (op_name, mangled_type);
/* Find or create an identifier. */
identifier = get_identifier (op_name);
/* Done with the temporary buffer. */

File diff suppressed because it is too large Load Diff

View File

@ -40,12 +40,16 @@ Boston, MA 02111-1307, USA. */
assignment operators, the same tree-codes are reused; i.e.,
`operator +' will also have PLUS_EXPR as its CODE.
MANGLING
NEW_MANGLING
The mangling prefix for the operator, as a C string, and as
mangled under the new ABI. For `operator +', for example, this
would be "pl".
OLD_MANGLING
Analagous, but for the old ABI.
ARITY
The arity of the operator, or -1 if any arity is allowed. (As
@ -67,84 +71,84 @@ Boston, MA 02111-1307, USA. */
arguments are as for DEF_OPERATOR, but there is no need to provide
an ASSIGNMENT_P argument; it is always zero. */
#define DEF_SIMPLE_OPERATOR(NAME, CODE, MANGLING, ARITY) \
DEF_OPERATOR(NAME, CODE, MANGLING, ARITY, 0)
#define DEF_SIMPLE_OPERATOR(NAME, CODE, NEW_MANGLING, OLD_MANGLING, ARITY) \
DEF_OPERATOR(NAME, CODE, NEW_MANGLING, OLD_MANGLING, ARITY, 0)
/* Use DEF_ASSN_OPERATOR to define an assignment operator. Its
arguments are as for DEF_OPERATOR, but there is no need to provide
an ASSIGNMENT_P argument; it is always one. */
#define DEF_ASSN_OPERATOR(NAME, CODE, MANGLING, ARITY) \
DEF_OPERATOR(NAME, CODE, MANGLING, ARITY, 1)
#define DEF_ASSN_OPERATOR(NAME, CODE, NEW_MANGLING, OLD_MANGLING, ARITY) \
DEF_OPERATOR(NAME, CODE, NEW_MANGLING, OLD_MANGLING, ARITY, 1)
/* Memory allocation operators. */
DEF_SIMPLE_OPERATOR ("new", NEW_EXPR, "nw", -1)
DEF_SIMPLE_OPERATOR ("new []", VEC_NEW_EXPR, "na", -1)
DEF_SIMPLE_OPERATOR ("delete", DELETE_EXPR, "dl", -1)
DEF_SIMPLE_OPERATOR ("delete []", VEC_DELETE_EXPR, "da", -1)
DEF_SIMPLE_OPERATOR ("new", NEW_EXPR, "nw", "__nw", -1)
DEF_SIMPLE_OPERATOR ("new []", VEC_NEW_EXPR, "na", "__vn", -1)
DEF_SIMPLE_OPERATOR ("delete", DELETE_EXPR, "dl", "__dl", -1)
DEF_SIMPLE_OPERATOR ("delete []", VEC_DELETE_EXPR, "da", "__vd", -1)
/* Unary operators. */
DEF_SIMPLE_OPERATOR ("+", CONVERT_EXPR, "ps", 1)
DEF_SIMPLE_OPERATOR ("-", NEGATE_EXPR, "ng", 1)
DEF_SIMPLE_OPERATOR ("&", ADDR_EXPR, "ad", 1)
DEF_SIMPLE_OPERATOR ("*", INDIRECT_REF, "de", 1)
DEF_SIMPLE_OPERATOR ("~", BIT_NOT_EXPR, "co", 1)
DEF_SIMPLE_OPERATOR ("!", TRUTH_NOT_EXPR, "nt", 1)
DEF_SIMPLE_OPERATOR ("++", PREINCREMENT_EXPR, "pp", 1)
DEF_SIMPLE_OPERATOR ("--", PREDECREMENT_EXPR, "mm", 1)
DEF_SIMPLE_OPERATOR ("sizeof", SIZEOF_EXPR, "sz", 1)
DEF_SIMPLE_OPERATOR ("+", CONVERT_EXPR, "ps", "__pl", 1)
DEF_SIMPLE_OPERATOR ("-", NEGATE_EXPR, "ng", "__mi", 1)
DEF_SIMPLE_OPERATOR ("&", ADDR_EXPR, "ad", "__ad", 1)
DEF_SIMPLE_OPERATOR ("*", INDIRECT_REF, "de", "__ml", 1)
DEF_SIMPLE_OPERATOR ("~", BIT_NOT_EXPR, "co", "__co", 1)
DEF_SIMPLE_OPERATOR ("!", TRUTH_NOT_EXPR, "nt", "__nt", 1)
DEF_SIMPLE_OPERATOR ("++", PREINCREMENT_EXPR, "pp", "__pp", 1)
DEF_SIMPLE_OPERATOR ("--", PREDECREMENT_EXPR, "mm", "__mm", 1)
DEF_SIMPLE_OPERATOR ("sizeof", SIZEOF_EXPR, "sz", "__sz", 1)
/* This is an extension. */
DEF_SIMPLE_OPERATOR ("alignof", ALIGNOF_EXPR, "vx7alignof", 1)
DEF_SIMPLE_OPERATOR ("alignof", ALIGNOF_EXPR, "vx7alignof", "__al", 1)
/* The cast operator. */
DEF_SIMPLE_OPERATOR ("", TYPE_EXPR, "cv", 1)
DEF_SIMPLE_OPERATOR ("", TYPE_EXPR, "cv", OPERATOR_TYPENAME_FORMAT, 1)
/* Binary operators. */
DEF_SIMPLE_OPERATOR ("+", PLUS_EXPR, "pl", 2)
DEF_SIMPLE_OPERATOR ("-", MINUS_EXPR, "mi", 2)
DEF_SIMPLE_OPERATOR ("*", MULT_EXPR, "ml", 2)
DEF_SIMPLE_OPERATOR ("/", TRUNC_DIV_EXPR, "dv", 2)
DEF_SIMPLE_OPERATOR ("%", TRUNC_MOD_EXPR, "rm", 2)
DEF_SIMPLE_OPERATOR ("&", BIT_AND_EXPR, "an", 2)
DEF_SIMPLE_OPERATOR ("|", BIT_IOR_EXPR, "or", 2)
DEF_SIMPLE_OPERATOR ("^", BIT_XOR_EXPR, "eo", 2)
DEF_SIMPLE_OPERATOR ("<<", LSHIFT_EXPR, "ls", 2)
DEF_SIMPLE_OPERATOR (">>", RSHIFT_EXPR, "rs", 2)
DEF_SIMPLE_OPERATOR ("==", EQ_EXPR, "eq", 2)
DEF_SIMPLE_OPERATOR ("!=", NE_EXPR, "ne", 2)
DEF_SIMPLE_OPERATOR ("<", LT_EXPR, "lt", 2)
DEF_SIMPLE_OPERATOR (">", GT_EXPR, "gt", 2)
DEF_SIMPLE_OPERATOR ("<=", LE_EXPR, "le", 2)
DEF_SIMPLE_OPERATOR (">=", GE_EXPR, "ge", 2)
DEF_SIMPLE_OPERATOR ("&&", TRUTH_ANDIF_EXPR, "aa", 2)
DEF_SIMPLE_OPERATOR ("||", TRUTH_ORIF_EXPR, "oo", 2)
DEF_SIMPLE_OPERATOR (",", COMPOUND_EXPR, "cm", 2)
DEF_SIMPLE_OPERATOR ("->*", MEMBER_REF, "pm", 2)
DEF_SIMPLE_OPERATOR ("->", COMPONENT_REF, "pt", 2)
DEF_SIMPLE_OPERATOR ("[]", ARRAY_REF, "ix", 2)
DEF_SIMPLE_OPERATOR ("++", POSTINCREMENT_EXPR, "pp", 2)
DEF_SIMPLE_OPERATOR ("--", POSTDECREMENT_EXPR, "mm", 2)
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, "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)
DEF_SIMPLE_OPERATOR ("<<", LSHIFT_EXPR, "ls", "__ls", 2)
DEF_SIMPLE_OPERATOR (">>", RSHIFT_EXPR, "rs", "__rs", 2)
DEF_SIMPLE_OPERATOR ("==", EQ_EXPR, "eq", "__eq", 2)
DEF_SIMPLE_OPERATOR ("!=", NE_EXPR, "ne", "__ne", 2)
DEF_SIMPLE_OPERATOR ("<", LT_EXPR, "lt", "__lt", 2)
DEF_SIMPLE_OPERATOR (">", GT_EXPR, "gt", "__gt", 2)
DEF_SIMPLE_OPERATOR ("<=", LE_EXPR, "le", "__le", 2)
DEF_SIMPLE_OPERATOR (">=", GE_EXPR, "ge", "__ge", 2)
DEF_SIMPLE_OPERATOR ("&&", TRUTH_ANDIF_EXPR, "aa", "__aa", 2)
DEF_SIMPLE_OPERATOR ("||", TRUTH_ORIF_EXPR, "oo", "__oo", 2)
DEF_SIMPLE_OPERATOR (",", COMPOUND_EXPR, "cm", "__cm", 2)
DEF_SIMPLE_OPERATOR ("->*", MEMBER_REF, "pm", "__rm", 2)
DEF_SIMPLE_OPERATOR ("->", COMPONENT_REF, "pt", "__rf", 2)
DEF_SIMPLE_OPERATOR ("[]", ARRAY_REF, "ix", "__vc", 2)
DEF_SIMPLE_OPERATOR ("++", POSTINCREMENT_EXPR, "pp", "__pp", 2)
DEF_SIMPLE_OPERATOR ("--", POSTDECREMENT_EXPR, "mm", "__mm", 2)
/* These are extensions. */
DEF_SIMPLE_OPERATOR ("<?", MIN_EXPR, "vx3min", 2)
DEF_SIMPLE_OPERATOR (">?", MAX_EXPR, "vx3max", 2)
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", 2);
DEF_SIMPLE_OPERATOR ("::", SCOPE_REF, "sr", NULL, 2);
/* Assignment operators. */
DEF_ASSN_OPERATOR ("=", NOP_EXPR, "aS", 2)
DEF_ASSN_OPERATOR ("+=", PLUS_EXPR, "pL", 2)
DEF_ASSN_OPERATOR ("-=", MINUS_EXPR, "mI", 2)
DEF_ASSN_OPERATOR ("*=", MULT_EXPR, "mL", 2)
DEF_ASSN_OPERATOR ("/=", TRUNC_DIV_EXPR, "dV", 2)
DEF_ASSN_OPERATOR ("%=", TRUNC_MOD_EXPR, "rM", 2)
DEF_ASSN_OPERATOR ("&=", BIT_AND_EXPR, "aN", 2)
DEF_ASSN_OPERATOR ("|=", BIT_IOR_EXPR, "oR", 2)
DEF_ASSN_OPERATOR ("^=", BIT_XOR_EXPR, "eO", 2)
DEF_ASSN_OPERATOR ("<<=", LSHIFT_EXPR, "lS", 2)
DEF_ASSN_OPERATOR (">>=", RSHIFT_EXPR, "rS", 2)
DEF_ASSN_OPERATOR ("=", NOP_EXPR, "aS", "__as", 2)
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, "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)
DEF_ASSN_OPERATOR ("<<=", LSHIFT_EXPR, "lS", "__als", 2)
DEF_ASSN_OPERATOR (">>=", RSHIFT_EXPR, "rS", "__ars", 2)
/* Ternary operators. */
DEF_SIMPLE_OPERATOR ("?:", COND_EXPR, "qu", 3)
DEF_SIMPLE_OPERATOR ("?:", COND_EXPR, "qu", "__cn", 3)
/* Miscellaneous. */
DEF_SIMPLE_OPERATOR ("()", CALL_EXPR, "cl", -1)
DEF_SIMPLE_OPERATOR ("()", CALL_EXPR, "cl", "__cl", -1)

View File

@ -143,6 +143,7 @@ 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, tree));
@ -1556,8 +1557,9 @@ check_explicit_specialization (declarator, decl, template_count, flags)
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_decl (decl);
if ((is_member_template (tmpl) || ctype == NULL_TREE)
&& name_mangling_version >= 1)
set_mangled_name_for_template_decl (decl);
if (is_friend && !have_def)
/* This is not really a declaration of a specialization.
@ -4077,7 +4079,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) = mangle_decl (type_decl);
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
@ -4503,10 +4509,11 @@ tsubst_friend_function (decl, args)
DECL_USE_TEMPLATE (DECL_TEMPLATE_RESULT (new_friend)) = 0;
/* The mangled name for the NEW_FRIEND is incorrect. The call to
tsubst will have resulted in a call to set_mangled_name_for_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
tsubst will have resulted in a call to
set_mangled_name_for_template_decl. But, the function is not a
template instantiation and should not be mangled like one.
Therefore, we remangle the function name. We don't have to do
this if the NEW_FRIEND is a template since
set_mangled_name_for_template_decl doesn't do anything if the
function declaration still uses template arguments. */
if (TREE_CODE (new_friend) != TEMPLATE_DECL)
@ -5697,9 +5704,14 @@ tsubst_decl (t, args, type, in_decl)
/*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) = mangle_conv_op_name_for_type (TREE_TYPE (type));
{
/* 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);
@ -5733,7 +5745,30 @@ tsubst_decl (t, args, type, in_decl)
register_specialization (r, gen_tmpl, argvec);
/* Set the mangled name for R. */
set_mangled_name_for_decl (r);
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
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 (name_mangling_version < 1
|| 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);
}
DECL_RTL (r) = 0;
make_decl_rtl (r, NULL_PTR, 1);
@ -7050,7 +7085,10 @@ tsubst_copy (t, args, complain, in_decl)
if (IDENTIFIER_TYPENAME_P (t))
{
tree new_type = tsubst (TREE_TYPE (t), args, complain, in_decl);
return mangle_conv_op_name_for_type (new_type);
if (flag_new_abi)
return mangle_conv_op_name_for_type (new_type);
else
return (build_typename_overload (new_type));
}
else
return t;
@ -9962,3 +10000,97 @@ 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;
{
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);
targs = INNERMOST_TEMPLATE_ARGS (targs);
ret_type = TREE_TYPE (fn_type);
parm_types = TYPE_ARG_TYPES (fn_type);
/* For a static member function, we generate a fake `this' pointer,
for the purposes of mangling. This indicates of which class the
function is a member. Because of:
[class.static]
There shall not be a static and a nonstatic member function
with the same name and the same parameter types
we don't have to worry that this will result in a clash with a
non-static member function. */
if (DECL_STATIC_FUNCTION_P (decl))
parm_types = hash_tree_chain (build_pointer_type (context), parm_types);
/* There should be the same number of template parameters as
template arguments. */
my_friendly_assert (TREE_VEC_LENGTH (tparms) == TREE_VEC_LENGTH (targs),
0);
/* 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));
}

View File

@ -83,22 +83,29 @@ void
init_rtti_processing ()
{
if (flag_honor_std)
push_namespace (std_identifier);
push_namespace (get_identifier ("std"));
type_info_type_node = xref_tag
(class_type_node, get_identifier ("type_info"), 1);
if (flag_honor_std)
pop_namespace ();
if (!new_abi_rtti_p ())
{
tinfo_decl_id = get_identifier ("__tf");
tinfo_decl_type = build_function_type
(build_reference_type
(build_qualified_type
(type_info_type_node, TYPE_QUAL_CONST)),
void_list_node);
tinfo_var_id = get_identifier ("__ti");
}
else
tinfo_decl_type = build_qualified_type
(type_info_type_node, TYPE_QUAL_CONST);
{
/* FIXME: These identifier prefixes are not set in stone yet. */
tinfo_decl_id = get_identifier ("__ti");
tinfo_var_id = get_identifier ("__tn");
tinfo_decl_type = build_qualified_type
(type_info_type_node, TYPE_QUAL_CONST);
}
}
/* Given a pointer to an object with at least one virtual table
@ -326,12 +333,11 @@ static tree
get_tinfo_var (type)
tree type;
{
tree tname;
tree tname = build_overload_with_type (tinfo_var_id, type);
tree arrtype;
int size;
my_friendly_assert (!new_abi_rtti_p (), 20000118);
tname = mangle_typeinfo_for_type (type);
if (IDENTIFIER_GLOBAL_VALUE (tname))
return IDENTIFIER_GLOBAL_VALUE (tname);
@ -367,7 +373,6 @@ get_tinfo_var (type)
}
/* Generate the NTBS name of a type. */
static tree
tinfo_name (type)
tree type;
@ -375,7 +380,10 @@ tinfo_name (type)
const char *name;
tree name_string;
name = mangle_type_string (type);
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;
}
@ -401,10 +409,11 @@ get_tinfo_decl (type)
type = build_function_type (TREE_TYPE (type),
TREE_CHAIN (TYPE_ARG_TYPES (type)));
if (new_abi_rtti_p ())
if (flag_new_abi)
name = mangle_typeinfo_for_type (type);
else
name = mangle_typeinfo_fn_for_type (type);
name = build_overload_with_type (tinfo_decl_id, type);
d = IDENTIFIER_GLOBAL_VALUE (name);
if (d)
/* OK */;
@ -1306,7 +1315,10 @@ tinfo_base_init (desc, target)
NULL_TREE);
tree name_string = tinfo_name (target);
name_name = mangle_typeinfo_for_type (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;
@ -1315,8 +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)
= mangle_typeinfo_string_for_type (target);
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);
}
@ -1682,7 +1699,9 @@ create_real_tinfo_var (name, type, init, non_public)
tree hidden_name;
char hidden[30];
sprintf (hidden, "tinfo var %d", count++);
sprintf (hidden, "%.*s_%d",
IDENTIFIER_LENGTH (tinfo_decl_id), IDENTIFIER_POINTER (tinfo_decl_id),
count++);
hidden_name = get_identifier (hidden);
decl = build_lang_decl (VAR_DECL, hidden_name,

View File

@ -436,17 +436,17 @@ __dynamic_cast_2 (const type_info& (*from)(void), const type_info& (*to)(void),
// must match the mangling in gcc/cp/rtti.c.
#define BUILTIN(mangled) \
unsigned char _ZTI##mangled [sizeof (__builtin_type_info)] \
unsigned char __ti##mangled [sizeof (__builtin_type_info)] \
__attribute__ ((aligned (__alignof__ (void *)))); \
extern "C" const type_info &_ZTF##mangled (void) { \
if ((*(void **) _ZTI##mangled) == 0) \
new (_ZTI##mangled) __builtin_type_info (#mangled); \
return *(type_info *)_ZTI##mangled; \
extern "C" const type_info &__tf##mangled (void) { \
if ((*(void **) __ti##mangled) == 0) \
new (__ti##mangled) __builtin_type_info (#mangled); \
return *(type_info *)__ti##mangled; \
}
BUILTIN (v); BUILTIN (x); BUILTIN (l); BUILTIN (i); BUILTIN (s); BUILTIN (b);
BUILTIN (c); BUILTIN (w); BUILTIN (e); BUILTIN (d); BUILTIN (f);
BUILTIN (j); BUILTIN (m); BUILTIN (y); BUILTIN (t); BUILTIN (h);
BUILTIN (a);
BUILTIN (c); BUILTIN (w); BUILTIN (r); BUILTIN (d); BUILTIN (f);
BUILTIN (Ui); BUILTIN (Ul); BUILTIN (Ux); BUILTIN (Us); BUILTIN (Uc);
BUILTIN (Sc);
#endif

View File

@ -111,7 +111,7 @@ in the following sections.
-fhuge-objects -fno-implicit-templates -finit-priority
-fno-implement-inlines -fname-mangling-version-@var{n}
-fno-default-inline -fno-operator-names -fno-optional-diags -fpermissive
-frepo -fstrict-prototype -ftemplate-depth-@var{n}
-frepo -fstrict-prototype -fsquangle -ftemplate-depth-@var{n}
-fuse-cxa-atexit -fvtable-thunks -nostdinc++ -Wctor-dtor-privacy
-Wno-deprecated -Weffc++ -Wno-non-template-friend -Wnon-virtual-dtor
-Wold-style-cast -Woverloaded-virtual -Wno-pmf-conversions -Wreorder
@ -1155,6 +1155,20 @@ errors if these functions are not inlined everywhere they are called.
Disable pedwarns about constructs used in MFC, such as implicit int and
getting a pointer to member function via non-standard syntax.
@item -fname-mangling-version-@var{n}
Control the way in which names are mangled. Version 0 is compatible
with versions of g++ before 2.8. Version 1 is the default. Version 1
will allow correct mangling of function templates. For example,
version 0 mangling does not mangle foo<int, double> and foo<int, char>
given this declaration:
@example
template <class T, class U> void foo(T t);
@end example
Like all options that change the ABI, all C++ code, @emph{including
libgcc} must be built with the same setting of this option.
@item -fno-operator-names
Do not treat the operator name keywords @code{and}, @code{bitand},
@code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
@ -1197,6 +1211,18 @@ functions.
This flag no longer affects declarations with C++ linkage.
@item -fsquangle
@itemx -fno-squangle
@samp{-fsquangle} will enable a compressed form of name mangling for
identifiers. In particular, it helps to shorten very long names by recognizing
types and class names which occur more than once, replacing them with special
short ID codes. This option also requires any C++ libraries being used to
be compiled with this option as well. The compiler has this disabled (the
equivalent of @samp{-fno-squangle}) by default.
Like all options that change the ABI, all C++ code, @emph{including
libgcc.a} must be built with the same setting of this option.
@item -ftemplate-depth-@var{n}
Set the maximum instantiation depth for template classes to @var{n}.
A limit on the template instantiation depth is needed to detect