1*67e74705SXin Li// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-unreachable-code 2*67e74705SXin Li// expected-no-diagnostics 3*67e74705SXin Li 4*67e74705SXin Li@interface NSObject 5*67e74705SXin Li+ alloc; 6*67e74705SXin Li- init; 7*67e74705SXin Li@end 8*67e74705SXin Li 9*67e74705SXin Li@protocol Test 10*67e74705SXin Li @property int required; 11*67e74705SXin Li 12*67e74705SXin Li@optional 13*67e74705SXin Li @property int optional; 14*67e74705SXin Li @property int optional1; 15*67e74705SXin Li @property int optional_preexisting_setter_getter; 16*67e74705SXin Li @property (setter = setOptional_preexisting_setter_getter: , 17*67e74705SXin Li getter = optional_preexisting_setter_getter) int optional_with_setter_getter_attr; 18*67e74705SXin Li@required 19*67e74705SXin Li @property int required1; 20*67e74705SXin Li@optional 21*67e74705SXin Li @property int optional_to_be_defined; 22*67e74705SXin Li @property (readonly, getter = optional_preexisting_setter_getter) int optional_getter_attr; 23*67e74705SXin Li@end 24*67e74705SXin Li 25*67e74705SXin Li@interface Test : NSObject <Test> { 26*67e74705SXin Li int ivar; 27*67e74705SXin Li int ivar1; 28*67e74705SXin Li int ivar2; 29*67e74705SXin Li} 30*67e74705SXin Li@property int required; 31*67e74705SXin Li@property int optional_to_be_defined; 32*67e74705SXin Li- (int) optional_preexisting_setter_getter; 33*67e74705SXin Li- (void) setOptional_preexisting_setter_getter:(int)value; 34*67e74705SXin Li@end 35*67e74705SXin Li 36*67e74705SXin Li@implementation Test 37*67e74705SXin Li@synthesize required = ivar; 38*67e74705SXin Li@synthesize required1 = ivar1; 39*67e74705SXin Li@synthesize optional_to_be_defined = ivar2; 40*67e74705SXin Li- (int) optional_preexisting_setter_getter { return ivar; } 41*67e74705SXin Li- (void) setOptional_preexisting_setter_getter:(int)value 42*67e74705SXin Li { 43*67e74705SXin Li ivar = value; 44*67e74705SXin Li } 45*67e74705SXin Li- (void) setOptional_getter_attr:(int)value { ivar = value; } 46*67e74705SXin Li@end 47*67e74705SXin Li 48*67e74705SXin Livoid abort(void); 49*67e74705SXin Liint main () 50*67e74705SXin Li{ 51*67e74705SXin Li Test *x = [[Test alloc] init]; 52*67e74705SXin Li /* 1. Test of a required property */ 53*67e74705SXin Li x.required1 = 100; 54*67e74705SXin Li if (x.required1 != 100) 55*67e74705SXin Li abort (); 56*67e74705SXin Li 57*67e74705SXin Li /* 2. Test of a synthesize optional property */ 58*67e74705SXin Li x.optional_to_be_defined = 123; 59*67e74705SXin Li if (x.optional_to_be_defined != 123) 60*67e74705SXin Li abort (); 61*67e74705SXin Li 62*67e74705SXin Li /* 3. Test of optional property with pre-sxisting defined setter/getter */ 63*67e74705SXin Li x.optional_preexisting_setter_getter = 200; 64*67e74705SXin Li if (x.optional_preexisting_setter_getter != 200) 65*67e74705SXin Li abort (); 66*67e74705SXin Li 67*67e74705SXin Li /* 4. Test of optional property with setter/getter attribute */ 68*67e74705SXin Li if (x.optional_with_setter_getter_attr != 200) 69*67e74705SXin Li abort (); 70*67e74705SXin Li return 0; 71*67e74705SXin Li 72*67e74705SXin Li /* 5. Test of optional property with getter attribute and default setter method. */ 73*67e74705SXin Li x.optional_getter_attr = 1000; 74*67e74705SXin Li if (x.optional_getter_attr != 1000) 75*67e74705SXin Li abort (); 76*67e74705SXin Li 77*67e74705SXin Li return 0; 78*67e74705SXin Li} 79*67e74705SXin Li 80