1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 #if !__has_feature(objc_class_property)
4 #error does not support class property
19 @property(readonly) int ro, ro2;
20 @property (class) int c;
21 @property (class) int c2; // expected-note {{property declared here}} \
22 // expected-note {{property declared here}}
23 @property (class) int x;
24 @property (class, setter=customSet:) int customSetterProperty;
25 @property (class, getter=customGet) int customGetterProperty;
28 @implementation A // expected-warning {{class property 'c2' requires method 'c2' to be defined}} \
29 // expected-warning {{class property 'c2' requires method 'setC2:' to be defined}}
30 @dynamic x; // refers to the instance property
31 @dynamic (class) x; // refers to the class property
32 @synthesize z, c2; // expected-error {{@synthesize not allowed on a class property 'c2'}}
33 @dynamic c; // refers to the class property
34 @dynamic customSetterProperty;
35 @dynamic customGetterProperty;
39 A *a = [[A alloc] init];
40 a.c; // expected-error {{property 'c' is a class property; did you mean to access it with class 'A'}}
44 void customSelectors(void) {
45 A.customSetterProperty = 1;
46 (void)A.customGetterProperty;
49 void message_id(id me) {
53 void message_class(Class me) {
60 @interface MyClass : NSObject
61 @property(class, readonly) int classProp; // expected-note {{property declared here}}
64 @implementation MyClass // expected-warning {{class property 'classProp' requires method 'classProp' to be defined}}
65 - (int)classProp { // Oops, mistakenly made this an instance method.