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" } */
8 #include <objc/Object.h>
12 /* The following is not required in actual user code; we include it
13 here to check that the compiler generates an internal definition of
14 _setjmp that is consistent with what <setjmp.h> provides. */
17 #define CHECK_IF(expr) if(!(expr)) abort()
19 @interface Frob: Object
22 @implementation Frob: Object
25 static Frob* _connection = nil;
27 //--------------------------------------------------------------------
30 void test (Object* sendPort)
33 Frob* receivePort = nil;
36 printf ("receivePort = %p\n", receivePort);
37 printf ("sendPort = %p\n", sendPort);
38 printf ("cleanupPorts = %d\n", cleanupPorts);
41 receivePort = (Frob *) -1;
42 _connection = (Frob *) -1;
43 printf ("receivePort = %p\n", receivePort);
44 printf ("sendPort = %p\n", sendPort);
45 printf ("cleanupPorts = %d\n", cleanupPorts);
52 printf ("receivePort = %p\n", receivePort);
53 printf ("sendPort = %p\n", sendPort);
54 printf ("cleanupPorts = %d\n", cleanupPorts);
60 printf ("Exception caught by incorrect handler!\n");
64 printf ("Exception caught by correct handler.\n");
65 printf ("receivePort = %p (expected 0x0)\n", receivePort);
66 printf ("sendPort = %p (expected 0x0)\n", sendPort);
67 printf ("cleanupPorts = %d (expected 0)\n", cleanupPorts);
69 CHECK_IF(!receivePort);
71 CHECK_IF(!cleanupPorts);