PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / obj-c++.dg / exceptions-1.mm
blob0f3b7e8ae14706fbe9e453c61c25629383deddc1
1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
2 /* { dg-options "-fobjc-exceptions" } */
3 /* { dg-do compile } */
5 /* This test checks the syntax @catch (...) which catches any
6    exceptions.  At the moment, @catch (...) is identical to @catch (id
7    exception).  */
9 #include <objc/objc.h>
11 @interface MyObject
13   Class isa;
15 @end
17 @implementation MyObject
18 @end
20 int test (id object)
22   int i = 0;
24   @try
25     {
26       @throw object;
27     }
28   @catch (MyObject *o)
29     {
30       i += 1;
31     }
32   @catch (...)
33     {
34       i += 2;
35     }
36   @finally
37     {
38       i += 4;
39     }
41   return i;