1 /* Check if casting 'self' or 'super' affects message lookup in the
3 /* Contributed by Ziemowit Laski <zlaski@apple.com>. */
4 /* { dg-do compile } */
7 #include <objc/Object.h>
9 #ifdef __NEXT_RUNTIME__
10 #define OBJC_GETCLASS objc_getClass
12 #define OBJC_GETCLASS objc_get_class
17 - (int) instance_func0;
20 @interface Derived: Object
28 - (int) instance_func1;
29 - (int) instance_func2;
30 - (int) instance_func3;
31 - (int) instance_func4;
32 - (int) instance_func5;
33 - (int) instance_func6;
34 - (int) instance_func7;
37 @interface Derived (Categ)
38 + (int) categ_class_func1;
39 + (int) categ_class_func2;
40 - (int) categ_instance_func1;
41 - (int) categ_instance_func2;
44 @implementation Derived
47 int i = (int)[self class_func0]; /* { dg-warning ".Derived. may not respond to .\\+class_func0." } */
48 /* { dg-warning "Messages without a matching method signature" "" { target *-*-* } 47 } */
49 /* { dg-warning "will be assumed to return .id. and accept" "" { target *-*-* } 47 } */
50 /* { dg-warning ".\.\.\.. as arguments" "" { target *-*-* } 47 } */
51 return i + (int)[super class_func0]; /* { dg-warning ".Object. may not respond to .\\+class_func0." } */
55 int i = [(id <Func>)self class_func0];
56 return i + [(id <Func>)super class_func0];
60 return [(Object <Func> *)super class_func0];
64 return [(Derived <Func> *)super class_func0];
68 int i = (int)[Derived class_func0]; /* { dg-warning ".Derived. may not respond to .\\+class_func0." } */
69 return i + (int)[Object class_func0]; /* { dg-warning ".Object. may not respond to .\\+class_func0." } */
73 return (int)[OBJC_GETCLASS("Object") class_func1]; /* { dg-warning ".Object. may not respond to .\\+class_func1." } */
77 return [OBJC_GETCLASS("Derived") class_func1];
79 - (int) instance_func1
81 int i = (int)[self instance_func0]; /* { dg-warning ".Derived. may not respond to .\\-instance_func0." } */
82 return i + (int)[super instance_func0]; /* { dg-warning ".Object. may not respond to .\\-instance_func0." } */
84 - (int) instance_func2
86 return [(id <Func>)super instance_func0];
88 - (int) instance_func3
90 return [(Object <Func> *)super instance_func0];
92 - (int) instance_func4
94 return [(Derived <Func> *)super instance_func0];
96 - (int) instance_func5
98 int i = (int)[Derived instance_func1]; /* { dg-warning ".Derived. may not respond to .\\+instance_func1." } */
99 return i + (int)[Object instance_func1]; /* { dg-warning ".Object. may not respond to .\\+instance_func1." } */
101 - (int) instance_func6
103 return (int)[OBJC_GETCLASS("Object") class_func1]; /* { dg-warning ".Object. may not respond to .\\+class_func1." } */
105 - (int) instance_func7
107 return [OBJC_GETCLASS("Derived") class_func1];
111 @implementation Derived (Categ)
112 + (int) categ_class_func1
114 int i = (int)[self class_func0]; /* { dg-warning ".Derived. may not respond to .\\+class_func0." } */
115 i += [self class_func1];
116 i += [self categ_class_func2];
117 i += (int)[self categ_instance_func1]; /* { dg-warning ".Derived. may not respond to .\\+categ_instance_func1." } */
118 return i + (int)[super class_func0]; /* { dg-warning ".Object. may not respond to .\\+class_func0." } */
120 + (int) categ_class_func2
122 int i = [(id <Func>)self class_func0];
123 return i + [(id <Func>)super class_func0];
125 - (int) categ_instance_func1
127 int i = (int)[self instance_func0]; /* { dg-warning ".Derived. may not respond to .\\-instance_func0." } */
128 i += [(Derived <Func> *)self categ_instance_func2];
129 i += (int)[(Object <Func> *)self categ_instance_func2]; /* { dg-warning ".Object. may not respond to .\\-categ_instance_func2." } */
130 /* { dg-warning ".\\-categ_instance_func2. not implemented by protocol" "" { target *-*-* } 129 } */
131 i += (int)[(id <Func>)self categ_instance_func2]; /* { dg-warning ".\\-categ_instance_func2. not implemented by protocol" } */
132 i += [(id)self categ_instance_func2];
133 return i + (int)[super instance_func0]; /* { dg-warning ".Object. may not respond to .\\-instance_func0." } */
135 - (int) categ_instance_func2
137 return [(id <Func>)super instance_func0];