Steve Naroff | 6b9dfd4 | 2009-03-04 15:11:40 +0000 | [diff] [blame] | 1 | // RUN: clang -fsyntax-only -verify %s |
| 2 | |
| 3 | #include <stddef.h> |
| 4 | |
| 5 | typedef struct objc_object *id; |
| 6 | id objc_getClass(const char *s); |
| 7 | |
| 8 | @interface Object |
| 9 | @end |
| 10 | |
| 11 | @protocol Func |
| 12 | + (int) class_func0; |
| 13 | - (int) instance_func0; |
| 14 | @end |
| 15 | |
| 16 | @interface Derived: Object |
| 17 | + (int) class_func1; |
| 18 | + (int) class_func2; |
| 19 | + (int) class_func3; |
| 20 | + (int) class_func4; |
| 21 | + (int) class_func5; |
| 22 | + (int) class_func6; |
| 23 | + (int) class_func7; |
| 24 | - (int) instance_func1; |
| 25 | - (int) instance_func2; |
| 26 | - (int) instance_func3; |
| 27 | - (int) instance_func4; |
| 28 | - (int) instance_func5; |
| 29 | - (int) instance_func6; |
| 30 | - (int) instance_func7; |
| 31 | @end |
| 32 | |
| 33 | @implementation Derived |
| 34 | + (int) class_func1 |
| 35 | { |
| 36 | int i = (size_t)[self class_func0]; // expected-warning {{method '-class_func0' not found (return type defaults to 'id')}} |
| 37 | return i + (size_t)[super class_func0]; // expected-warning {{method '+class_func0' not found (return type defaults to 'id')}} |
| 38 | } |
| 39 | + (int) class_func2 |
| 40 | { |
| 41 | int i = [(id <Func>)self class_func0]; // expected-warning {{method '-class_func0' not found (return type defaults to 'id')}} // expected-warning {{incompatible pointer to integer conversion initializing 'id', expected 'int'}} |
| 42 | i += [(id <Func>)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}} |
| 43 | i += [(Class <Func>)self class_func0]; // expected-error {{protocol qualified 'Class' is unsupported}} |
| 44 | return i + [(Class <Func>)super class_func0]; // expected-error {{protocol qualified 'Class' is unsupported}} // expected-error {{cannot cast 'super' (it isn't an expression)}} |
| 45 | } |
| 46 | + (int) class_func3 |
| 47 | { |
| 48 | return [(Object <Func> *)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}} |
| 49 | } |
| 50 | + (int) class_func4 |
| 51 | { |
| 52 | return [(Derived <Func> *)super class_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}} |
| 53 | } |
| 54 | + (int) class_func5 |
| 55 | { |
| 56 | int i = (size_t)[Derived class_func0]; // expected-warning {{method '+class_func0' not found (return type defaults to 'id')}} |
| 57 | return i + (size_t)[Object class_func0]; // expected-warning {{method '+class_func0' not found (return type defaults to 'id')}} |
| 58 | } |
| 59 | + (int) class_func6 |
| 60 | { |
| 61 | return (size_t)[objc_getClass("Object") class_func1]; // GCC warns about this |
| 62 | } |
| 63 | + (int) class_func7 |
| 64 | { |
| 65 | return [objc_getClass("Derived") class_func1]; |
| 66 | } |
| 67 | - (int) instance_func1 |
| 68 | { |
| 69 | int i = (size_t)[self instance_func0]; // expected-warning {{method '-instance_func0' not found (return type defaults to 'id'))}} |
| 70 | return i + (size_t)[super instance_func0]; // expected-warning {{method '-instance_func0' not found (return type defaults to 'id')}} |
| 71 | } |
| 72 | - (int) instance_func2 |
| 73 | { |
| 74 | return [(id <Func>)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}} |
| 75 | } |
| 76 | - (int) instance_func3 |
| 77 | { |
| 78 | return [(Object <Func> *)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}} |
| 79 | } |
| 80 | - (int) instance_func4 |
| 81 | { |
| 82 | return [(Derived <Func> *)super instance_func0]; // expected-error {{cannot cast 'super' (it isn't an expression)}} |
| 83 | } |
| 84 | - (int) instance_func5 |
| 85 | { |
Fariborz Jahanian | b1006c7 | 2009-03-04 17:50:39 +0000 | [diff] [blame^] | 86 | int i = (size_t)[Derived instance_func1]; // expected-warning {{method '+instance_func1' not found (return type defaults to 'id')}} |
Steve Naroff | 6b9dfd4 | 2009-03-04 15:11:40 +0000 | [diff] [blame] | 87 | return i + (size_t)[Object instance_func1]; // expected-warning {{method '+instance_func1' not found (return type defaults to 'id')}} |
| 88 | } |
| 89 | - (int) instance_func6 |
| 90 | { |
| 91 | return (size_t)[objc_getClass("Object") class_func1]; |
| 92 | } |
| 93 | - (int) instance_func7 |
| 94 | { |
| 95 | return [objc_getClass("Derived") class_func1]; |
| 96 | } |
| 97 | @end |
| 98 | |