OSDN Git Service

* objc/execute/exceptions/exceptions.exp: New exp for the exceptions
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / objc / execute / exceptions / foward-1.m
1 /* Check that throwing an exception from a -forward:: works.  */
2 /* Developed by Marcin Koziej <creep@desk.pl>.  */
3
4 #import <objc/Object.h>
5 #import <objc/objc-api.h>
6 #include <stdlib.h>
7
8 static int i;
9
10 @interface Thrower : Object
11 - forward: (SEL) s : (void*) a;
12 @end
13
14 @implementation Thrower
15 - forward: (SEL) s : (void*) a
16 {
17   i++;
18   @throw [Object new];
19 }
20 @end
21 int
22 main()
23 {
24   id t = [Thrower new];
25   @try
26   {
27     [t doesnotexist];
28   }
29   @catch (id error)
30   {
31     i++;
32     [error free];
33   }
34   
35   if (i != 2)
36     abort ();
37   
38   return 0;
39 }