Daily bump.
[official-gcc.git] / gcc / testsuite / objc.dg / exceptions-4.m
blob5d77ffa61d251cf6632d0c901a59703746f61793
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 /* Test warnings when parsing syntax errors in @catch().  */
8 #include <objc/objc.h>
10 @interface MyObject
12   Class isa;
14 @end
16 @implementation MyObject
17 @end
19 @interface MyObject2
21   Class isa;
23 @end
25 @implementation MyObject2
26 @end
28 @protocol MyProtocol;
30 int test (id object)
32   int dummy = 0;
34   @try { @throw object; }
35   @catch
36     { /* { dg-error "expected ... before ... token" } */
37       dummy++;
38     }
39   @catch ()  /* { dg-error "expected declaration specifiers or ..... before ..." } */
40     {
41       dummy++;
42     }
43   @catch (i) /* { dg-error "unknown type name .i." } */
44     {
45       dummy++;
46     }
47   @catch (id <MyProtocol x) /* { dg-error "expected ... before .x." } */
48     {                       /* { dg-error "'@catch' parameter cannot be protocol-qualified" "" { target *-*-* } .-1 } */
49       dummy++;
50     }
51   @catch MyObject *x       /* { dg-error "expected ... before .MyObject." } */
52     {
53       dummy++;
54     }
55   @catch MyObject2 *x)      /* { dg-error "expected ... before .MyObject2." } */
56    {
57      dummy++;
58    }
60   @try { @throw object; }
61   @catch (MyObject *x)
62   @catch (MyObject2 *y)    /* { dg-error "expected ... before .catch." } */
64   return dummy;