• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// 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
3
4#if __has_attribute(objc_requires_property_definitions)
5__attribute ((objc_requires_property_definitions))
6#endif
7@interface NoAuto // expected-note 2 {{class with specified objc_requires_property_definitions attribute is declared here}}
8@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
15__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}}
17@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
36__attribute ((objc_requires_property_definitions))
37@interface Deep(CAT)  // expected-error {{attributes may not be specified on a category}}
38@end
39
40__attribute ((objc_requires_property_definitions)) // expected-error {{objc_requires_property_definitions attribute may only be specified on a class}}
41@protocol P @end
42
43// rdar://13388503
44@interface NSObject @end
45@protocol Foo
46@property (readonly) char isFoo; // expected-note {{property declared here}}
47@property (readonly) char isNotFree;
48@end
49
50@interface Bar : NSObject <Foo>
51@end
52
53@implementation Bar
54- (char)isFoo {
55    return 0;
56}
57- (char)isNotFree {
58    return 0;
59}
60@end
61
62@interface Baz : Bar
63@end
64
65@interface Baz ()
66@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}}
67@property char Property1; // expected-warning {{auto property synthesis will not synthesize property 'Property1' because it cannot share an ivar with another synthesized property}}
68@property char Property2;
69@property (readwrite) char isNotFree;
70@end
71
72@implementation Baz {
73    char _isFoo;
74    char _isNotFree;
75}
76@synthesize Property2 = Property1; // expected-note {{property synthesized here}}
77
78- (void) setIsNotFree : (char)Arg {
79  _isNotFree = Arg;
80}
81
82@end
83