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-1.mm] - Blame information for rev 820

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

Line No. Rev Author Line
1 149 jeremybenn
/* Test errors for accessing @private and @protected 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
  _private = 12;   /* Ok  */
26
  _protected = 12; /* Ok  */
27
  _public = 12;    /* Ok  */
28
}
29
@end
30
 
31
 
32
@interface MyClass : MySuperClass
33
@end
34
 
35
@implementation MyClass
36
- (void) test
37
{
38
  /* Private variables simply don't exist in the subclass.  */
39
  _private = 12; /* { dg-error "._private. was not declared in this scope" } */
40
 
41
  _protected = 12; /* Ok  */
42
  _public = 12;    /* Ok  */
43
}
44
@end
45
 
46
int main (void)
47
{
48
  MyClass *m = nil;
49
 
50
  if (m != nil)
51
    {
52
      int access;
53
 
54
      access = m->_private;   /* { dg-error "is @private" }  */
55
      access = m->_protected; /* { dg-error "is @protected" }  */
56
      access = m->_public;    /* Ok  */
57
    }
58
 
59
  return 0;
60
}

powered by: WebSVN 2.1.0

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