1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, November 2010. */
2 /* { dg-options "-fobjc-exceptions" } */
3 /* { dg-do compile } */
5 /* Test that the compiler is checking the argument of @catch(), and
6 produce errors when invalid types are used. */
16 @implementation MyObject
21 typedef MyObject MyObjectTypedef;
22 typedef MyObject *MyObjectPtrTypedef;
23 typedef int intTypedef;
29 @try { @throw object; }
30 @catch (int x) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
35 @try { @throw object; }
36 @catch (intTypedef x) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
41 @try { @throw object; }
42 @catch (int *x) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
47 @try { @throw object; }
48 @catch (id x) /* Ok */
53 @try { @throw object; }
54 @catch (id <MyProtocol> x) /* { dg-error "@catch parameter can not be protocol-qualified" } */
59 @try { @throw object; }
60 @catch (MyObject *x) /* Ok */
65 @try { @throw object; }
66 @catch (MyObject <MyProtocol> *x) /* { dg-error "@catch parameter can not be protocol-qualified" } */
71 @try { @throw object; }
72 @catch (MyObject x) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
73 { /* { dg-error "conversion to non-scalar type requested" "" { target *-*-* } 72 } */
77 @try { @throw object; }
78 @catch (static MyObject *x) /* { dg-error "storage class specified for" } */
83 @try { @throw object; }
84 @catch (MyObjectTypedef *x) /* Ok */
89 @try { @throw object; }
90 @catch (MyObjectTypedef <MyProtocol> *x) /* { dg-error "@catch parameter can not be protocol-qualified" } */
95 @try { @throw object; }
96 @catch (MyObjectPtrTypedef x) /* Ok */
101 @try { @throw object; }
102 @catch (Class x) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
107 @try { @throw object; }
108 @catch (...) /* Ok */