Debian Codegraph @

gcc/testsuite/obj-c++.dg/exceptions-1.mm

raw
1 /* Contributed by Nicola Pero <[email protected]>, November 2010. */
2 /* { dg-options "-fobjc-exceptions" } */
3 /* { dg-do compile } */
4 // { dg-additional-options "-Wno-objc-root-class" }
5
6 /* This test checks the syntax @catch (...) which catches any
7 exceptions. At the moment, @catch (...) is identical to @catch (id
8 exception). */
9
10 #include <objc/objc.h>
11
12 @interface MyObject
13 {
14 Class isa;
15 }
16 @end
17
18 @implementation MyObject
19 @end
20
21 int test (id object)
22 {
23 int i = 0;
24
25 @try
26 {
27 @throw object;
28 }
29 @catch (MyObject *o)
30 {
31 i += 1;
32 }
33 @catch (...)
34 {
35 i += 2;
36 }
37 @finally
38 {
39 i += 4;
40 }
41
42 return i;
43 }