OSDN Git Service

In gcc/objc/:
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / objc.dg / super-class-3.m
1 /* Ensure that the compiler does not emit spurious extern declarations named '_Foo', where 'Foo'
2    is an ObjC class name.  */
3 /* Contributed by Ziemowit Laski <zlaski@apple.com>.  */
4 /* { dg-do run } */
5 /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
6
7 #include "../objc-obj-c++-shared/Object1.h"
8
9 #include <stdlib.h>
10 #define CHECK_IF(expr) if(!(expr)) abort()
11
12 @interface _Child: Object
13 + (int) flashCache;
14 @end
15
16 @interface Child: _Child
17 + (int) flushCache1;
18 @end
19
20 @interface Child (Categ)
21 + (int) flushCache2;
22 @end
23
24 int _Object = 23;  /* Should not conflict with @interface Object.  */
25
26 @implementation _Child
27 + (int) flashCache { return 12 + _Object; }
28 @end
29
30 @implementation Child
31 + (int) flushCache1 { return 7 + [super flashCache]; }
32 @end
33
34 @implementation Child (Categ)
35 + (int) flushCache2 { return 9 + [super flashCache]; }
36 @end
37
38 int main(void) {
39   CHECK_IF([_Child flashCache] == 35);
40   CHECK_IF([Child flushCache1] == 42);
41   CHECK_IF([Child flushCache2] == 44);
42
43   return 0; 
44 }
45
46 #include "../objc-obj-c++-shared/Object1-implementation.h"