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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [obj-c++.dg/] [private-1.mm] - Blame information for rev 703

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 703 jeremybenn
/* Test errors for accessing @private and @protected variables.  */
2
/* Based on work by: Nicola Pero .  */
3
/* { dg-do compile } */
4
#include 
5
 
6
@interface MySuperClass
7
{
8
@private
9
  int _private;
10
 
11
@protected
12
  int _protected;
13
 
14
@public
15
  int _public;
16
}
17
- (void) test;
18
@end
19
 
20
@implementation MySuperClass
21
- (void) test
22
{
23
  _private = 12;   /* Ok  */
24
  _protected = 12; /* Ok  */
25
  _public = 12;    /* Ok  */
26
}
27
@end
28
 
29
 
30
@interface MyClass : MySuperClass
31
@end
32
 
33
@implementation MyClass
34
- (void) test
35
{
36
  /* Private variables simply don't exist in the subclass.  */
37
  _private = 12; /* { dg-error "instance variable \\'_private\\' is declared private" } */
38
 
39
  _protected = 12; /* Ok  */
40
  _public = 12;    /* Ok  */
41
}
42
@end
43
 
44
int main (void)
45
{
46
  MyClass *m = nil;
47
 
48
  if (m != nil)
49
    {
50
      int access;
51
 
52
      access = m->_private;   /* { dg-warning "is @private" }  */
53
      access = m->_protected; /* { dg-warning "is @protected" }  */
54
      access = m->_public;    /* Ok  */
55
    }
56
 
57
  return 0;
58
}

powered by: WebSVN 2.1.0

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