2013-09-28 04:21:48 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -Wobjc-missing-property-synthesis -verify -Wno-objc-root-class %s
|
2012-05-04 00:43:30 +08:00
|
|
|
// rdar://11295716
|
2010-07-17 09:16:59 +08:00
|
|
|
|
|
|
|
@interface NSObject
|
|
|
|
- (void) release;
|
|
|
|
- (id) retain;
|
|
|
|
@end
|
|
|
|
@class NSString;
|
|
|
|
|
|
|
|
@interface SynthItAll : NSObject
|
2012-05-04 00:43:30 +08:00
|
|
|
@property int howMany; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}}
|
|
|
|
@property (retain) NSString* what; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}}
|
2010-07-17 09:16:59 +08:00
|
|
|
@end
|
|
|
|
|
2012-05-04 00:43:30 +08:00
|
|
|
@implementation SynthItAll // expected-note 2 {{detected while default synthesizing properties in class implementation}}
|
2010-07-17 09:16:59 +08:00
|
|
|
//@synthesize howMany, what;
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@interface SynthSetter : NSObject
|
2012-05-04 00:43:30 +08:00
|
|
|
@property (nonatomic) int howMany; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}}
|
|
|
|
@property (nonatomic, retain) NSString* what; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}}
|
2010-07-17 09:16:59 +08:00
|
|
|
@end
|
|
|
|
|
2012-05-04 00:43:30 +08:00
|
|
|
@implementation SynthSetter // expected-note 2 {{detected while default synthesizing properties in class implementation}}
|
2010-07-17 09:16:59 +08:00
|
|
|
//@synthesize howMany, what;
|
|
|
|
|
|
|
|
- (int) howMany {
|
2011-09-28 07:39:40 +08:00
|
|
|
return _howMany;
|
2010-07-17 09:16:59 +08:00
|
|
|
}
|
|
|
|
// - (void) setHowMany: (int) value
|
|
|
|
|
|
|
|
- (NSString*) what {
|
2011-09-28 07:39:40 +08:00
|
|
|
return _what;
|
2010-07-17 09:16:59 +08:00
|
|
|
}
|
|
|
|
// - (void) setWhat: (NSString*) value
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@interface SynthGetter : NSObject
|
2012-05-04 00:43:30 +08:00
|
|
|
@property (nonatomic) int howMany; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}}
|
|
|
|
@property (nonatomic, retain) NSString* what; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}}
|
2010-07-17 09:16:59 +08:00
|
|
|
@end
|
|
|
|
|
2012-05-04 00:43:30 +08:00
|
|
|
@implementation SynthGetter // expected-note 2 {{detected while default synthesizing properties in class implementation}}
|
2010-07-17 09:16:59 +08:00
|
|
|
//@synthesize howMany, what;
|
|
|
|
|
|
|
|
// - (int) howMany
|
|
|
|
- (void) setHowMany: (int) value {
|
2011-09-28 07:39:40 +08:00
|
|
|
_howMany = value;
|
2010-07-17 09:16:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// - (NSString*) what
|
|
|
|
- (void) setWhat: (NSString*) value {
|
2011-09-28 07:39:40 +08:00
|
|
|
if (_what != value) {
|
|
|
|
[_what release];
|
|
|
|
_what = [value retain];
|
2010-07-17 09:16:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@interface SynthNone : NSObject
|
|
|
|
@property int howMany;
|
|
|
|
@property (retain) NSString* what;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation SynthNone
|
|
|
|
//@synthesize howMany, what; // REM: Redundant anyway
|
|
|
|
|
|
|
|
- (int) howMany {
|
2011-09-01 06:24:06 +08:00
|
|
|
return howMany; // expected-error {{use of undeclared identifier 'howMany'}}
|
2010-07-17 09:16:59 +08:00
|
|
|
}
|
|
|
|
- (void) setHowMany: (int) value {
|
2011-09-01 06:24:06 +08:00
|
|
|
howMany = value; // expected-error {{use of undeclared identifier 'howMany'}}
|
2010-07-17 09:16:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString*) what {
|
2011-09-01 06:24:06 +08:00
|
|
|
return what; // expected-error {{use of undeclared identifier 'what'}}
|
2010-07-17 09:16:59 +08:00
|
|
|
}
|
|
|
|
- (void) setWhat: (NSString*) value {
|
2011-09-01 06:24:06 +08:00
|
|
|
if (what != value) { // expected-error {{use of undeclared identifier 'what'}}
|
|
|
|
[what release]; // expected-error {{use of undeclared identifier 'what'}}
|
|
|
|
what = [value retain]; // expected-error {{use of undeclared identifier 'what'}}
|
2010-07-17 09:16:59 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
2010-08-25 08:31:58 +08:00
|
|
|
// rdar://8349319
|
|
|
|
// No default synthesis if implementation has getter (readonly) and setter(readwrite) methods.
|
|
|
|
@interface DSATextSearchResult
|
|
|
|
@property(assign,readonly) float relevance;
|
|
|
|
@property(assign,readonly) char isTitleMatch;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface DSANodeSearchResult : DSATextSearchResult {}
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@implementation DSATextSearchResult
|
|
|
|
-(char)isTitleMatch {
|
|
|
|
return (char)0;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(float)relevance {
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation DSANodeSearchResult
|
|
|
|
-(id)initWithNode:(id )node relevance:(float)relevance isTitleMatch:(char)isTitleMatch {
|
|
|
|
relevance = 0.0;
|
|
|
|
isTitleMatch = 'a';
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
@end
|
2010-07-17 09:16:59 +08:00
|
|
|
|
2012-05-02 06:26:06 +08:00
|
|
|
@interface rdar11333367
|
|
|
|
@property enum A x; // expected-note {{forward declaration of 'enum A'}} expected-note {{property declared here}}
|
2012-05-04 00:43:30 +08:00
|
|
|
@property struct B y; // expected-note {{forward declaration of 'struct B'}} expected-note {{property declared here}} \
|
|
|
|
// expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}}
|
2012-05-02 06:26:06 +08:00
|
|
|
@end
|
2012-05-04 00:43:30 +08:00
|
|
|
@implementation rdar11333367 // expected-error {{cannot synthesize property 'y' with incomplete type 'struct B'}} \
|
|
|
|
// expected-note {{detected while default synthesizing properties in class implementation}}
|
2012-05-02 06:26:06 +08:00
|
|
|
@synthesize x; // expected-error {{cannot synthesize property 'x' with incomplete type 'enum A'}}
|
|
|
|
@end
|
2014-07-27 04:52:26 +08:00
|
|
|
|
|
|
|
// rdar://17774815
|
|
|
|
@interface ZXParsedResult
|
2014-10-11 06:08:23 +08:00
|
|
|
@property (nonatomic, copy, readonly) NSString *description; // expected-note {{property declared here}}
|
2014-07-27 04:52:26 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@interface ZXCalendarParsedResult : ZXParsedResult
|
|
|
|
|
2014-08-30 02:31:16 +08:00
|
|
|
@property (nonatomic, copy, readonly) NSString *description; // expected-warning {{auto property synthesis will not synthesize property 'description'; it will be implemented by its superclass}}
|
2014-07-27 04:52:26 +08:00
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation ZXCalendarParsedResult // expected-note {{detected while default synthesizing properties in class implementation}}
|
|
|
|
- (NSString *) Meth {
|
|
|
|
return _description; // expected-error {{use of undeclared identifier '_description'}}
|
|
|
|
}
|
|
|
|
@end
|