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