1 /* Contributed by Nicola Pero <nicola.pero@meta-innovation.com>, December 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 @synchronized(),
7 and produce errors when invalid types are used. */
17 @implementation MyObject
22 typedef MyObject MyObjectTypedef;
23 typedef MyObject *MyObjectPtrTypedef;
24 typedef int intTypedef;
26 typedef struct { float x; float y; } point, *point_ptr;
34 @synchronized (x) /* { dg-error ".@synchronized. argument is not an object" } */
40 @synchronized (x) /* { dg-error ".@synchronized. argument is not an object" } */
46 @synchronized (x) /* { dg-error ".@synchronized. argument is not an object" } */
52 @synchronized (x) /* { dg-error ".@synchronized. argument is not an object" } */
58 @synchronized (x) /* { dg-error ".@synchronized. argument is not an object" } */
64 @synchronized (x) /* Ok */
70 @synchronized (x) /* Ok */
76 @synchronized (x) /* Ok */
81 MyObject <MyProtocol> *x;
82 @synchronized (x) /* Ok */
88 @synchronized (x) /* Ok */
94 @synchronized (x) /* Ok */
99 MyObjectTypedef <MyProtocol> *x;
100 @synchronized (x) /* Ok */
105 MyObjectPtrTypedef x;
106 @synchronized (x) /* Ok */
112 @synchronized (x) /* Ok */
116 @synchronized (1) /* { dg-error ".@synchronized. argument is not an object" } */
119 @synchronized ("Test") /* { dg-error ".@synchronized. argument is not an object" } */
122 @synchronized () /* { dg-error "expected" } */
125 @synchronized (int) /* { dg-error "expected" } */