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. */
13 } /* { dg-line interface_MyObject } */
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 "no matching function" "" { target *-*-* } .-1 } */
74 dummy++; /* { dg-message "MyObject" "" { target *-*-* } interface_MyObject } */
75 } /* { dg-message "candidate" "" { target *-*-* } interface_MyObject } */
76 @try { @throw object; }
77 @catch (static MyObject *x) /* { dg-error "storage class" } */
82 @try { @throw object; }
83 @catch (MyObjectTypedef *x) /* Ok */
88 @try { @throw object; }
89 @catch (MyObjectTypedef <MyProtocol> *x) /* { dg-error "@catch parameter can not be protocol-qualified" } */
94 @try { @throw object; }
95 @catch (MyObjectPtrTypedef x) /* Ok */
100 @try { @throw object; }
101 @catch (Class x) /* { dg-error "@catch parameter is not a known Objective-C class type" } */
106 @try { @throw object; }
107 @catch (...) /* Ok */