[RISC-V] Avoid unnecessary extensions when value is already extended
[official-gcc.git] / gcc / testsuite / objc.dg / private-2.m
blobd0646f5ca68fcb245d388e250f36f123c23e9295
1 /* Test warnings for shadowing instance variables.  */
2 /* Author: Nicola Pero <nicola@brainstorm.co.uk>.  */
3 /* { dg-do compile } */
4 /* { dg-additional-options "-Wno-objc-root-class" } */
5 #include <objc/objc.h>
7 @interface MySuperClass
9 @private
10   int private;
12 @protected
13   int protected;
15 @public
16   int public;
18 - (void) test;
19 @end
21 @implementation MySuperClass
22 - (void) test
24   /* FIXME: I wonder if the warnings shouldn't be better generated
25      when the variable is declared, rather than used!  */
26   int private = 12;
27   int protected = 12;
28   int public = 12;
29   int a;
30   
31   a = private;    /* { dg-warning "hides instance variable" } */
32   a = protected;  /* { dg-warning "hides instance variable" } */
33   a = public;     /* { dg-warning "hides instance variable" } */
35 @end
38 @interface MyClass : MySuperClass 
39 @end
41 @implementation MyClass
42 - (void) test
44   int private = 12;
45   int protected = 12;
46   int public = 12;
47   int a;
49   /* The private variable can be shadowed without warnings, because
50    * it's invisible, and not accessible, to the subclass!  */
51   a = private;   /* Ok  */
52   a = protected; /* { dg-warning "hides instance variable" } */
53   a = public;    /* { dg-warning "hides instance variable" } */
55 @end