* lto.c (do_stream_out): Add PART parameter; open dump file.
[official-gcc.git] / gcc / testsuite / obj-c++.dg / except-1.mm
blobfbce2f2721133002d361bc5269836a9d1c281997
1 /* { dg-do run } */
2 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
4 /* This tests that exceptions work.  It used to fail because
5    objc_msgSend was marked with DECL_NOTHROW. 
6    If you include objc/Object.h, the problem goes away, because
7    that file includes objc/objc-runtime.h which explicitly prototypes
8    objc_msgSend without 'nothrow'.  */
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include "../objc-obj-c++-shared/TestsuiteObject.m"
14 // ObjectiveC class header
15 @interface ObjCclass : TestsuiteObject {
17 -(void)method1;
18 -(void)method2;
19 @end
21 // C++ class header
22 class CPPclass {
23 public:
24         void function1();
28 // Main
29 int main(int argc, char *argv[])
31         ObjCclass * foo = [[ObjCclass alloc] init];
32         [foo method1];
33         exit (0);
37 // ObjectiveC implementation
38 @implementation ObjCclass
40 -(void) method1
42         try {
43                 [self method2];
44         }
45         catch(...) {
46                 return;
47         }
50 -(void) method2
52         CPPclass foo;
53         foo.function1();
56 @end
59 // C++ implementation
60 void CPPclass::function1()
62         throw (1);
63         /* Shouldn't be here because we threw.  */
64         abort ();