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