summaryrefslogtreecommitdiff
path: root/gcc/testsuite/objc
diff options
context:
space:
mode:
authorayers <ayers@138bc75d-0d04-0410-961f-82ee72b054a4>2009-03-12 22:28:15 +0000
committerayers <ayers@138bc75d-0d04-0410-961f-82ee72b054a4>2009-03-12 22:28:15 +0000
commit5d727e51c5e237f9048d1a78ce23559839e46f6a (patch)
tree53acb0e9cd94a0ada09c499da8ecc1b24cdba655 /gcc/testsuite/objc
parent1f477a18c46bb6c3901cb019cd1bfdd8242dc2aa (diff)
downloadgcc-5d727e51c5e237f9048d1a78ce23559839e46f6a.tar.gz
libobjc/
2009-03-12 Richard Frith-Macdonald <rfm@gnu.org> David Ayers <ayers@fsfe.org> PR libobjc/27466 * objc/objc-api.h (_objc_unexpected_exception): Declare new hook. Update copyright dates. * exception.c (objc_exception_throw): Use hook. Update copyright dates. * libobjc.def (_objc_unexpected_exception): Export hook. Update copyright dates. gcc/testsuite/ 2009-03-12 David Ayers <ayers@fsfe.org> PR libobjc/27466 * objc/execute/exceptions/handler-1.m. New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@144826 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/testsuite/objc')
-rw-r--r--gcc/testsuite/objc/execute/exceptions/handler-1.m38
1 files changed, 38 insertions, 0 deletions
diff --git a/gcc/testsuite/objc/execute/exceptions/handler-1.m b/gcc/testsuite/objc/execute/exceptions/handler-1.m
new file mode 100644
index 00000000000..9cd8df19c44
--- /dev/null
+++ b/gcc/testsuite/objc/execute/exceptions/handler-1.m
@@ -0,0 +1,38 @@
+/* Test custom exception handlers */
+/* Author: David Ayers */
+
+#include <objc/objc-api.h>
+#include <objc/Object.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static unsigned int handlerExpected = 0;
+
+void
+my_exception_handler(id excp)
+{
+ /* Returning from the handler would abort. */
+ if (handlerExpected)
+ exit(0);
+
+ abort();
+}
+
+int
+main(int argc, char *argv[])
+{
+ _objc_unexpected_exception = my_exception_handler;
+
+ @try
+ {
+ @throw [Object new];
+ }
+ @catch (id exc)
+ {
+ handlerExpected = 1;
+ }
+
+ @throw [Object new];
+ abort();
+ return 0;
+}