OSDN Git Service

* gcc.target/i386/pr34256.c: Update number of mov insns
[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
6 #include <objc/Object.h>
7 #include <stdlib.h>
8 #define CHECK_IF(expr) if(!(expr)) abort()
9
10 @interface _Child: Object
11 + (int) flashCache;
12 @end
13
14 @interface Child: _Child
15 + (int) flushCache1;
16 @end
17
18 @interface Child (Categ)
19 + (int) flushCache2;
20 @end
21
22 int _Object = 23;  /* Should not conflict with @interface Object.  */
23
24 @implementation _Child
25 + (int) flashCache { return 12 + _Object; }
26 @end
27
28 @implementation Child
29 + (int) flushCache1 { return 7 + [super flashCache]; }
30 @end
31
32 @implementation Child (Categ)
33 + (int) flushCache2 { return 9 + [super flashCache]; }
34 @end
35
36 int main(void) {
37   CHECK_IF([_Child flashCache] == 35);
38   CHECK_IF([Child flushCache1] == 42);
39   CHECK_IF([Child flushCache2] == 44);
40
41   return 0; 
42 }
43