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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [objc.dg/] [private-1.m] - Blame information for rev 774

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

Line No. Rev Author Line
1 704 jeremybenn
/* Test errors for accessing @private and @protected variables.  */
2
/* Author: Nicola Pero <nicola@brainstorm.co.uk>.  */
3
/* { dg-do compile } */
4
#include <objc/objc.h>
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" } */
38
  /* { dg-message "function it appears in" "" { target *-*-* } { 37 } } */
39
 
40
  protected = 12; /* Ok  */
41
  public = 12;    /* Ok  */
42
}
43
@end
44
 
45
int main (void)
46
{
47
  MyClass *m = nil;
48
 
49
  if (m != nil)
50
    {
51
      int access;
52
 
53
      access = m->private;   /* { dg-warning "is @private" }  */
54
      access = m->protected; /* { dg-warning "is @protected" }  */
55
      access = m->public;    /* Ok  */
56
    }
57
 
58
  return 0;
59
}

powered by: WebSVN 2.1.0

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