message.mm revision 732281de5d518fca96c449ae185ee56bde422c4f
15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// RUN: %clang_cc1 -fsyntax-only -verify %s 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@interface I1 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (int*)method; 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@end 57d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles) 67d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)@implementation I1 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (int*)method { 85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) struct x { }; 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) [x method]; // expected-error{{receiver type 'x' is not an Objective-C class}} 105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) return 0; 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@end 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)typedef struct { int x; } ivar; 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@interface I2 { 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) id ivar; 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (int*)method; 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)+ (void)method; 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)@end 225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)struct I2_holder { 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) I2_holder(); 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) I2 *get(); 275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)I2 *operator+(I2_holder, int); 305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)@implementation I2 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)- (int*)method { 335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) [ivar method]; 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Test instance messages that start with a simple-type-specifier. 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) [I2_holder().get() method]; 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) [I2_holder().get() + 17 method]; 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return 0; 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)+ (void)method { 415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) [ivar method]; // expected-error{{receiver type 'ivar' (aka 'ivar') is not an Objective-C class}} 425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 437d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)@end 44 45// Class message sends 46@interface I3 47+ (int*)method; 48@end 49 50@interface I4 : I3 51+ (int*)otherMethod; 52@end 53 54template<typename T> 55struct 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]; // expected-warning{{'typename' refers to a non-dependent type name; accepted as a C++0x extension}} 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]}; // expected-warning{{'typename' refers to a non-dependent type name; accepted as a C++0x extension}} 73 int* ip4 = {[typename identity<I2_holder>::type().get() method]}; // expected-warning{{'typename' refers to a non-dependent type name; accepted as a C++0x extension}} 74 int array[5] = {[3] = 2}; 75 return [super method]; 76} 77@end 78 79struct String { 80 String(const char *); 81}; 82 83struct MutableString : public String { }; 84 85// C++-specific parameter types 86@interface I5 87- method:(const String&)str1 88 other:(String&)str2; // expected-note{{passing argument to parameter 'str2' here}} 89@end 90 91void test_I5(I5 *i5, String s) { 92 [i5 method:"hello" other:s]; 93 [i5 method:s other:"world"]; // expected-error{{non-const lvalue reference to type 'String' cannot bind to a value of unrelated type 'char const [6]'}} 94} 95