* lto.c (do_stream_out): Add PART parameter; open dump file.
[official-gcc.git] / gcc / testsuite / obj-c++.dg / private-1.mm
blob0c25aea5566d9250b88059222b6dfab43e039381
1 /* Test errors for accessing @private and @protected variables.  */
2 /* Based on work by: Nicola Pero <nicola@brainstorm.co.uk>.  */
3 /* { dg-do compile } */
4 #include <objc/objc.h>
6 @interface MySuperClass
8 @private
9   int _private;
11 @protected
12   int _protected;
14 @public
15   int _public;
17 - (void) test;
18 @end
20 @implementation MySuperClass
21 - (void) test
23   _private = 12;   /* Ok  */
24   _protected = 12; /* Ok  */
25   _public = 12;    /* Ok  */
27 @end
30 @interface MyClass : MySuperClass 
31 @end
33 @implementation MyClass
34 - (void) test
36   /* Private variables simply don't exist in the subclass.  */
37   _private = 12; /* { dg-error "instance variable \\'_private\\' is declared private" } */
39   _protected = 12; /* Ok  */
40   _public = 12;    /* Ok  */
42 @end
44 int main (void)
46   MyClass *m = nil;
47   
48   if (m != nil)
49     {
50       int access;
52       access = m->_private;   /* { dg-warning "is @private" }  */
53       access = m->_protected; /* { dg-warning "is @protected" }  */
54       access = m->_public;    /* Ok  */
55     }
57   return 0;