testsuite: Align testcase with implementation [PR105090]
[official-gcc.git] / gcc / testsuite / obj-c++.dg / exceptions-1.mm
blob75327ef7a9fa4ab2adc2fdf2eaad98db887fa128
1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010.  */
2 /* { dg-options "-fobjc-exceptions" } */
3 /* { dg-do compile } */
4 // { dg-additional-options "-Wno-objc-root-class" }
6 /* This test checks the syntax @catch (...) which catches any
7    exceptions.  At the moment, @catch (...) is identical to @catch (id
8    exception).  */
10 #include <objc/objc.h>
12 @interface MyObject
14   Class isa;
16 @end
18 @implementation MyObject
19 @end
21 int test (id object)
23   int i = 0;
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     }
42   return i;