2012-04-07 02:12:22 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s
|
2010-02-10 05:49:50 +08:00
|
|
|
|
|
|
|
@interface NSString @end
|
|
|
|
|
|
|
|
@interface NSObject @end
|
|
|
|
|
|
|
|
@interface SynthItAll
|
|
|
|
@property int howMany;
|
|
|
|
@property (retain) NSString* what;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation SynthItAll
|
2012-02-02 08:15:51 +08:00
|
|
|
#if !__has_feature(objc_default_synthesize_properties)
|
|
|
|
@synthesize howMany, what;
|
|
|
|
#endif
|
2010-02-10 05:49:50 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@interface SynthSetter : NSObject
|
|
|
|
@property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair
|
|
|
|
@property (nonatomic, retain) NSString* what;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation SynthSetter
|
2012-02-02 08:15:51 +08:00
|
|
|
#if !__has_feature(objc_default_synthesize_properties)
|
|
|
|
@synthesize howMany, what;
|
|
|
|
#endif
|
2010-02-10 05:49:50 +08:00
|
|
|
|
|
|
|
- (int) howMany {
|
2010-04-03 04:09:24 +08:00
|
|
|
return self.howMany;
|
2010-02-10 05:49:50 +08:00
|
|
|
}
|
|
|
|
// - (void) setHowMany: (int) value
|
|
|
|
|
|
|
|
- (NSString*) what {
|
2010-04-03 04:09:24 +08:00
|
|
|
return self.what;
|
2010-02-10 05:49:50 +08:00
|
|
|
}
|
|
|
|
// - (void) setWhat: (NSString*) value
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@interface SynthGetter : NSObject
|
|
|
|
@property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair
|
|
|
|
@property (nonatomic, retain) NSString* what;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation SynthGetter
|
2012-02-02 08:15:51 +08:00
|
|
|
#if !__has_feature(objc_default_synthesize_properties)
|
|
|
|
@synthesize howMany, what;
|
|
|
|
#endif
|
2010-02-10 05:49:50 +08:00
|
|
|
|
|
|
|
// - (int) howMany
|
|
|
|
- (void) setHowMany: (int) value {
|
2010-04-03 04:09:24 +08:00
|
|
|
self.howMany = value;
|
2010-02-10 05:49:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// - (NSString*) what
|
|
|
|
- (void) setWhat: (NSString*) value {
|
2010-04-03 04:09:24 +08:00
|
|
|
if (self.what != value) {
|
2010-02-10 05:49:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@interface SynthNone : NSObject
|
|
|
|
@property int howMany;
|
|
|
|
@property (retain) NSString* what;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation SynthNone
|
2012-02-02 08:15:51 +08:00
|
|
|
#if !__has_feature(objc_default_synthesize_properties)
|
|
|
|
@synthesize howMany, what; // REM: Redundant anyway
|
|
|
|
#endif
|
2010-02-10 05:49:50 +08:00
|
|
|
|
|
|
|
- (int) howMany {
|
2010-04-03 04:09:24 +08:00
|
|
|
return self.howMany;
|
2010-02-10 05:49:50 +08:00
|
|
|
}
|
|
|
|
- (void) setHowMany: (int) value {
|
2010-04-03 04:09:24 +08:00
|
|
|
self.howMany = value;
|
2010-02-10 05:49:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString*) what {
|
2010-04-03 04:09:24 +08:00
|
|
|
return self.what;
|
2010-02-10 05:49:50 +08:00
|
|
|
}
|
|
|
|
- (void) setWhat: (NSString*) value {
|
2010-04-03 04:09:24 +08:00
|
|
|
if (self.what != value) {
|
2010-02-10 05:49:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
2010-04-22 02:57:20 +08:00
|
|
|
@protocol TopProtocol
|
|
|
|
@property (readonly) id myString;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface TopClass <TopProtocol>
|
|
|
|
{
|
2010-05-03 23:49:20 +08:00
|
|
|
id myString;
|
2010-04-22 02:57:20 +08:00
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface SubClass : TopClass <TopProtocol>
|
|
|
|
@end
|
|
|
|
|
2010-05-03 23:49:20 +08:00
|
|
|
@implementation SubClass @end
|
2010-04-30 01:52:18 +08:00
|
|
|
|
2010-11-09 10:16:57 +08:00
|
|
|
// rdar://7920807
|
2010-04-30 01:52:18 +08:00
|
|
|
@interface C @end
|
|
|
|
@interface C (Category)
|
2011-08-28 05:55:47 +08:00
|
|
|
@property int p; // expected-note 2 {{property declared here}}
|
2010-04-30 01:52:18 +08:00
|
|
|
@end
|
2011-08-28 05:55:47 +08:00
|
|
|
@implementation C (Category) // expected-warning {{property 'p' requires method 'p' to be defined}} \
|
|
|
|
// expected-warning {{property 'p' requires method 'setP:' to be defined}}
|
2010-04-30 01:52:18 +08:00
|
|
|
@end
|
|
|
|
|
2010-07-15 02:11:52 +08:00
|
|
|
// Don't complain if a property is already @synthesized by usr.
|
|
|
|
@interface D
|
|
|
|
{
|
|
|
|
}
|
|
|
|
@property int PROP;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation D
|
2011-07-22 09:06:53 +08:00
|
|
|
- (int) Meth { return self.PROP; }
|
2012-02-02 08:15:51 +08:00
|
|
|
#if __has_feature(objc_default_synthesize_properties)
|
2011-08-02 06:39:49 +08:00
|
|
|
@synthesize PROP=IVAR;
|
2012-02-02 08:15:51 +08:00
|
|
|
#endif
|
2010-07-15 02:11:52 +08:00
|
|
|
@end
|
|
|
|
|
2011-12-15 09:03:18 +08:00
|
|
|
// rdar://10567333
|
|
|
|
@protocol MyProtocol
|
|
|
|
@property (nonatomic, strong) NSString *requiredString; // expected-note {{property declared here}}
|
|
|
|
|
|
|
|
@optional
|
|
|
|
@property (nonatomic, strong) NSString *optionalString;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface MyClass <MyProtocol>
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation MyClass // expected-warning {{auto property synthesis will not synthesize property declared in a protocol}}
|
|
|
|
@end
|