Debian Codegraph @

gcc/testsuite/objc.dg/ivar-scope-3.m

raw
1 /* Test instance variable scope. */
2 /* Author: Dimitris Papavasiliou <[email protected]>. */
3 /* { dg-do run } */
4 /* { dg-additional-options "-Wno-shadow-ivar" } */
5 #include "../objc-obj-c++-shared/TestsuiteObject.m"
6 #include <objc/objc.h>
7
8 extern void abort(void);
9
10 int someivar = 1;
11
12 @interface MyClass: TestsuiteObject
13 {
14 int someivar;
15 }
16 - (int) get;
17 - (int) getHidden;
18 @end
19
20 @implementation MyClass
21 - init
22 {
23 someivar = 2;
24
25 return self;
26 }
27
28 - (int) get
29 {
30 return someivar;
31 }
32
33 - (int) getHidden
34 {
35 int someivar = 3;
36
37 return someivar;
38 }
39 @end
40
41 int main(void)
42 {
43 MyClass *object;
44
45 object = [[MyClass alloc] init];
46
47 /* Check whether the instance variable hides the global variable. */
48
49 if ([object get] != 2) {
50 abort();
51 }
52
53 /* Check whether the local variable hides the instance variable. */
54
55 if ([object getHidden] != 3) {
56 abort();
57 }
58
59 return 0;
60 }