Douglas Gregor | c5e77d5 | 2010-02-19 15:18:45 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
Douglas Gregor | c5e77d5 | 2010-02-19 15:18:45 +0000 | [diff] [blame] | 2 | @interface I1 |
Douglas Gregor | 6aa14d8 | 2010-04-21 22:36:40 +0000 | [diff] [blame^] | 3 | - (int*)method; |
Douglas Gregor | c5e77d5 | 2010-02-19 15:18:45 +0000 | [diff] [blame] | 4 | @end |
| 5 | |
| 6 | @implementation I1 |
Douglas Gregor | 6aa14d8 | 2010-04-21 22:36:40 +0000 | [diff] [blame^] | 7 | - (int*)method { |
Douglas Gregor | c5e77d5 | 2010-02-19 15:18:45 +0000 | [diff] [blame] | 8 | struct x { }; |
Douglas Gregor | 2725ca8 | 2010-04-21 19:57:20 +0000 | [diff] [blame] | 9 | [x method]; // expected-error{{receiver type 'x' is not an Objective-C class}} |
Douglas Gregor | 6aa14d8 | 2010-04-21 22:36:40 +0000 | [diff] [blame^] | 10 | return 0; |
Douglas Gregor | c5e77d5 | 2010-02-19 15:18:45 +0000 | [diff] [blame] | 11 | } |
| 12 | @end |
Douglas Gregor | 36262b8 | 2010-02-19 16:08:35 +0000 | [diff] [blame] | 13 | |
| 14 | typedef struct { int x; } ivar; |
| 15 | |
| 16 | @interface I2 { |
| 17 | id ivar; |
| 18 | } |
Douglas Gregor | 6aa14d8 | 2010-04-21 22:36:40 +0000 | [diff] [blame^] | 19 | - (int*)method; |
Douglas Gregor | 36262b8 | 2010-02-19 16:08:35 +0000 | [diff] [blame] | 20 | + (void)method; |
| 21 | @end |
| 22 | |
Douglas Gregor | 6aa14d8 | 2010-04-21 22:36:40 +0000 | [diff] [blame^] | 23 | struct I2_holder { |
| 24 | I2_holder(); |
| 25 | |
| 26 | I2 *get(); |
| 27 | }; |
| 28 | |
| 29 | I2 *operator+(I2_holder, int); |
| 30 | |
Douglas Gregor | 36262b8 | 2010-02-19 16:08:35 +0000 | [diff] [blame] | 31 | @implementation I2 |
Douglas Gregor | 6aa14d8 | 2010-04-21 22:36:40 +0000 | [diff] [blame^] | 32 | - (int*)method { |
Douglas Gregor | 36262b8 | 2010-02-19 16:08:35 +0000 | [diff] [blame] | 33 | [ivar method]; |
Douglas Gregor | 6aa14d8 | 2010-04-21 22:36:40 +0000 | [diff] [blame^] | 34 | |
| 35 | // Test instance messages that start with a simple-type-specifier. |
| 36 | [I2_holder().get() method]; |
| 37 | [I2_holder().get() + 17 method]; |
| 38 | return 0; |
Douglas Gregor | 36262b8 | 2010-02-19 16:08:35 +0000 | [diff] [blame] | 39 | } |
| 40 | + (void)method { |
Douglas Gregor | 2725ca8 | 2010-04-21 19:57:20 +0000 | [diff] [blame] | 41 | [ivar method]; // expected-error{{receiver type 'ivar' (aka 'ivar') is not an Objective-C class}} |
Douglas Gregor | 36262b8 | 2010-02-19 16:08:35 +0000 | [diff] [blame] | 42 | } |
| 43 | @end |
Douglas Gregor | 6aa14d8 | 2010-04-21 22:36:40 +0000 | [diff] [blame^] | 44 | |
| 45 | // Class message sends |
| 46 | @interface I3 |
| 47 | + (int*)method; |
| 48 | @end |
| 49 | |
| 50 | @interface I4 : I3 |
| 51 | + (int*)otherMethod; |
| 52 | @end |
| 53 | |
| 54 | template<typename T> |
| 55 | struct identity { |
| 56 | typedef T type; |
| 57 | }; |
| 58 | |
| 59 | @implementation I4 |
| 60 | + (int *)otherMethod { |
| 61 | // Test class messages that use non-trivial simple-type-specifiers |
| 62 | // or typename-specifiers. |
| 63 | if (false) { |
| 64 | if (true) |
| 65 | return [typename identity<I3>::type method]; |
| 66 | |
| 67 | return [::I3 method]; |
| 68 | } |
| 69 | |
| 70 | int* ip1 = {[super method]}; |
| 71 | int* ip2 = {[::I3 method]}; |
| 72 | int* ip3 = {[typename identity<I3>::type method]}; |
| 73 | int* ip4 = {[typename identity<I2_holder>::type().get() method]}; |
| 74 | int array[5] = {[3] = 2}; |
| 75 | return [super method]; |
| 76 | } |
| 77 | @end |