PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / objc.dg / call-super-2.m
blobaf01d4453644e97dbef54f81a74a36b2e11a0368
1 /* Check if casting 'self' or 'super' affects message lookup in the correct way.  */
2 /* Contributed by Ziemowit Laski <zlaski@apple.com>.  */
3 /* { dg-do compile } */
5 #include "../objc-obj-c++-shared/TestsuiteObject.h"
6 #include "../objc-obj-c++-shared/runtime.h"
7 #include <stddef.h>
9 /* FIXME: This is temporary.  At the moment, the compiler, when
10    compiling for the GNU runtime and doing method checks, only
11    recognizes objc_get_class(), and not objc_getClass().  So
12    temporarily force objc_get_class() to be used.  */
13 #ifndef __NEXT_RUNTIME__
14 # define objc_getClass(C) objc_get_class(C)
15 #endif
17 @protocol Func
18 + (int) class_func0;
19 - (int) instance_func0;
20 @end
22 @interface Derived: TestsuiteObject
23 + (int) class_func1;
24 + (int) class_func2;
25 + (int) class_func3;
26 + (int) class_func4;
27 + (int) class_func5;
28 + (int) class_func6;
29 + (int) class_func7;
30 - (int) instance_func1;
31 - (int) instance_func2;
32 - (int) instance_func3;
33 - (int) instance_func4;
34 - (int) instance_func5;
35 - (int) instance_func6;
36 - (int) instance_func7;
37 @end
39 @interface Derived (Categ)
40 + (int) categ_class_func1;
41 + (int) categ_class_func2;
42 - (int) categ_instance_func1;
43 - (int) categ_instance_func2;
44 @end
46 @implementation Derived
47 + (int) class_func1
49    int i = (size_t)[self class_func0];       /* { dg-warning ".Derived. may not respond to .\\+class_func0." } */
50    return i + (size_t)[super class_func0];   /* { dg-warning ".TestsuiteObject. may not respond to .\\+class_func0." } */
52 + (int) class_func2
54    int i = [(id <Func>)self class_func0];  /* { dg-warning ".\\-class_func0. not found in protocol" } */
55    i += [(id <Func>)super class_func0];    /* { dg-warning ".\\-class_func0. not found in protocol" } */
56    i += [(Class <Func>)self class_func0];
57    return i + [(Class <Func>)super class_func0];
59 + (int) class_func3
61    return [(TestsuiteObject <Func> *)super class_func0];
63 + (int) class_func4
65    return [(Derived <Func> *)super class_func0];
66 }   
67 + (int) class_func5
69    int i = (size_t)[Derived class_func0];    /* { dg-warning ".Derived. may not respond to .\\+class_func0." } */
70    return i + (size_t)[TestsuiteObject class_func0];  /* { dg-warning ".TestsuiteObject. may not respond to .\\+class_func0." } */
72 + (int) class_func6
74    return (size_t)[objc_getClass("TestsuiteObject") class_func1];  /* { dg-warning ".TestsuiteObject. may not respond to .\\+class_func1." } */
76 + (int) class_func7
78    return [objc_getClass("Derived") class_func1];
80 - (int) instance_func1
82    int i = (size_t)[self instance_func0];     /* { dg-warning ".Derived. may not respond to .\\-instance_func0." } */
83    return i + (size_t)[super instance_func0]; /* { dg-warning ".TestsuiteObject. may not respond to .\\-instance_func0." } */
85 - (int) instance_func2
87    return [(id <Func>)super instance_func0];
89 - (int) instance_func3
91    return [(TestsuiteObject <Func> *)super instance_func0];
93 - (int) instance_func4
95    return [(Derived <Func> *)super instance_func0];
96 }   
97 - (int) instance_func5
99    int i = (size_t)[Derived instance_func1]; /* { dg-warning ".Derived. may not respond to .\\+instance_func1." } */
100    return i + (size_t)[TestsuiteObject instance_func1]; /* { dg-warning ".TestsuiteObject. may not respond to .\\+instance_func1." } */
102 - (int) instance_func6
104    return (size_t)[objc_getClass("TestsuiteObject") class_func1]; /* { dg-warning ".TestsuiteObject. may not respond to .\\+class_func1." } */
106 - (int) instance_func7
108    return [objc_getClass("Derived") class_func1];
110 @end
112 @implementation Derived (Categ)
113 + (int) categ_class_func1
115    int i = (size_t)[self class_func0];       /* { dg-warning ".Derived. may not respond to .\\+class_func0." } */
116    i += [self class_func1];
117    i += [self categ_class_func2];
118    i += (size_t)[self categ_instance_func1]; /* { dg-warning ".Derived. may not respond to .\\+categ_instance_func1." } */
119    return i + (size_t)[super class_func0];   /* { dg-warning ".TestsuiteObject. may not respond to .\\+class_func0." } */
121 + (int) categ_class_func2
123    int i = [(id <Func>)self class_func0];  /* { dg-warning ".\\-class_func0. not found in protocol" } */
124    i += [(id <Func>)super class_func0];    /* { dg-warning ".\\-class_func0. not found in protocol" } */
125    i += [(Class <Func>)self class_func0];
126    return i + [(Class <Func>)super class_func0];
128 - (int) categ_instance_func1
130    int i = (size_t)[self instance_func0];    /* { dg-warning ".Derived. may not respond to .\\-instance_func0." } */
131    i += [(Derived <Func> *)self categ_instance_func2];
132    i += (size_t)[(TestsuiteObject <Func> *)self categ_instance_func2]; /* { dg-warning ".TestsuiteObject. may not respond to .\\-categ_instance_func2." } */
133    /* { dg-warning ".\\-categ_instance_func2. not found in protocol" "" { target *-*-* } .-1 } */
134    i += (size_t)[(id <Func>)self categ_instance_func2];  /* { dg-warning ".\\-categ_instance_func2. not found in protocol" } */
135    i += [(id)self categ_instance_func2];
136    return i + (size_t)[super instance_func0];   /* { dg-warning ".TestsuiteObject. may not respond to .\\-instance_func0." } */
138 - (int) categ_instance_func2
140    return [(id <Func>)super instance_func0];
142 @end
144 /* { dg-warning "Messages without a matching method signature" "" { target *-*-* } 0 } */
145 /* { dg-warning "will be assumed to return .id. and accept" "" { target *-*-* } 0 } */
146 /* { dg-warning ".\.\.\.. as arguments" "" { target *-*-* } 0 } */