Debian Codegraph @

gcc/testsuite/objc/execute/exceptions/handler-1.m

raw
1 /* Test custom exception handlers */
2 /* Author: David Ayers */
3
4 #ifdef __NEXT_RUNTIME__
5 /* This test only runs for the GNU runtime. TODO: It should work on
6 the NEXT runtime as well (needs testing).
7 */
8
9 int main(void)
10 {
11 return 0;
12 }
13
14 #else
15
16 #include <objc/runtime.h>
17 #include <objc/objc-exception.h>
18 #include "../../../objc-obj-c++-shared/TestsuiteObject.m"
19 #include <stdlib.h>
20
21 static unsigned int handlerExpected = 0;
22
23 void
24 my_exception_handler(id excp)
25 {
26 /* Returning from the handler would abort. */
27 if (handlerExpected)
28 exit(0);
29
30 abort();
31 }
32
33 int
34 main(int argc, char *argv[])
35 {
36 objc_setUncaughtExceptionHandler (my_exception_handler);
37
38 @try
39 {
40 @throw [TestsuiteObject new];
41 }
42 @catch (id exc)
43 {
44 handlerExpected = 1;
45 }
46
47 @throw [TestsuiteObject new];
48 abort();
49 return 0;
50 }
51
52
53 #endif