1 /* Test out '@catch(id foo) {...}', which should catch
2 all uncaught exceptions. */
3 /* Developed by Ziemowit Laski <zlaski@apple.com>. */
5 /* { dg-options "-fobjc-exceptions" } */
6 /* { dg-xfail-if "PR23616" { "*-*-*" } { "*" } { "" } } */
9 #include <objc/Object.h>
13 /* The following is not required in actual user code; we include it
14 here to check that the compiler generates an internal definition of
15 _setjmp that is consistent with what <setjmp.h> provides. */
18 #define CHECK_IF(expr) if(!(expr)) abort()
20 @interface Frob: Object
23 @implementation Frob: Object
26 static Frob* _connection = nil;
28 //--------------------------------------------------------------------
31 void test (Object* sendPort)
34 Frob* receivePort = nil;
37 printf ("receivePort = %p\n", receivePort);
38 printf ("sendPort = %p\n", sendPort);
39 printf ("cleanupPorts = %d\n", cleanupPorts);
42 receivePort = (Frob *) -1;
43 _connection = (Frob *) -1;
44 printf ("receivePort = %p\n", receivePort);
45 printf ("sendPort = %p\n", sendPort);
46 printf ("cleanupPorts = %d\n", cleanupPorts);
53 printf ("receivePort = %p\n", receivePort);
54 printf ("sendPort = %p\n", sendPort);
55 printf ("cleanupPorts = %d\n", cleanupPorts);
61 printf ("Exception caught by incorrect handler!\n");
65 printf ("Exception caught by correct handler.\n");
66 printf ("receivePort = %p (expected 0x0)\n", receivePort);
67 printf ("sendPort = %p (expected 0x0)\n", sendPort);
68 printf ("cleanupPorts = %d (expected 0)\n", cleanupPorts);
70 CHECK_IF(!receivePort);
72 CHECK_IF(!cleanupPorts);