1*67e74705SXin Li// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s 2*67e74705SXin Li 3*67e74705SXin Li@interface NSString @end 4*67e74705SXin Li 5*67e74705SXin Li@interface NSObject @end 6*67e74705SXin Li 7*67e74705SXin Li@interface SynthItAll 8*67e74705SXin Li@property int howMany; 9*67e74705SXin Li@property (retain) NSString* what; 10*67e74705SXin Li@end 11*67e74705SXin Li 12*67e74705SXin Li@implementation SynthItAll 13*67e74705SXin Li#if !__has_feature(objc_default_synthesize_properties) 14*67e74705SXin Li@synthesize howMany, what; 15*67e74705SXin Li#endif 16*67e74705SXin Li@end 17*67e74705SXin Li 18*67e74705SXin Li 19*67e74705SXin Li@interface SynthSetter : NSObject 20*67e74705SXin Li@property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair 21*67e74705SXin Li@property (nonatomic, retain) NSString* what; 22*67e74705SXin Li@end 23*67e74705SXin Li 24*67e74705SXin Li@implementation SynthSetter 25*67e74705SXin Li#if !__has_feature(objc_default_synthesize_properties) 26*67e74705SXin Li@synthesize howMany, what; 27*67e74705SXin Li#endif 28*67e74705SXin Li 29*67e74705SXin Li- (int) howMany { 30*67e74705SXin Li return self.howMany; 31*67e74705SXin Li} 32*67e74705SXin Li// - (void) setHowMany: (int) value 33*67e74705SXin Li 34*67e74705SXin Li- (NSString*) what { 35*67e74705SXin Li return self.what; 36*67e74705SXin Li} 37*67e74705SXin Li// - (void) setWhat: (NSString*) value 38*67e74705SXin Li@end 39*67e74705SXin Li 40*67e74705SXin Li 41*67e74705SXin Li@interface SynthGetter : NSObject 42*67e74705SXin Li@property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair 43*67e74705SXin Li@property (nonatomic, retain) NSString* what; 44*67e74705SXin Li@end 45*67e74705SXin Li 46*67e74705SXin Li@implementation SynthGetter 47*67e74705SXin Li#if !__has_feature(objc_default_synthesize_properties) 48*67e74705SXin Li@synthesize howMany, what; 49*67e74705SXin Li#endif 50*67e74705SXin Li 51*67e74705SXin Li// - (int) howMany 52*67e74705SXin Li- (void) setHowMany: (int) value { 53*67e74705SXin Li self.howMany = value; 54*67e74705SXin Li} 55*67e74705SXin Li 56*67e74705SXin Li// - (NSString*) what 57*67e74705SXin Li- (void) setWhat: (NSString*) value { 58*67e74705SXin Li if (self.what != value) { 59*67e74705SXin Li } 60*67e74705SXin Li} 61*67e74705SXin Li@end 62*67e74705SXin Li 63*67e74705SXin Li 64*67e74705SXin Li@interface SynthNone : NSObject 65*67e74705SXin Li@property int howMany; 66*67e74705SXin Li@property (retain) NSString* what; 67*67e74705SXin Li@end 68*67e74705SXin Li 69*67e74705SXin Li@implementation SynthNone 70*67e74705SXin Li#if !__has_feature(objc_default_synthesize_properties) 71*67e74705SXin Li@synthesize howMany, what; // REM: Redundant anyway 72*67e74705SXin Li#endif 73*67e74705SXin Li 74*67e74705SXin Li- (int) howMany { 75*67e74705SXin Li return self.howMany; 76*67e74705SXin Li} 77*67e74705SXin Li- (void) setHowMany: (int) value { 78*67e74705SXin Li self.howMany = value; 79*67e74705SXin Li} 80*67e74705SXin Li 81*67e74705SXin Li- (NSString*) what { 82*67e74705SXin Li return self.what; 83*67e74705SXin Li} 84*67e74705SXin Li- (void) setWhat: (NSString*) value { 85*67e74705SXin Li if (self.what != value) { 86*67e74705SXin Li } 87*67e74705SXin Li} 88*67e74705SXin Li@end 89*67e74705SXin Li 90*67e74705SXin Li@protocol TopProtocol 91*67e74705SXin Li @property (readonly) id myString; 92*67e74705SXin Li@end 93*67e74705SXin Li 94*67e74705SXin Li@interface TopClass <TopProtocol> 95*67e74705SXin Li{ 96*67e74705SXin Li id myString; 97*67e74705SXin Li} 98*67e74705SXin Li@end 99*67e74705SXin Li 100*67e74705SXin Li@interface SubClass : TopClass <TopProtocol> 101*67e74705SXin Li@end 102*67e74705SXin Li 103*67e74705SXin Li@implementation SubClass @end 104*67e74705SXin Li 105*67e74705SXin Li// rdar://7920807 106*67e74705SXin Li@interface C @end 107*67e74705SXin Li@interface C (Category) 108*67e74705SXin Li@property int p; // expected-note 2 {{property declared here}} 109*67e74705SXin Li@end 110*67e74705SXin Li@implementation C (Category) // expected-warning {{property 'p' requires method 'p' to be defined}} \ 111*67e74705SXin Li // expected-warning {{property 'p' requires method 'setP:' to be defined}} 112*67e74705SXin Li@end 113*67e74705SXin Li 114*67e74705SXin Li// Don't complain if a property is already @synthesized by usr. 115*67e74705SXin Li@interface D 116*67e74705SXin Li{ 117*67e74705SXin Li} 118*67e74705SXin Li@property int PROP; 119*67e74705SXin Li@end 120*67e74705SXin Li 121*67e74705SXin Li@implementation D 122*67e74705SXin Li- (int) Meth { return self.PROP; } 123*67e74705SXin Li#if __has_feature(objc_default_synthesize_properties) 124*67e74705SXin Li@synthesize PROP=IVAR; 125*67e74705SXin Li#endif 126*67e74705SXin Li@end 127*67e74705SXin Li 128*67e74705SXin Li// rdar://10567333 129*67e74705SXin Li@protocol MyProtocol 130*67e74705SXin Li@property (nonatomic, strong) NSString *requiredString; // expected-note {{property declared here}} 131*67e74705SXin Li 132*67e74705SXin Li@optional 133*67e74705SXin Li@property (nonatomic, strong) NSString *optionalString; 134*67e74705SXin Li@end 135*67e74705SXin Li 136*67e74705SXin Li@interface MyClass <MyProtocol> 137*67e74705SXin Li@end 138*67e74705SXin Li 139*67e74705SXin Li@implementation MyClass // expected-warning {{auto property synthesis will not synthesize property 'requiredString' declared in protocol 'MyProtocol'}} 140*67e74705SXin Li@end 141*67e74705SXin Li 142*67e74705SXin Li// rdar://18152478 143*67e74705SXin Li@protocol NSObject @end 144*67e74705SXin Li@protocol TMSourceManagerDelegate<NSObject> 145*67e74705SXin Li@end 146*67e74705SXin Li 147*67e74705SXin Li@protocol TMSourceManager <NSObject> 148*67e74705SXin Li@property (nonatomic, assign) id <TMSourceManagerDelegate> delegate; 149*67e74705SXin Li@end 150*67e74705SXin Li 151*67e74705SXin Li@interface TMSourceManager 152*67e74705SXin Li@property (nonatomic, assign) id <TMSourceManagerDelegate> delegate; 153*67e74705SXin Li@end 154*67e74705SXin Li 155*67e74705SXin Li@protocol TMTimeZoneManager <TMSourceManager> 156*67e74705SXin Li@end 157*67e74705SXin Li 158*67e74705SXin Li@interface TimeZoneManager : TMSourceManager <TMTimeZoneManager> 159*67e74705SXin Li@end 160*67e74705SXin Li 161*67e74705SXin Li@implementation TimeZoneManager 162*67e74705SXin Li@end 163*67e74705SXin Li 164*67e74705SXin Li// rdar://18179833 165*67e74705SXin Li@protocol BaseProt 166*67e74705SXin Li@property (assign) id prot; 167*67e74705SXin Li@end 168*67e74705SXin Li 169*67e74705SXin Li@interface Base<BaseProt> 170*67e74705SXin Li@end 171*67e74705SXin Li 172*67e74705SXin Li@interface I : Base<BaseProt> 173*67e74705SXin Li@end 174*67e74705SXin Li 175*67e74705SXin Li@implementation I 176*67e74705SXin Li@end 177