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