1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -verify -fsyntax-only -Wno-objc-root-class %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambucvoid abort(void); 4*f4a2713aSLionel Sambuc 5*f4a2713aSLionel Sambuc@interface Subclass 6*f4a2713aSLionel Sambuc+ (int)magicNumber; 7*f4a2713aSLionel Sambuc+ (void)setMagicNumber:(int)value; 8*f4a2713aSLionel Sambuc+ (void)setFakeSetterNumber:(int)value; 9*f4a2713aSLionel Sambuc@end 10*f4a2713aSLionel Sambuc 11*f4a2713aSLionel Sambuc@implementation Subclass 12*f4a2713aSLionel Sambucint _magicNumber = 0; 13*f4a2713aSLionel Sambuc+ (int)magicNumber { 14*f4a2713aSLionel Sambuc return _magicNumber; 15*f4a2713aSLionel Sambuc} 16*f4a2713aSLionel Sambuc 17*f4a2713aSLionel Sambuc+ (void)setMagicNumber:(int)value { 18*f4a2713aSLionel Sambuc _magicNumber = value; 19*f4a2713aSLionel Sambuc} 20*f4a2713aSLionel Sambuc 21*f4a2713aSLionel Sambuc+ (void)setFakeSetterNumber:(int)value { 22*f4a2713aSLionel Sambuc _magicNumber = value; 23*f4a2713aSLionel Sambuc} 24*f4a2713aSLionel Sambuc 25*f4a2713aSLionel Sambuc+ (void) classMeth 26*f4a2713aSLionel Sambuc{ 27*f4a2713aSLionel Sambuc self.magicNumber = 10; 28*f4a2713aSLionel Sambuc if (self.magicNumber != 10) 29*f4a2713aSLionel Sambuc abort (); 30*f4a2713aSLionel Sambuc} 31*f4a2713aSLionel Sambuc@end 32*f4a2713aSLionel Sambuc 33*f4a2713aSLionel Sambucint main (void) { 34*f4a2713aSLionel Sambuc 35*f4a2713aSLionel Sambuc int a; 36*f4a2713aSLionel Sambuc Subclass.magicNumber = 2 /*[Subclass setMagicNumber:2]*/; 37*f4a2713aSLionel Sambuc if (Subclass.magicNumber != 0) 38*f4a2713aSLionel Sambuc abort (); 39*f4a2713aSLionel Sambuc if (Subclass.magicNumber != 2) 40*f4a2713aSLionel Sambuc abort (); 41*f4a2713aSLionel Sambuc Subclass.magicNumber += 3; 42*f4a2713aSLionel Sambuc if (Subclass.magicNumber != 5) 43*f4a2713aSLionel Sambuc abort (); 44*f4a2713aSLionel Sambuc Subclass.magicNumber -= 5; 45*f4a2713aSLionel Sambuc if (Subclass.magicNumber != 0) 46*f4a2713aSLionel Sambuc abort (); 47*f4a2713aSLionel Sambuc /* We only have a setter in the following case. */ 48*f4a2713aSLionel Sambuc Subclass.fakeSetterNumber = 123; 49*f4a2713aSLionel Sambuc 50*f4a2713aSLionel Sambuc /* We read it using the other getter. */ 51*f4a2713aSLionel Sambuc if (Subclass.magicNumber != 123) 52*f4a2713aSLionel Sambuc abort (); 53*f4a2713aSLionel Sambuc Subclass.fakeSetterNumber = Subclass.magicNumber; 54*f4a2713aSLionel Sambuc if (Subclass.magicNumber != 123) 55*f4a2713aSLionel Sambuc abort (); 56*f4a2713aSLionel Sambuc 57*f4a2713aSLionel Sambuc Subclass.fakeSetterNumberX = 123; // expected-error{{property 'fakeSetterNumberX' not found on object of type 'Subclass'}} 58*f4a2713aSLionel Sambuc 59*f4a2713aSLionel Sambuc /* Test class methods using the new syntax. */ 60*f4a2713aSLionel Sambuc [Subclass classMeth]; 61*f4a2713aSLionel Sambuc return 0; 62*f4a2713aSLionel Sambuc} 63