Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / obj-c++.dg / local-decl-1.mm
blob0d7389d2c2fa80b0c238edc288ebe706ab8d895d
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
3    name are seen.  */
4 /* Author: Ziemowit Laski <zlaski@apple.com>.  */
6 /* { dg-do compile } */
8 #include <objc/Object.h>
10 @interface Sprite: Object {
11   int sprite, spree;
13 + (void)setFoo:(int)foo;
14 + (void)setSprite:(int)sprite;
15 - (void)setFoo:(int)foo;
16 - (void)setSprite:(int)sprite;
17 @end
19 int spree = 23;
21 @implementation Sprite
22 + (void)setFoo:(int)foo {
23   sprite = foo;  /* { dg-warning "instance variable .sprite. accessed in class method" } */
24   spree = foo;
26 + (void)setSprite:(int)sprite {
27   int spree;
28   sprite = 15;
29   spree = 17;
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 {
34   sprite = foo;
35   spree = foo;
37 - (void)setSprite:(int)sprite {
38   int spree;
39   sprite = 15;  /* { dg-warning "local declaration of .sprite. hides instance variable" } */
40   self->sprite = 16;
41   spree = 17;  /* { dg-warning "local declaration of .spree. hides instance variable" } */
42   self->spree = 18;
43 }   
44 @end