2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / objc.dg / call-super-3.m
blob05b6233ff5f301190c27b9b5978b65d5c895e18e
1 /* Check if sending messages to super does not interfere with sending messages
2    to classes. */
3 /* Contributed by Ziemowit Laski <zlaski@apple.com>.  */
4 /* { dg-do run } */
5 /* { dg-options "-lobjc" } */
7 #include <objc/Object.h>
9 extern void abort(void);
10 #define CHECK_IF(expr) if(!(expr)) abort()
12 @interface Base: Object
13 + (int) class_func1;
14 - (int) instance_func1;
15 @end
17 @interface Derived: Base
18 + (int) class_func1;
19 @end
21 @interface Derived (Categ)
22 - (int) instance_func1;
23 @end
25 @implementation Base
26 + (int) class_func1 { return 234; }
27 - (int) instance_func1 { return 345; }
28 @end
30 @implementation Derived
31 + (int) class_func1 { 
32   int i = [super class_func1];
33   i += [Base class_func1];
34   return i;
36 @end
38 @implementation Derived (Categ)
39 - (int) instance_func1 { 
40   int i = [super instance_func1];
41   i += [Base class_func1];  /* { dg-bogus "invalid receiver type" } */
42   return i;
44 @end
46 int main(void) {
47   Base *base = [[Base alloc] init];  /* { dg-bogus "invalid receiver type" } */
48   Derived *derived = [[Derived alloc] init];
49   CHECK_IF([Base class_func1] == 234);  /* { dg-bogus "invalid receiver type" } */
50   CHECK_IF([Derived class_func1] == 234 + 234);
51   CHECK_IF([base instance_func1] == 345);
52   CHECK_IF([derived instance_func1] == 234 + 345);
53   return 0;