1 // RUN: %clang_cc1 -fsyntax-only -verify %s
5 typedef struct objc_object *id;
6 id objc_getClass(const char *s);
9 - (id) initWithInt: (int) i;
14 - (int) instance_func0;
17 @interface Derived: Object // expected-note {{receiver is instance of class declared here}}
25 - (int) instance_func1;
26 - (int) instance_func2;
27 - (int) instance_func3;
28 - (int) instance_func4;
29 - (int) instance_func5;
30 - (int) instance_func6;
31 - (int) instance_func7;
32 - (id) initWithInt: (int) i;
35 @implementation Derived
38 int i = (size_t)[self class_func0]; // expected-warning {{class method '+class_func0' not found (return type defaults to 'id'); did you mean '+class_func}}
39 return i + (size_t)[super class_func0]; // expected-warning {{class method '+class_func0' not found (return type defaults to 'id')}}
43 int i = [(id <Func>)self class_func0];
44 i += [(id <Func>)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}
45 i += [(Class <Func>)self class_func0]; //
46 return i + [(Class <Func>)super class_func0]; // // expected-error {{cannot cast 'super' (it isn't an expression)}}
50 return [(Object <Func> *)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}
54 return [(Derived <Func> *)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}
58 int i = (size_t)[Derived class_func0]; // expected-warning {{class method '+class_func0' not found (return type defaults to 'id')}}
59 return i + (size_t)[Object class_func0]; // expected-warning {{class method '+class_func0' not found (return type defaults to 'id')}}
63 return (size_t)[objc_getClass("Object") class_func1]; // GCC warns about this
67 return [objc_getClass("Derived") class_func1];
69 - (int) instance_func1
71 int i = (size_t)[self instance_func0]; // expected-warning {{instance method '-instance_func0' not found (return type defaults to 'id'); did you mean}}
72 return i + (size_t)[super instance_func0]; // expected-warning {{'Object' may not respond to 'instance_func0'}}
74 - (int) instance_func2
76 return [(id <Func>)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}
78 - (int) instance_func3
80 return [(Object <Func> *)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}
82 - (int) instance_func4
84 return [(Derived <Func> *)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}}
86 - (int) instance_func5
88 int i = (size_t)[Derived instance_func1]; // expected-warning {{class method '+instance_func1' not found (return type defaults to 'id')}}
89 return i + (size_t)[Object instance_func1]; // expected-warning {{class method '+instance_func1' not found (return type defaults to 'id')}}
91 - (int) instance_func6
93 return (size_t)[objc_getClass("Object") class_func1];
95 - (int) instance_func7
97 return [objc_getClass("Derived") class_func1];
99 - (id) initWithInt: (int) i
101 // Don't warn about parentheses here.
102 if (self = [super initWithInt: i]) {
103 [self instance_func1];
110 @interface A // expected-note {{receiver is instance of class declared here}}
111 - (instancetype)initWithCoder:(A *)coder;
118 - (instancetype)initWithCoder:(C *)coder {
119 if (0 != (self = [super initWithCode:code])) // expected-error {{use of undeclared identifier 'code'}} expected-warning {{instance method '-initWithCode:' not found}}