Debian Codegraph @

gcc/testsuite/objc.dg/property/dotsyntax-10.m

raw
1 /* Contributed by Nicola Pero <[email protected]>, November 2010. */
2 /* { dg-do run } */
3 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
4
5 /* Test dot-syntax with 'super'. */
6
7 #include <stdlib.h>
8 #include <objc/objc.h>
9 #include <objc/runtime.h>
10
11 static int c;
12
13 @interface MyRootClass
14 {
15 Class isa;
16 int a;
17 }
18 + (id) initialize;
19 + (id) alloc;
20 - (id) init;
21 - (int) count;
22 - (void) setCount: (int)count;
23 + (int) classCount;
24 + (void) setClassCount: (int)count;
25 @end
26
27 @implementation MyRootClass
28 + (id) initialize { return self; }
29 + (id) alloc { return class_createInstance (self, 0); }
30 - (id) init { return self; }
31 - (int) count
32 {
33 return a;
34 }
35 - (void) setCount: (int)count
36 {
37 a = count;
38 }
39 + (int) classCount
40 {
41 return c;
42 }
43 + (void) setClassCount: (int)count
44 {
45 c = count;
46 }
47 @end
48
49 @interface MySubClass : MyRootClass
50 + (int) testMe;
51 - (int) testMe;
52 @end
53
54 @implementation MySubClass
55 - (int) testMe
56 {
57 super.count = 400;
58 if (super.count != 400)
59 abort ();
60
61 return super.count;
62 }
63 + (int) testMe
64 {
65 super.classCount = 4000;
66 if (super.classCount != 4000)
67 abort ();
68
69 return super.classCount;
70 }
71 @end
72
73 int main (void)
74 {
75 MySubClass *object = [[MySubClass alloc] init];
76
77 if ([object testMe] != 400)
78 abort ();
79
80 if ([MySubClass testMe] != 4000)
81 abort ();
82
83 return 0;
84 }
85
86