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