blob: ba2f11594f96c918ce6342bd9a21354f5a565556 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Fariborz Jahanian077c1e72009-03-02 21:55:29 +00002
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 {
John McCallba135432009-11-21 08:51:07 +000018 sprite = foo; // expected-error {{instance variable 'sprite' accessed in class method}}
Fariborz Jahanian077c1e72009-03-02 21:55:29 +000019 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