From 6397d80b752df0770438e1edbc1efd8773fbb7eb Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Fri, 4 Oct 2002 04:59:39 +0000 Subject: [PATCH] re PR c++/8006 (ice in mangle_conv_op_name_for_type boost regression) * doc/invoke.texi (-Wabi): Document mangling bug. PR c++/8006 * mangle.c (CLASSTYPE_TEMPLATE_ID_P): Handle instances of template template parameters. (globals): Add entity and need_abi_warning. (decl_is_template_id): Use TYPE_TEMPLATE_INFO, not CLASSTYPE_TEMPLATE_INFO. (is_std_substitution): Use CLASSTYPE_TI_TEMPLATE, not TYPE_TI_TEMPLATE. (write_prefix): Handle typename types correctly. (write_template_prefix): Handle template template parameters correctly. (start_mangling): Add entity parameter. (finish_mangling): Warn about names whose mangling will change. (mangle_decl_string): Adjust. (mangle_type_string): Likewise. (mangle_special_for_type): Likewise. (mangle_ctor_vtbl_for_type): Likewise. (mangle_thunk): Likewise. (mangle_guard_variable): Likewise. (mangle_ref_init_variable): Likewise. PR c++/8006 * g++.dg/abi/mangle9.C: New test. * g++.dg/abi/mangle10.C: New test. * g++.dg/abi/mangle11.C: New test. * g++.dg/abi/mangle12.C: New test. From-SVN: r57799 --- gcc/ChangeLog | 4 ++ gcc/cp/ChangeLog | 23 ++++++ gcc/cp/mangle.c | 107 +++++++++++++++++++--------- gcc/doc/invoke.texi | 15 ++++ gcc/testsuite/ChangeLog | 8 +++ gcc/testsuite/g++.dg/abi/mangle10.C | 13 ++++ gcc/testsuite/g++.dg/abi/mangle11.C | 10 +++ gcc/testsuite/g++.dg/abi/mangle12.C | 11 +++ gcc/testsuite/g++.dg/abi/mangle9.C | 12 ++++ 9 files changed, 168 insertions(+), 35 deletions(-) create mode 100644 gcc/testsuite/g++.dg/abi/mangle10.C create mode 100644 gcc/testsuite/g++.dg/abi/mangle11.C create mode 100644 gcc/testsuite/g++.dg/abi/mangle12.C create mode 100644 gcc/testsuite/g++.dg/abi/mangle9.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ffd1b531762..a664139beb4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2002-10-03 Mark Mitchell + + * doc/invoke.texi (-Wabi): Document mangling bug. + 2002-10-04 Alan Modra * config/rs6000/rs6000.c (rs6000_output_function_epilogue): Use a diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 521b4971ce1..f10a56466b9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,26 @@ +2002-10-03 Mark Mitchell + + PR c++/8006 + * mangle.c (CLASSTYPE_TEMPLATE_ID_P): Handle instances of template + template parameters. + (globals): Add entity and need_abi_warning. + (decl_is_template_id): Use TYPE_TEMPLATE_INFO, not + CLASSTYPE_TEMPLATE_INFO. + (is_std_substitution): Use CLASSTYPE_TI_TEMPLATE, not + TYPE_TI_TEMPLATE. + (write_prefix): Handle typename types correctly. + (write_template_prefix): Handle template template parameters + correctly. + (start_mangling): Add entity parameter. + (finish_mangling): Warn about names whose mangling will change. + (mangle_decl_string): Adjust. + (mangle_type_string): Likewise. + (mangle_special_for_type): Likewise. + (mangle_ctor_vtbl_for_type): Likewise. + (mangle_thunk): Likewise. + (mangle_guard_variable): Likewise. + (mangle_ref_init_variable): Likewise. + 2002-10-02 Mark Mitchell PR c++/7188. diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index c7bd31299db..76fd5f7e425 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -80,10 +80,11 @@ that hard to distinguish A from A, where A is the type as instantiated outside of the template, and A is the type used without parameters inside the template. */ -#define CLASSTYPE_TEMPLATE_ID_P(NODE) \ - (TYPE_LANG_SPECIFIC (NODE) != NULL \ - && CLASSTYPE_TEMPLATE_INFO (NODE) != NULL \ - && (PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (NODE)))) +#define CLASSTYPE_TEMPLATE_ID_P(NODE) \ + (TYPE_LANG_SPECIFIC (NODE) != NULL \ + && (TREE_CODE (NODE) == BOUND_TEMPLATE_TEMPLATE_PARM \ + || (CLASSTYPE_TEMPLATE_INFO (NODE) != NULL \ + && (PRIMARY_TEMPLATE_P (CLASSTYPE_TI_TEMPLATE (NODE)))))) /* Things we only need one of. This module is not reentrant. */ static struct globals @@ -95,10 +96,17 @@ static struct globals we've seen them. */ varray_type substitutions; + /* The entity that is being mangled. */ + tree entity; + /* We are mangling an internal symbol. It is important to keep those involving template parmeters distinct by distinguishing their level and, for non-type parms, their type. */ bool internal_mangling_p; + + /* True if the mangling will be different in a future version of the + ABI. */ + bool need_abi_warning; } G; /* Indices into subst_identifiers. These are identifiers used in @@ -192,8 +200,8 @@ static const char *mangle_decl_string PARAMS ((tree)); /* Control functions. */ -static inline void start_mangling PARAMS ((void)); -static inline const char *finish_mangling PARAMS ((void)); +static inline void start_mangling (tree); +static inline const char *finish_mangling (bool); static tree mangle_special_for_type PARAMS ((tree, const char *)); /* Foreign language functions. */ @@ -250,7 +258,7 @@ decl_is_template_id (decl, template_info) if (template_info != NULL) /* For a templated TYPE_DECL, the template info is hanging off the type. */ - *template_info = CLASSTYPE_TEMPLATE_INFO (type); + *template_info = TYPE_TEMPLATE_INFO (type); return 1; } } @@ -398,8 +406,8 @@ is_std_substitution (node, index) return (DECL_NAMESPACE_STD_P (CP_DECL_CONTEXT (decl)) && TYPE_LANG_SPECIFIC (type) - && CLASSTYPE_TEMPLATE_INFO (type) - && (DECL_NAME (CLASSTYPE_TI_TEMPLATE (type)) + && TYPE_TEMPLATE_INFO (type) + && (DECL_NAME (TYPE_TI_TEMPLATE (type)) == subst_identifiers[index])); } @@ -837,7 +845,8 @@ write_nested_name (decl) write_char ('E'); } -/* ::= > +/* ::= + ::= ::= ::= # empty ::= */ @@ -860,7 +869,6 @@ write_prefix (node) return; if (DECL_P (node)) - /* Node is a decl. */ { /* If this is a function decl, that means we've hit function scope, so this prefix must be for a local name. In this @@ -874,14 +882,22 @@ write_prefix (node) decl_is_template_id (decl, &template_info); } else - /* Node is a type. */ { + /* Node is a type. */ decl = TYPE_NAME (node); if (CLASSTYPE_TEMPLATE_ID_P (node)) - template_info = CLASSTYPE_TEMPLATE_INFO (node); + template_info = TYPE_TEMPLATE_INFO (node); } - if (template_info != NULL) + /* In G++ 3.2, the name of the template parameter was used. */ + if (TREE_CODE (node) == TEMPLATE_TYPE_PARM + && !abi_version_at_least (2)) + G.need_abi_warning = true; + + if (TREE_CODE (node) == TEMPLATE_TYPE_PARM + && abi_version_at_least (2)) + write_template_param (node); + else if (template_info != NULL) /* Templated. */ { write_template_prefix (decl); @@ -898,6 +914,7 @@ write_prefix (node) } /* ::=