Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / obj-c++.dg / except-1.mm
blobe06bea0a86c0a20892e68b7c27fbe5a95a5da3a4
1 /* { dg-do run } */
3 /* This tests that exceptions work.  It used to fail because
4    objc_msgSend was marked with DECL_NOTHROW. 
5    If you include objc/Object.h, the problem goes away, because
6    that file includes objc/objc-runtime.h which explicitly prototypes
7    objc_msgSend without 'nothrow'.  */
9 #include <stdio.h>
10 #include <stdlib.h>
13 @interface Object {
14   Class isa;  
16 + alloc;
17 - init;
18 @end
20 // ObjectiveC class header
21 @interface ObjCclass : Object {
23 -(void)method1;
24 -(void)method2;
25 @end
27 // C++ class header
28 class CPPclass {
29 public:
30         void function1();
34 // Main
35 int main(int argc, char *argv[])
37         ObjCclass * foo = [[ObjCclass alloc] init];
38         [foo method1];
39         exit (0);
43 // ObjectiveC implementation
44 @implementation ObjCclass
46 -(void) method1
48         try {
49                 [self method2];
50         }
51         catch(...) {
52                 return;
53         }
56 -(void) method2
58         CPPclass foo;
59         foo.function1();
62 @end
65 // C++ implementation
66 void CPPclass::function1()
68         throw (1);
69         /* Shouldn't be here because we threw.  */
70         abort ();