message.mm revision 688fc9b9b4323a294f5bf4f8a83f7c365edec573
1// RUN: %clang_cc1 -fsyntax-only -verify %s
2@interface I1
3- (int*)method;
4@end
5
6@implementation I1
7- (int*)method {
8  struct x { };
9  [x method]; // expected-error{{receiver type 'x' is not an Objective-C class}}
10  return 0;
11}
12@end
13
14typedef struct { int x; } ivar;
15
16@interface I2 {
17  id ivar;
18}
19- (int*)method;
20+ (void)method;
21@end
22
23struct I2_holder {
24  I2_holder();
25
26  I2 *get();
27};
28
29I2 *operator+(I2_holder, int);
30
31@implementation I2
32- (int*)method {
33  [ivar method];
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;
39}
40+ (void)method {
41  [ivar method]; // expected-error{{receiver type 'ivar' (aka 'ivar') is not an Objective-C class}}
42}
43@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];
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
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 other:(String&)str2;
88@end
89
90void test_I5(I5 *i5, String s) {
91  [i5 method:"hello" other:s];
92}
93