This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
C++ PATCH: Rename __pure_virtual and friends
- To: gcc-patches at gcc dot gnu dot org
- Subject: C++ PATCH: Rename __pure_virtual and friends
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Sun, 19 Nov 2000 13:07:48 -0800
- Organization: CodeSourcery, LLC
The new ABI mandates names for a few functions in the G++ runtime
library that hadn't yet been converted. This patch effects the
changes.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
2000-11-19 Mark Mitchell <mark@codesourcery.com>
* decl.c (init_decl_processing): Correct name of pure virtual
function under the new ABI.
* rtti.c (throw_bad_cast): Likewise, for bad cast function.
(throw_bad_typeid): Likewise for bad typeid function.
2000-11-19 Mark Mitchell <mark@codesourcery.com>
* libsupc++/exception_support.cc (__throw_bad_cast): Name it
__cxa_bad_cast under the new ABI.
(__throw_bad_typeid): Name it __cxa_bad_typeid under the new ABI.
* libsupc++/pure.cc (__pure_virtual): Name it __cxa_pure_virtual
under the new ABI.
Index: gcc/cp/decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v
retrieving revision 1.715
diff -c -p -r1.715 decl.c
*** decl.c 2000/11/19 04:56:44 1.715
--- decl.c 2000/11/19 21:00:52
*************** init_decl_processing ()
*** 6656,6662 ****
}
abort_fndecl
! = build_library_fn_ptr ("__pure_virtual", void_ftype);
/* Perform other language dependent initializations. */
init_class_processing ();
--- 6656,6665 ----
}
abort_fndecl
! = build_library_fn_ptr ((flag_new_abi
! ? "__cxa_pure_virtual"
! : "__pure_virtual"),
! void_ftype);
/* Perform other language dependent initializations. */
init_class_processing ();
Index: gcc/cp/rtti.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/rtti.c,v
retrieving revision 1.103
diff -c -p -r1.103 rtti.c
*** rtti.c 2000/10/18 18:59:04 1.103
--- rtti.c 2000/11/19 21:00:53
*************** build_headof (exp)
*** 182,188 ****
static tree
throw_bad_cast ()
{
! tree fn = get_identifier ("__throw_bad_cast");
if (IDENTIFIER_GLOBAL_VALUE (fn))
fn = IDENTIFIER_GLOBAL_VALUE (fn);
else
--- 182,190 ----
static tree
throw_bad_cast ()
{
! tree fn = get_identifier (flag_new_abi
! ? "__cxa_bad_cast" :
! "__throw_bad_cast");
if (IDENTIFIER_GLOBAL_VALUE (fn))
fn = IDENTIFIER_GLOBAL_VALUE (fn);
else
*************** throw_bad_cast ()
*** 195,201 ****
static tree
throw_bad_typeid ()
{
! tree fn = get_identifier ("__throw_bad_typeid");
if (IDENTIFIER_GLOBAL_VALUE (fn))
fn = IDENTIFIER_GLOBAL_VALUE (fn);
else
--- 197,205 ----
static tree
throw_bad_typeid ()
{
! tree fn = get_identifier (flag_new_abi
! ? "__cxa_bad_typeid"
! : "__throw_bad_typeid");
if (IDENTIFIER_GLOBAL_VALUE (fn))
fn = IDENTIFIER_GLOBAL_VALUE (fn);
else
Index: libstdc++-v3/libsupc++/exception_support.cc
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/libsupc++/exception_support.cc,v
retrieving revision 1.3
diff -c -p -r1.3 exception_support.cc
*** exception_support.cc 2000/11/19 02:22:53 1.3
--- exception_support.cc 2000/11/19 21:00:57
*************** __check_null_eh_spec (void)
*** 348,362 ****
// Helpers for rtti. Although these don't return, we give them return types so
// that the type system is not broken.
extern "C" void *
! __throw_bad_cast ()
{
throw std::bad_cast ();
return 0;
}
extern "C" std::type_info const &
! __throw_bad_typeid ()
{
throw std::bad_typeid ();
return typeid (void);
--- 348,370 ----
// Helpers for rtti. Although these don't return, we give them return types so
// that the type system is not broken.
+ #if !defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100
+ #define THROW_BAD_CAST __throw_bad_cast
+ #define THROW_BAD_TYPEID __throw_bad_typeid
+ #else
+ #define THROW_BAD_CAST __cxa_bad_cast
+ #define THROW_BAD_TYPEID __cxa_bad_typeid
+ #endif
+
extern "C" void *
! THROW_BAD_CAST ()
{
throw std::bad_cast ();
return 0;
}
extern "C" std::type_info const &
! THROW_BAD_TYPEID ()
{
throw std::bad_typeid ();
return typeid (void);
Index: libstdc++-v3/libsupc++/pure.cc
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/libsupc++/pure.cc,v
retrieving revision 1.2
diff -c -p -r1.2 pure.cc
*** pure.cc 2000/10/10 23:50:39 1.2
--- pure.cc 2000/11/19 21:00:57
*************** extern "C" {
*** 46,53 ****
extern void __terminate(void) __attribute__ ((__noreturn__));
void
! __pure_virtual (void)
{
writestr ("pure virtual method called\n");
__terminate ();
--- 46,61 ----
extern void __terminate(void) __attribute__ ((__noreturn__));
+ // The name of the function to be placed in vtables in place of a pure
+ // virtual function is different in the two ABIs.
+ #if !defined(__GXX_ABI_VERSION) || __GXX_ABI_VERSION < 100
+ #define PURE_VIRTUAL_NAME __pure_virtual
+ #else
+ #define PURE_VIRTUAL_NAME __cxa_pure_virtual
+ #endif
+
void
! PURE_VIRTUAL_NAME (void)
{
writestr ("pure virtual method called\n");
__terminate ();