Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / obj-c++.dg / private-1.mm
blobc4ec5ffb9b1baabe1442a65f8141f13098d2a168
1 /* Test errors for accessing @private and @protected variables.  */
2 /* Based on work by: Nicola Pero <nicola@brainstorm.co.uk>.  */
4 /* { dg-do compile } */
6 #include <objc/objc.h>
8 @interface MySuperClass
10 @private
11   int _private;
13 @protected
14   int _protected;
16 @public
17   int _public;
19 - (void) test;
20 @end
22 @implementation MySuperClass
23 - (void) test
25   _private = 12;   /* Ok  */
26   _protected = 12; /* Ok  */
27   _public = 12;    /* Ok  */
29 @end
32 @interface MyClass : MySuperClass 
33 @end
35 @implementation MyClass
36 - (void) test
38   /* Private variables simply don't exist in the subclass.  */
39   _private = 12; /* { dg-error "._private. was not declared in this scope" } */
41   _protected = 12; /* Ok  */
42   _public = 12;    /* Ok  */
44 @end
46 int main (void)
48   MyClass *m = nil;
49   
50   if (m != nil)
51     {
52       int access;
54       access = m->_private;   /* { dg-error "is @private" }  */
55       access = m->_protected; /* { dg-error "is @protected" }  */
56       access = m->_public;    /* Ok  */
57     }
59   return 0;