summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/exception.cc10
-rw-r--r--test/test_exception.cc19
2 files changed, 28 insertions, 1 deletions
diff --git a/src/exception.cc b/src/exception.cc
index 272bf30..e0d32da 100644
--- a/src/exception.cc
+++ b/src/exception.cc
@@ -901,6 +901,16 @@ extern "C" void __cxa_call_unexpected(void*exception)
abort();
}
+/**
+ * ABI function, returns the adjusted pointer to the exception object.
+ */
+extern "C" void *__cxa_get_exception_ptr(void *exceptionObject) {
+ // exceptionObject is the pointer to the _Unwind_Exception within the
+ // __cxa_exception. The throw object is after this
+ return ((char*)exceptionObject + sizeof(_Unwind_Exception));
+}
+
+
namespace std
{
unexpected_handler set_unexpected(unexpected_handler f) throw()
diff --git a/test/test_exception.cc b/test/test_exception.cc
index 8149fbf..eb738ba 100644
--- a/test/test_exception.cc
+++ b/test/test_exception.cc
@@ -29,6 +29,16 @@ struct bar : foo
};
+/**
+ * Non-pod type to test throwing
+ */
+class non_pod {
+public:
+ non_pod(int i): x(i) {}
+ int x;
+};
+
+
static int cleanup_count;
/**
* Simple structure declared with a destructor. Destroying this object will
@@ -59,11 +69,12 @@ int inner(int i)
case 2: fprintf(stderr, "Throwing int64_t\n");throw (int64_t)1;
case 3: { foo f = {2} ; throw f; }
case 4: { bar f; f.i = 2 ; f.bar=1 ; throw f; }
+ case 5: throw non_pod(3);
}
return -1;
}
-int outer(int i) throw(float, int, foo)
+int outer(int i) throw(float, int, foo, non_pod)
{
//CLEANUP
inner(i);
@@ -97,6 +108,11 @@ static void test_catch(int s)
TEST((s == 3 || s == 4) && f.i == 2, "Caught struct");
return;
}
+ catch (non_pod np) {
+ fprintf(stderr, "Caught non_pod {%d}!\n", np.x);
+ TEST(s == 5 && np.x == 3, "Caught non_pod");
+ return;
+ }
//abort();
TEST(0, "Unreachable line reached");
}
@@ -153,6 +169,7 @@ void test_exceptions(void)
TEST_CLEANUP(test_catch(1));
TEST_CLEANUP(test_catch(3));
TEST_CLEANUP(test_catch(4));
+ TEST_CLEANUP(test_catch(5));
TEST_CLEANUP(test_nested());
try{
test_catch(2);