aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Sidwell <nathan@codesourcery.com>2000-04-09 16:05:16 +0000
committerNathan Sidwell <nathan@gcc.gnu.org>2000-04-09 16:05:16 +0000
commitb8c1233b5e3d2cdc5ab6db633195675b98ee515a (patch)
treeef3a8297733946b1a8fa48aa5d31a200239f8ac3
parent7e2d247261b874a7cf47f0b91b548a46107b6b44 (diff)
downloadgcc-b8c1233b5e3d2cdc5ab6db633195675b98ee515a.zip
gcc-b8c1233b5e3d2cdc5ab6db633195675b98ee515a.tar.gz
gcc-b8c1233b5e3d2cdc5ab6db633195675b98ee515a.tar.bz2
vec.cc: Include <new> and <exception>.
* vec.cc: Include <new> and <exception>. (__cxa_vec_ctor): Use __cxa_vec_dtor for cleanup. (__cxa_vec_dtor): Catch dtor exceptions, and rethrow or terminate. (__cxa_vec_delete): Catch dtor exceptions. From-SVN: r33042
-rw-r--r--gcc/cp/ChangeLog8
-rw-r--r--gcc/cp/vec.cc55
2 files changed, 46 insertions, 17 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f76ef39..3457d8e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,13 @@
2000-04-09 Nathan Sidwell <nathan@codesourcery.com>
+ * vec.cc: Include <new> and <exception>.
+ (__cxa_vec_ctor): Use __cxa_vec_dtor for cleanup.
+ (__cxa_vec_dtor): Catch dtor exceptions, and rethrow or
+ terminate.
+ (__cxa_vec_delete): Catch dtor exceptions.
+
+2000-04-09 Nathan Sidwell <nathan@codesourcery.com>
+
Prepend __ to implementation defined names.
* inc/typeinfo (type_info): Rename _name to __name.
(type_info::type_info): Rename parameter.
diff --git a/gcc/cp/vec.cc b/gcc/cp/vec.cc
index 3b5182c..4f5ce49 100644
--- a/gcc/cp/vec.cc
+++ b/gcc/cp/vec.cc
@@ -27,6 +27,12 @@
#if defined(__GXX_ABI_VERSION) && __GXX_ABI_VERSION >= 100
#include <cxxabi.h>
+#include <new>
+#include <exception>
+
+// Exception handling hook, to mark current exception as not caught --
+// generally because we're about to rethrow it after some cleanup.
+extern "C" void __uncatch_exception (void);
namespace __cxxabiv1
{
@@ -54,6 +60,7 @@ __cxa_vec_new (size_t element_count,
}
catch (...)
{
+ // operator delete [] cannot throw, so no need to protect it
operator delete[] (base - padding_size);
throw;
}
@@ -79,18 +86,8 @@ __cxa_vec_ctor (void *array_address,
}
catch (...)
{
- try
- {
- if (destructor)
- for (; ix--; ptr -= element_size)
- destructor (ptr);
- }
- catch (...)
- {
- // [except.ctor]/3 If a destructor called during stack unwinding
- // exists with an exception, terminate is called.
- std::terminate ();
- }
+ __uncatch_exception ();
+ __cxa_vec_dtor (array_address, ix, element_size, destructor);
throw;
}
}
@@ -105,13 +102,28 @@ __cxa_vec_dtor (void *array_address,
if (destructor)
{
char *ptr = static_cast <char *> (array_address);
+ size_t ix = element_count;
+ bool unwinding = std::uncaught_exception ();
ptr += element_count * element_size;
- for (size_t ix = element_count; ix--;)
+ try
+ {
+ while (ix--)
+ {
+ ptr -= element_size;
+ destructor (ptr);
+ }
+ }
+ catch (...)
{
- ptr -= element_size;
- destructor (ptr);
+ if (unwinding)
+ // [except.ctor]/3 If a destructor called during stack unwinding
+ // exists with an exception, terminate is called.
+ std::terminate ();
+ __uncatch_exception ();
+ __cxa_vec_dtor (array_address, ix, element_size, destructor);
+ throw;
}
}
}
@@ -128,9 +140,18 @@ __cxa_vec_delete (void *array_address,
if (padding_size)
{
size_t element_count = reinterpret_cast <size_t *> (base)[-1];
-
- __cxa_vec_dtor (base, element_count, element_size, destructor);
base -= padding_size;
+ try
+ {
+ __cxa_vec_dtor (array_address, element_count, element_size,
+ destructor);
+ }
+ catch (...)
+ {
+ // operator delete [] cannot throw, so no need to protect it
+ operator delete[] (base);
+ throw;
+ }
}
operator delete[] (base);
}