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/Object1.h"
6 #include "../objc-obj-c++-shared/next-mapping.h"
11 - (int) instance_func0;
14 @interface Derived: Object
22 - (int) instance_func1;
23 - (int) instance_func2;
24 - (int) instance_func3;
25 - (int) instance_func4;
26 - (int) instance_func5;
27 - (int) instance_func6;
28 - (int) instance_func7;
31 @interface Derived (Categ)
32 + (int) categ_class_func1;
33 + (int) categ_class_func2;
34 - (int) categ_instance_func1;
35 - (int) categ_instance_func2;
38 @implementation Derived
41 int i = (size_t)[self class_func0]; /* { dg-warning ".Derived. may not respond to .\\+class_func0." } */
42 return i + (size_t)[super class_func0]; /* { dg-warning ".Object. may not respond to .\\+class_func0." } */
46 int i = [(id <Func>)self class_func0]; /* { dg-warning ".\\-class_func0. not found in protocol" } */
47 i += [(id <Func>)super class_func0]; /* { dg-warning ".\\-class_func0. not found in protocol" } */
48 i += [(Class <Func>)self class_func0];
49 return i + [(Class <Func>)super class_func0];
53 return [(Object <Func> *)super class_func0];
57 return [(Derived <Func> *)super class_func0];
61 int i = (size_t)[Derived class_func0]; /* { dg-warning ".Derived. may not respond to .\\+class_func0." } */
62 return i + (size_t)[Object class_func0]; /* { dg-warning ".Object. may not respond to .\\+class_func0." } */
66 return (size_t)[objc_get_class("Object") class_func1]; /* { dg-warning ".Object. may not respond to .\\+class_func1." } */
70 return [objc_get_class("Derived") class_func1];
72 - (int) instance_func1
74 int i = (size_t)[self instance_func0]; /* { dg-warning ".Derived. may not respond to .\\-instance_func0." } */
75 return i + (size_t)[super instance_func0]; /* { dg-warning ".Object. may not respond to .\\-instance_func0." } */
77 - (int) instance_func2
79 return [(id <Func>)super instance_func0];
81 - (int) instance_func3
83 return [(Object <Func> *)super instance_func0];
85 - (int) instance_func4
87 return [(Derived <Func> *)super instance_func0];
89 - (int) instance_func5
91 int i = (size_t)[Derived instance_func1]; /* { dg-warning ".Derived. may not respond to .\\+instance_func1." } */
92 return i + (size_t)[Object instance_func1]; /* { dg-warning ".Object. may not respond to .\\+instance_func1." } */
94 - (int) instance_func6
96 return (size_t)[objc_get_class("Object") class_func1]; /* { dg-warning ".Object. may not respond to .\\+class_func1." } */
98 - (int) instance_func7
100 return [objc_get_class("Derived") class_func1];
104 @implementation Derived (Categ)
105 + (int) categ_class_func1
107 int i = (size_t)[self class_func0]; /* { dg-warning ".Derived. may not respond to .\\+class_func0." } */
108 i += [self class_func1];
109 i += [self categ_class_func2];
110 i += (size_t)[self categ_instance_func1]; /* { dg-warning ".Derived. may not respond to .\\+categ_instance_func1." } */
111 return i + (size_t)[super class_func0]; /* { dg-warning ".Object. may not respond to .\\+class_func0." } */
113 + (int) categ_class_func2
115 int i = [(id <Func>)self class_func0]; /* { dg-warning ".\\-class_func0. not found in protocol" } */
116 i += [(id <Func>)super class_func0]; /* { dg-warning ".\\-class_func0. not found in protocol" } */
117 i += [(Class <Func>)self class_func0];
118 return i + [(Class <Func>)super class_func0];
120 - (int) categ_instance_func1
122 int i = (size_t)[self instance_func0]; /* { dg-warning ".Derived. may not respond to .\\-instance_func0." } */
123 i += [(Derived <Func> *)self categ_instance_func2];
124 i += (size_t)[(Object <Func> *)self categ_instance_func2]; /* { dg-warning ".Object. may not respond to .\\-categ_instance_func2." } */
125 /* { dg-warning ".\\-categ_instance_func2. not found in protocol" "" { target *-*-* } 124 } */
126 i += (size_t)[(id <Func>)self categ_instance_func2]; /* { dg-warning ".\\-categ_instance_func2. not found in protocol" } */
127 i += [(id)self categ_instance_func2];
128 return i + (size_t)[super instance_func0]; /* { dg-warning ".Object. may not respond to .\\-instance_func0." } */
130 - (int) categ_instance_func2
132 return [(id <Func>)super instance_func0];
136 /* { dg-warning "Messages without a matching method signature" "" { target *-*-* } 0 } */
137 /* { dg-warning "will be assumed to return .id. and accept" "" { target *-*-* } 0 } */
138 /* { dg-warning ".\.\.\.. as arguments" "" { target *-*-* } 0 } */