1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s 2*f4a2713aSLionel Sambuc 3*f4a2713aSLionel Sambuc@interface Sprite { 4*f4a2713aSLionel Sambuc int sprite, spree; 5*f4a2713aSLionel Sambuc int UseGlobalBar; 6*f4a2713aSLionel Sambuc} 7*f4a2713aSLionel Sambuc+ (void)setFoo:(int)foo; 8*f4a2713aSLionel Sambuc+ (void)setSprite:(int)sprite; 9*f4a2713aSLionel Sambuc- (void)setFoo:(int)foo; 10*f4a2713aSLionel Sambuc- (void)setSprite:(int)sprite; 11*f4a2713aSLionel Sambuc@end 12*f4a2713aSLionel Sambuc 13*f4a2713aSLionel Sambucint spree = 23; 14*f4a2713aSLionel Sambucint UseGlobalBar; 15*f4a2713aSLionel Sambuc 16*f4a2713aSLionel Sambuc@implementation Sprite 17*f4a2713aSLionel Sambuc+ (void)setFoo:(int)foo { 18*f4a2713aSLionel Sambuc sprite = foo; // expected-error {{instance variable 'sprite' accessed in class method}} 19*f4a2713aSLionel Sambuc spree = foo; 20*f4a2713aSLionel Sambuc Xsprite = foo; // expected-error {{use of undeclared identifier 'Xsprite'}} 21*f4a2713aSLionel Sambuc UseGlobalBar = 10; 22*f4a2713aSLionel Sambuc} 23*f4a2713aSLionel Sambuc+ (void)setSprite:(int)sprite { 24*f4a2713aSLionel Sambuc int spree; 25*f4a2713aSLionel Sambuc sprite = 15; 26*f4a2713aSLionel Sambuc spree = 17; 27*f4a2713aSLionel Sambuc ((Sprite *)self)->sprite = 16; /* NB: This is how one _should_ access */ 28*f4a2713aSLionel Sambuc ((Sprite *)self)->spree = 18; /* ivars from within class methods! */ 29*f4a2713aSLionel Sambuc} 30*f4a2713aSLionel Sambuc- (void)setFoo:(int)foo { 31*f4a2713aSLionel Sambuc sprite = foo; 32*f4a2713aSLionel Sambuc spree = foo; 33*f4a2713aSLionel Sambuc} 34*f4a2713aSLionel Sambuc- (void)setSprite:(int)sprite { 35*f4a2713aSLionel Sambuc int spree; 36*f4a2713aSLionel Sambuc sprite = 15; // expected-warning {{local declaration of 'sprite' hides instance variable}} 37*f4a2713aSLionel Sambuc self->sprite = 16; 38*f4a2713aSLionel Sambuc spree = 17; // expected-warning {{local declaration of 'spree' hides instance variable}} 39*f4a2713aSLionel Sambuc self->spree = 18; 40*f4a2713aSLionel Sambuc} 41*f4a2713aSLionel Sambuc@end 42