1 /* Test for ivar access inside of class methods. It should be allowed (with a warning), but only
2 if no other declarations with the same name are seen. */
3 /* Author: Ziemowit Laski <zlaski@apple.com>. */
4 /* { dg-do compile } */
6 #include <objc/Object.h>
8 @interface Sprite: Object {
11 + (void)setFoo:(int)foo;
12 + (void)setSprite:(int)sprite;
13 - (void)setFoo:(int)foo;
14 - (void)setSprite:(int)sprite;
19 @implementation Sprite
20 + (void)setFoo:(int)foo {
21 sprite = foo; /* { dg-warning "instance variable .sprite. accessed in class method" } */
24 + (void)setSprite:(int)sprite {
28 ((Sprite *)self)->sprite = 16; /* NB: This is how one _should_ access */
29 ((Sprite *)self)->spree = 18; /* ivars from within class methods! */
31 - (void)setFoo:(int)foo {
35 - (void)setSprite:(int)sprite {
37 sprite = 15; /* { dg-warning "local declaration of .sprite. hides instance variable" } */
39 spree = 17; /* { dg-warning "local declaration of .spree. hides instance variable" } */