OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [objc.dg/] [local-decl-2.m] - Blame information for rev 841

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* 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 } */
5
 
6
#include <objc/Object.h>
7
 
8
@interface Sprite: Object {
9
  int sprite, spree;
10
}
11
+ (void)setFoo:(int)foo;
12
+ (void)setSprite:(int)sprite;
13
- (void)setFoo:(int)foo;
14
- (void)setSprite:(int)sprite;
15
@end
16
 
17
int spree = 23;
18
 
19
@implementation Sprite
20
+ (void)setFoo:(int)foo {
21
  sprite = foo;  /* { dg-warning "instance variable .sprite. accessed in class method" } */
22
  spree = foo;
23
}
24
+ (void)setSprite:(int)sprite {
25
  int spree;
26
  sprite = 15;
27
  spree = 17;
28
  ((Sprite *)self)->sprite = 16;   /* NB: This is how one _should_ access */
29
  ((Sprite *)self)->spree = 18;    /* ivars from within class methods!    */
30
}
31
- (void)setFoo:(int)foo {
32
  sprite = foo;
33
  spree = foo;
34
}
35
- (void)setSprite:(int)sprite {
36
  int spree;
37
  sprite = 15;  /* { dg-warning "local declaration of .sprite. hides instance variable" } */
38
  self->sprite = 16;
39
  spree = 17;  /* { dg-warning "local declaration of .spree. hides instance variable" } */
40
  self->spree = 18;
41
}
42
@end

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.