PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / obj-c++.dg / private-2.mm
blob3e6ff118d23cfdc99afb4a0a6e58a09aaa65fbec
1 /* Test warnings for shadowing instance 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   /* FIXME: I wonder if the warnings shouldn't be better generated
26      when the variable is declared, rather than used!  */
27   int _private = 12;
28   int _protected = 12;
29   int _public = 12;
30   int a;
31   
32   a = _private;    /* { dg-warning "hides instance variable" } */
33   a = _protected;  /* { dg-warning "hides instance variable" } */
34   a = _public;     /* { dg-warning "hides instance variable" } */
36 @end
39 @interface MyClass : MySuperClass 
40 @end
42 @implementation MyClass
43 - (void) test
45   int _private = 12;
46   int _protected = 12;
47   int _public = 12;
48   int a;
50   /* The private variable can be shadowed without warnings, because
51    * it's invisible, and not accessible, to the subclass!  */
52   a = _private;   /* Ok  */
53   a = _protected; /* { dg-warning "hides instance variable" } */
54   a = _public;    /* { dg-warning "hides instance variable" } */
56 @end