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