Debian Codegraph @

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

raw
1 /* Test custom exception matchers */
2 /* Author: Nicola Pero */
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 int
24 my_exception_matcher(Class match_class, id exception)
25 {
26 /* Always matches. */
27 return 1;
28 }
29
30 @interface A : TestsuiteObject
31 @end
32
33 @implementation A
34 @end
35
36 @interface B : TestsuiteObject
37 @end
38
39 @implementation B
40 @end
41
42 int
43 main(int argc, char *argv[])
44 {
45 objc_setExceptionMatcher (my_exception_matcher);
46
47 @try
48 {
49 @throw [A new];
50 }
51 @catch (B *exception)
52 {
53 /* Since we installed an exception matcher that always matches,
54 the exception should be sent here even if it's of class A and
55 this is looking for exceptions of class B.
56 */
57 return 0;
58 }
59 @catch (id exception)
60 {
61 abort ();
62 }
63
64 abort ();
65 }
66
67
68 #endif