1// RUN: %clang_cc1 -fsyntax-only -Wobjc-missing-property-synthesis -verify -Wno-objc-root-class -triple=x86_64-apple-macos10.10 %s 2 3@interface NSObject 4- (void) release; 5- (id) retain; 6@end 7@class NSString; 8 9@interface SynthItAll : NSObject 10@property int howMany; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} 11@property (retain) NSString* what; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} 12@end 13 14@implementation SynthItAll // expected-note 2 {{detected while default synthesizing properties in class implementation}} 15//@synthesize howMany, what; 16@end 17 18 19@interface SynthSetter : NSObject 20@property (nonatomic) int howMany; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} 21@property (nonatomic, retain) NSString* what; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} 22@end 23 24@implementation SynthSetter // expected-note 2 {{detected while default synthesizing properties in class implementation}} 25//@synthesize howMany, what; 26 27- (int) howMany { 28 return _howMany; 29} 30// - (void) setHowMany: (int) value 31 32- (NSString*) what { 33 return _what; 34} 35// - (void) setWhat: (NSString*) value 36@end 37 38 39@interface SynthGetter : NSObject 40@property (nonatomic) int howMany; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} 41@property (nonatomic, retain) NSString* what; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} 42@end 43 44@implementation SynthGetter // expected-note 2 {{detected while default synthesizing properties in class implementation}} 45//@synthesize howMany, what; 46 47// - (int) howMany 48- (void) setHowMany: (int) value { 49 _howMany = value; 50} 51 52// - (NSString*) what 53- (void) setWhat: (NSString*) value { 54 if (_what != value) { 55 [_what release]; 56 _what = [value retain]; 57 } 58} 59@end 60 61 62@interface SynthNone : NSObject 63@property int howMany; 64@property (retain) NSString* what; 65@end 66 67@implementation SynthNone 68//@synthesize howMany, what; // REM: Redundant anyway 69 70- (int) howMany { 71 return howMany; // expected-error {{use of undeclared identifier 'howMany'}} 72} 73- (void) setHowMany: (int) value { 74 howMany = value; // expected-error {{use of undeclared identifier 'howMany'}} 75} 76 77- (NSString*) what { 78 return what; // expected-error {{use of undeclared identifier 'what'}} 79} 80- (void) setWhat: (NSString*) value { 81 if (what != value) { // expected-error {{use of undeclared identifier 'what'}} 82 [what release]; // expected-error {{use of undeclared identifier 'what'}} 83 what = [value retain]; // expected-error {{use of undeclared identifier 'what'}} 84 } 85} 86@end 87 88// No default synthesis if implementation has getter (readonly) and setter(readwrite) methods. 89@interface DSATextSearchResult 90@property(assign,readonly) float relevance; 91@property(assign,readonly) char isTitleMatch; 92@end 93 94@interface DSANodeSearchResult : DSATextSearchResult {} 95@end 96 97 98@implementation DSATextSearchResult 99-(char)isTitleMatch { 100 return (char)0; 101} 102 103-(float)relevance { 104 return 0.0; 105} 106@end 107 108@implementation DSANodeSearchResult 109-(id)initWithNode:(id )node relevance:(float)relevance isTitleMatch:(char)isTitleMatch { 110 relevance = 0.0; 111 isTitleMatch = 'a'; 112 return self; 113} 114@end 115 116@interface rdar11333367 117@property enum A x; // expected-note {{forward declaration of 'enum A'}} expected-note {{property declared here}} 118@property struct B y; // expected-note {{forward declaration of 'struct B'}} expected-note {{property declared here}} \ 119 // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} 120@end 121@implementation rdar11333367 // expected-error {{cannot synthesize property 'y' with incomplete type 'struct B'}} \ 122 // expected-note {{detected while default synthesizing properties in class implementation}} 123@synthesize x; // expected-error {{cannot synthesize property 'x' with incomplete type 'enum A'}} 124@end 125 126@interface ZXParsedResult 127@property (nonatomic, copy, readonly) NSString *description; // expected-note {{property declared here}} 128@end 129 130@interface ZXCalendarParsedResult : ZXParsedResult 131 132@property (nonatomic, copy, readonly) NSString *description; // expected-warning {{auto property synthesis will not synthesize property 'description'; it will be implemented by its superclass}} 133 134@end 135 136@implementation ZXCalendarParsedResult // expected-note {{detected while default synthesizing properties in class implementation}} 137- (NSString *) Meth { 138 return _description; // expected-error {{use of undeclared identifier '_description'}} 139} 140@end 141 142@interface DontWarnOnUnavailable 143 144// No warning expected: 145@property (nonatomic, readonly) int un1 __attribute__((unavailable)); 146@property (readwrite) int un2 __attribute__((availability(macos, unavailable))); 147 148@property (readwrite) int un3 __attribute__((availability(ios, unavailable))); // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} 149 150@end 151 152@implementation DontWarnOnUnavailable // expected-note {{detected while default synthesizing properties in class implementation}} 153 154@end 155