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 that the compiler is checking the argument of @catch(), and
7 produce errors when invalid types are used. */
17 @implementation MyObject
22 typedef MyObject MyObjectTypedef;
23 typedef MyObject *MyObjectPtrTypedef;
24 typedef int intTypedef;
30 @try { @throw object; }
31 @catch (int x) /* { dg-error "'@catch' parameter is not a known Objective-C class type" } */
36 @try { @throw object; }
37 @catch (intTypedef x) /* { dg-error "'@catch' parameter is not a known Objective-C class type" } */
42 @try { @throw object; }
43 @catch (int *x) /* { dg-error "'@catch' parameter is not a known Objective-C class type" } */
48 @try { @throw object; }
49 @catch (id x) /* Ok */
54 @try { @throw object; }
55 @catch (id <MyProtocol> x) /* { dg-error "'@catch' parameter cannot be protocol-qualified" } */
60 @try { @throw object; }
61 @catch (MyObject *x) /* Ok */
66 @try { @throw object; }
67 @catch (MyObject <MyProtocol> *x) /* { dg-error "'@catch' parameter cannot be protocol-qualified" } */
72 @try { @throw object; }
73 @catch (MyObject x) /* { dg-error "'@catch' parameter is not a known Objective-C class type" } */
74 { /* { dg-error "conversion to non-scalar type requested" "" { target *-*-* } .-1 } */
78 @try { @throw object; }
79 @catch (static MyObject *x) /* { dg-error "storage class specified for" } */
84 @try { @throw object; }
85 @catch (MyObjectTypedef *x) /* Ok */
90 @try { @throw object; }
91 @catch (MyObjectTypedef <MyProtocol> *x) /* { dg-error "'@catch' parameter cannot be protocol-qualified" } */
96 @try { @throw object; }
97 @catch (MyObjectPtrTypedef x) /* Ok */
102 @try { @throw object; }
103 @catch (Class x) /* { dg-error "'@catch' parameter is not a known Objective-C class type" } */
108 @try { @throw object; }
109 @catch (...) /* Ok */