1 // RUN: %clang_cc1 -fsyntax-only -Wobjc-missing-property-synthesis -verify -Wno-objc-root-class -triple=x86_64-apple-macos10.10 %s
10 @interface SynthItAll : NSObject
11 @property int howMany; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}}
12 @property (retain) NSString* what; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}}
15 @implementation SynthItAll // expected-note 2 {{detected while default synthesizing properties in class implementation}}
16 //@synthesize howMany, what;
20 @interface SynthSetter : NSObject
21 @property (nonatomic) int howMany; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}}
22 @property (nonatomic, retain) NSString* what; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}}
25 @implementation SynthSetter // expected-note 2 {{detected while default synthesizing properties in class implementation}}
26 //@synthesize howMany, what;
31 // - (void) setHowMany: (int) value
36 // - (void) setWhat: (NSString*) value
40 @interface SynthGetter : NSObject
41 @property (nonatomic) int howMany; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}}
42 @property (nonatomic, retain) NSString* what; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}}
45 @implementation SynthGetter // expected-note 2 {{detected while default synthesizing properties in class implementation}}
46 //@synthesize howMany, what;
49 - (void) setHowMany: (int) value {
54 - (void) setWhat: (NSString*) value {
57 _what = [value retain];
63 @interface SynthNone : NSObject
64 @property int howMany;
65 @property (retain) NSString* what;
68 @implementation SynthNone
69 //@synthesize howMany, what; // REM: Redundant anyway
72 return howMany; // expected-error {{use of undeclared identifier 'howMany'}}
74 - (void) setHowMany: (int) value {
75 howMany = value; // expected-error {{use of undeclared identifier 'howMany'}}
79 return what; // expected-error {{use of undeclared identifier 'what'}}
81 - (void) setWhat: (NSString*) value {
82 if (what != value) { // expected-error {{use of undeclared identifier 'what'}}
83 [what release]; // expected-error {{use of undeclared identifier 'what'}}
84 what = [value retain]; // expected-error {{use of undeclared identifier 'what'}}
90 // No default synthesis if implementation has getter (readonly) and setter(readwrite) methods.
91 @interface DSATextSearchResult
92 @property(assign,readonly) float relevance;
93 @property(assign,readonly) char isTitleMatch;
96 @interface DSANodeSearchResult : DSATextSearchResult {}
100 @implementation DSATextSearchResult
101 -(char)isTitleMatch {
110 @implementation DSANodeSearchResult
111 -(id)initWithNode:(id )node relevance:(float)relevance isTitleMatch:(char)isTitleMatch {
118 @interface rdar11333367
119 @property enum A x; // expected-note {{forward declaration of 'enum A'}} expected-note {{property declared here}}
120 @property struct B y; // expected-note {{forward declaration of 'struct B'}} expected-note {{property declared here}} \
121 // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}}
123 @implementation rdar11333367 // expected-error {{cannot synthesize property 'y' with incomplete type 'struct B'}} \
124 // expected-note {{detected while default synthesizing properties in class implementation}}
125 @synthesize x; // expected-error {{cannot synthesize property 'x' with incomplete type 'enum A'}}
129 @interface ZXParsedResult
130 @property (nonatomic, copy, readonly) NSString *description; // expected-note {{property declared here}}
133 @interface ZXCalendarParsedResult : ZXParsedResult
135 @property (nonatomic, copy, readonly) NSString *description; // expected-warning {{auto property synthesis will not synthesize property 'description'; it will be implemented by its superclass}}
139 @implementation ZXCalendarParsedResult // expected-note {{detected while default synthesizing properties in class implementation}}
140 - (NSString *) Meth {
141 return _description; // expected-error {{use of undeclared identifier '_description'}}
145 @interface DontWarnOnUnavailable
147 // No warning expected:
148 @property (nonatomic, readonly) int un1 __attribute__((unavailable));
149 @property (readwrite) int un2 __attribute__((availability(macos, unavailable)));
151 @property (readwrite) int un3 __attribute__((availability(ios, unavailable))); // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}}
155 @implementation DontWarnOnUnavailable // expected-note {{detected while default synthesizing properties in class implementation}}