This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: Obscure new-abi mangling bug
- To: gcc-patches at gcc dot gnu dot org
- Subject: C++ PATCH: Obscure new-abi mangling bug
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Thu, 16 Nov 2000 14:35:33 -0800
- Organization: CodeSourcery, LLC
This fixes an obscure bug involving the mangling of local statics in
constructors or destructors under the new ABI.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
2000-11-16 Mark Mitchell <mark@codesourcery.com>
* mangle.c (write_special_name_constructor): Don't generate
assembler junk when confronted with an old-style constructor.
(write_special_name_destructor): Likewise.
(mangle_decl_string): Do it here instead.
Index: mangle.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/mangle.c,v
retrieving revision 1.18
diff -c -p -r1.18 mangle.c
*** mangle.c 2000/09/05 00:57:56 1.18
--- mangle.c 2000/11/16 22:32:21
*************** static void
*** 1077,1088 ****
write_special_name_constructor (ctor)
tree ctor;
{
! if (DECL_COMPLETE_CONSTRUCTOR_P (ctor))
write_string ("C1");
else if (DECL_BASE_CONSTRUCTOR_P (ctor))
write_string ("C2");
else
! write_string ("C*INTERNAL*");
}
/* Handle destructor productions of non-terminal <special-name>.
--- 1077,1092 ----
write_special_name_constructor (ctor)
tree ctor;
{
! if (DECL_COMPLETE_CONSTRUCTOR_P (ctor)
! /* Even though we don't ever emit a definition of the
! old-style destructor, we still have to consider entities
! (like static variables) nested inside it. */
! || DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (ctor))
write_string ("C1");
else if (DECL_BASE_CONSTRUCTOR_P (ctor))
write_string ("C2");
else
! my_friendly_abort (20001115);
}
/* Handle destructor productions of non-terminal <special-name>.
*************** write_special_name_destructor (dtor)
*** 1102,1114 ****
{
if (DECL_DELETING_DESTRUCTOR_P (dtor))
write_string ("D0");
! else if (DECL_COMPLETE_DESTRUCTOR_P (dtor))
write_string ("D1");
else if (DECL_BASE_DESTRUCTOR_P (dtor))
write_string ("D2");
else
! /* Old-ABI destructor. */
! write_string ("D*INTERNAL*");
}
/* Return the discriminator for ENTITY appearing inside
--- 1106,1121 ----
{
if (DECL_DELETING_DESTRUCTOR_P (dtor))
write_string ("D0");
! else if (DECL_COMPLETE_DESTRUCTOR_P (dtor)
! /* Even though we don't ever emit a definition of the
! old-style destructor, we still have to consider entities
! (like static variables) nested inside it. */
! || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (dtor))
write_string ("D1");
else if (DECL_BASE_DESTRUCTOR_P (dtor))
write_string ("D2");
else
! my_friendly_abort (20001115);
}
/* Return the discriminator for ENTITY appearing inside
*************** mangle_decl_string (decl)
*** 2002,2008 ****
if (TREE_CODE (decl) == TYPE_DECL)
write_type (TREE_TYPE (decl));
else
! write_mangled_name (decl);
result = finish_mangling ();
if (DEBUG_MANGLE)
--- 2009,2024 ----
if (TREE_CODE (decl) == TYPE_DECL)
write_type (TREE_TYPE (decl));
else
! {
! write_mangled_name (decl);
! if (DECL_LANG_SPECIFIC (decl)
! && (DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (decl)
! || DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl)))
! /* We need a distinct mangled name for these entities, but
! we should never actually output it. So, we append some
! characters the assembler won't like. */
! write_string (" *INTERNAL* ");
! }
result = finish_mangling ();
if (DEBUG_MANGLE)