155 lines · plain
1// RUN: %clang_cc1 -fsyntax-only -Wobjc-missing-property-synthesis -verify -Wno-objc-root-class -triple=x86_64-apple-macos10.10 %s2 3@interface NSObject 4- (void) release;5- (id) retain;6@end7@class NSString;8 9@interface SynthItAll : NSObject10@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@end13 14@implementation SynthItAll // expected-note 2 {{detected while default synthesizing properties in class implementation}}15//@synthesize howMany, what;16@end17 18 19@interface SynthSetter : NSObject20@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@end23 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) value31 32- (NSString*) what {33 return _what;34}35// - (void) setWhat: (NSString*) value 36@end37 38 39@interface SynthGetter : NSObject40@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@end43 44@implementation SynthGetter // expected-note 2 {{detected while default synthesizing properties in class implementation}}45//@synthesize howMany, what;46 47// - (int) howMany48- (void) setHowMany: (int) value {49 _howMany = value;50}51 52// - (NSString*) what53- (void) setWhat: (NSString*) value {54 if (_what != value) {55 [_what release];56 _what = [value retain];57 }58}59@end60 61 62@interface SynthNone : NSObject63@property int howMany;64@property (retain) NSString* what;65@end66 67@implementation SynthNone68//@synthesize howMany, what; // REM: Redundant anyway69 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@end87 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@end93 94@interface DSANodeSearchResult : DSATextSearchResult {}95@end96 97 98@implementation DSATextSearchResult 99-(char)isTitleMatch {100 return (char)0;101}102 103-(float)relevance {104 return 0.0;105}106@end107 108@implementation DSANodeSearchResult109-(id)initWithNode:(id )node relevance:(float)relevance isTitleMatch:(char)isTitleMatch {110 relevance = 0.0; 111 isTitleMatch = 'a';112 return self;113}114@end115 116@interface rdar11333367117@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@end121@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@end125 126@interface ZXParsedResult127@property (nonatomic, copy, readonly) NSString *description; // expected-note {{property declared here}}128@end129 130@interface ZXCalendarParsedResult : ZXParsedResult131 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@end135 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@end141 142@interface DontWarnOnUnavailable143 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@end151 152@implementation DontWarnOnUnavailable // expected-note {{detected while default synthesizing properties in class implementation}}153 154@end155