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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [obj-c++.dg/] [private-2.mm] - Blame information for rev 832

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

Line No. Rev Author Line
1 149 jeremybenn
/* Test warnings for shadowing instance variables.  */
2
/* Based on work by: Nicola Pero .  */
3
 
4
/* { dg-do compile } */
5
 
6
#include 
7
 
8
@interface MySuperClass
9
{
10
@private
11
  int _private;
12
 
13
@protected
14
  int _protected;
15
 
16
@public
17
  int _public;
18
}
19
- (void) test;
20
@end
21
 
22
@implementation MySuperClass
23
- (void) test
24
{
25
  /* FIXME: I wonder if the warnings shouldn't be better generated
26
     when the variable is declared, rather than used!  */
27
  int _private = 12;
28
  int _protected = 12;
29
  int _public = 12;
30
  int a;
31
 
32
  a = _private;    /* { dg-warning "hides instance variable" } */
33
  a = _protected;  /* { dg-warning "hides instance variable" } */
34
  a = _public;     /* { dg-warning "hides instance variable" } */
35
}
36
@end
37
 
38
 
39
@interface MyClass : MySuperClass
40
@end
41
 
42
@implementation MyClass
43
- (void) test
44
{
45
  int _private = 12;
46
  int _protected = 12;
47
  int _public = 12;
48
  int a;
49
 
50
  /* The private variable can be shadowed without warnings, because
51
   * it's invisible, and not accessible, to the subclass!  */
52
  a = _private;   /* Ok  */
53
  a = _protected; /* { dg-warning "hides instance variable" } */
54
  a = _public;    /* { dg-warning "hides instance variable" } */
55
}
56
@end

powered by: WebSVN 2.1.0

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