blob: 06741e119e5ba5ec1e4356141b8fe648e47b1a81 [file] [log] [blame]
Patrick Beardacfbe9e2012-04-06 18:12:22 +00001// RUN: %clang_cc1 -x objective-c -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
2// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
Fariborz Jahanian3c9707b2012-01-03 19:46:00 +00003
Ted Kremenek0c2c90b2012-01-05 22:47:47 +00004#if __has_attribute(objc_requires_property_definitions)
5__attribute ((objc_requires_property_definitions))
Fariborz Jahaniana28a78e2012-01-04 22:29:28 +00006#endif
Ted Kremenek0c2c90b2012-01-05 22:47:47 +00007@interface NoAuto // expected-note 2 {{class with specified objc_requires_property_definitions attribute is declared here}}
Fariborz Jahanian3c9707b2012-01-03 19:46:00 +00008@property int NoAutoProp; // expected-note 2 {{property declared here}}
9@end
10
11@implementation NoAuto // expected-warning {{property 'NoAutoProp' requires method 'NoAutoProp' to be defined}} \
12 // expected-warning {{property 'NoAutoProp' requires method 'setNoAutoProp:'}}
13@end
14
Ted Kremenek0c2c90b2012-01-05 22:47:47 +000015__attribute ((objc_requires_property_definitions)) // redundant, just for testing
16@interface Sub : NoAuto // expected-note 3 {{class with specified objc_requires_property_definitions attribute is declared here}}
Fariborz Jahanian3c9707b2012-01-03 19:46:00 +000017@property (copy) id SubProperty; // expected-note 2 {{property declared here}}
18@end
19
20@implementation Sub // expected-warning {{property 'SubProperty' requires method 'SubProperty' to be defined}} \
21 // expected-warning {{property 'SubProperty' requires method 'setSubProperty:' to be defined}}
22@end
23
24@interface Deep : Sub
25@property (copy) id DeepProperty;
26@property (copy) id DeepSynthProperty;
27@property (copy) id DeepMustSynthProperty; // expected-note {{property declared here}}
28@end
29
30@implementation Deep // expected-warning {{property 'DeepMustSynthProperty' requires method 'setDeepMustSynthProperty:' to be defined}}
31@dynamic DeepProperty;
32@synthesize DeepSynthProperty;
33- (id) DeepMustSynthProperty { return 0; }
34@end
35
Ted Kremenek0c2c90b2012-01-05 22:47:47 +000036__attribute ((objc_requires_property_definitions))
Fariborz Jahanian7249e362012-01-03 22:52:32 +000037@interface Deep(CAT) // expected-error {{attributes may not be specified on a category}}
38@end
39
Ted Kremenek0c2c90b2012-01-05 22:47:47 +000040__attribute ((objc_requires_property_definitions)) // expected-error {{objc_requires_property_definitions attribute may only be specified on a class}}
Fariborz Jahanian7249e362012-01-03 22:52:32 +000041@protocol P @end
Fariborz Jahanian9d25a482013-03-12 19:46:17 +000042
43// rdar://13388503
44@interface NSObject @end
45@protocol Foo
46@property (readonly) char isFoo; // expected-note {{property declared here}}
47@end
48
49@interface Bar : NSObject <Foo>
50@end
51
52@implementation Bar
53- (char)isFoo {
54 return 0;
55}
56@end
57
58@interface Baz : Bar
59@end
60
61@interface Baz ()
62@property (readwrite) char isFoo; // expected-warning {{auto property synthesis will not synthesize property 'isFoo' because it is 'readwrite' but it will be synthesized 'readonly' via another property}}
63@property char Property1; // expected-warning {{auto property synthesis will not synthesize property 'Property1' because it cannot share an ivar with another synthesized property}}
64@property char Property2;
65@end
66
67@implementation Baz {
68 char _isFoo;
69}
70@synthesize Property2 = Property1; // expected-note {{property synthesized here}}
71@end