[AArch64] Merge stores of D-register values with different modes
[official-gcc.git] / gcc / testsuite / obj-c++.dg / exceptions-3.mm
blobc29752d13999ea7b3f76308a51f030b35f98178f
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.  */
8 #include <objc/objc.h>
10 @interface MyObject
12   Class isa;
13 } /* { dg-line interface_MyObject } */
14 @end
16 @implementation MyObject
17 @end
19 @protocol MyProtocol;
21 typedef MyObject MyObjectTypedef;
22 typedef MyObject *MyObjectPtrTypedef;
23 typedef int intTypedef;
25 int test (id object)
27   int dummy = 0;
29   @try { @throw object; }
30   @catch (int x)          /* { dg-error "@catch parameter is not a known Objective-C class type" } */
31     {
32       dummy++;
33     }
35   @try { @throw object; }
36   @catch (intTypedef x)   /* { dg-error "@catch parameter is not a known Objective-C class type" } */
37     {
38       dummy++;
39     }
41   @try { @throw object; }
42   @catch (int *x)         /* { dg-error "@catch parameter is not a known Objective-C class type" } */
43     {
44       dummy++;
45     }  
47   @try { @throw object; }
48   @catch (id x)           /* Ok */
49     {
50       dummy++;
51     }
53   @try { @throw object; }
54   @catch (id <MyProtocol> x) /* { dg-error "@catch parameter can not be protocol-qualified" } */
55     {
56       dummy++;
57     }
59   @try { @throw object; }
60   @catch (MyObject *x)    /* Ok */
61     {
62       dummy++;
63     }
65   @try { @throw object; }
66   @catch (MyObject <MyProtocol> *x)  /* { dg-error "@catch parameter can not be protocol-qualified" } */
67     {
68       dummy++;
69     }
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" } */
78     {
79       dummy++;
80     }
82   @try { @throw object; }
83   @catch (MyObjectTypedef *x) /* Ok */
84     {
85       dummy++;
86     }
88   @try { @throw object; }
89   @catch (MyObjectTypedef <MyProtocol> *x) /* { dg-error "@catch parameter can not be protocol-qualified" } */
90     {
91       dummy++;
92     }
94   @try { @throw object; }
95   @catch (MyObjectPtrTypedef x) /* Ok */
96     {
97       dummy++;
98     }
100   @try { @throw object; }
101   @catch (Class x)   /* { dg-error "@catch parameter is not a known Objective-C class type" } */
102     {
103       dummy++;
104     }
106   @try { @throw object; }
107   @catch (...)            /* Ok */
108     {
109       dummy++;
110     }
112   return dummy;