annotate clang/test/SemaObjCXX/message.mm @ 222:81f6424ef0e3 llvm-original

LLVM original branch
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 18 Jul 2021 22:10:01 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile-10.5 -verify -Wno-objc-root-class %s
anatofuz
parents:
diff changeset
2 // RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile-10.5 -verify -Wno-objc-root-class -std=c++98 %s
anatofuz
parents:
diff changeset
3 // RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile-10.5 -verify -Wno-objc-root-class -std=c++11 %s
anatofuz
parents:
diff changeset
4
anatofuz
parents:
diff changeset
5 @interface I1
anatofuz
parents:
diff changeset
6 - (int*)method;
anatofuz
parents:
diff changeset
7 @end
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 @implementation I1
anatofuz
parents:
diff changeset
10 - (int*)method {
anatofuz
parents:
diff changeset
11 struct x { };
anatofuz
parents:
diff changeset
12 [x method]; // expected-error{{receiver type 'x' is not an Objective-C class}}
anatofuz
parents:
diff changeset
13 return 0;
anatofuz
parents:
diff changeset
14 }
anatofuz
parents:
diff changeset
15 @end
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 typedef struct { int x; } ivar;
anatofuz
parents:
diff changeset
18
anatofuz
parents:
diff changeset
19 @interface I2 {
anatofuz
parents:
diff changeset
20 id ivar;
anatofuz
parents:
diff changeset
21 }
anatofuz
parents:
diff changeset
22 - (int*)method;
anatofuz
parents:
diff changeset
23 + (void)method;
anatofuz
parents:
diff changeset
24 @end
anatofuz
parents:
diff changeset
25
anatofuz
parents:
diff changeset
26 struct I2_holder {
anatofuz
parents:
diff changeset
27 I2_holder();
anatofuz
parents:
diff changeset
28
anatofuz
parents:
diff changeset
29 I2 *get();
anatofuz
parents:
diff changeset
30 };
anatofuz
parents:
diff changeset
31
anatofuz
parents:
diff changeset
32 I2 *operator+(I2_holder, int);
anatofuz
parents:
diff changeset
33
anatofuz
parents:
diff changeset
34 @implementation I2
anatofuz
parents:
diff changeset
35 - (int*)method {
anatofuz
parents:
diff changeset
36 [ivar method];
anatofuz
parents:
diff changeset
37
anatofuz
parents:
diff changeset
38 // Test instance messages that start with a simple-type-specifier.
anatofuz
parents:
diff changeset
39 [I2_holder().get() method];
anatofuz
parents:
diff changeset
40 [I2_holder().get() + 17 method];
anatofuz
parents:
diff changeset
41 return 0;
anatofuz
parents:
diff changeset
42 }
anatofuz
parents:
diff changeset
43 + (void)method {
anatofuz
parents:
diff changeset
44 [ivar method]; // expected-error{{receiver type 'ivar' is not an Objective-C class}}
anatofuz
parents:
diff changeset
45 }
anatofuz
parents:
diff changeset
46 @end
anatofuz
parents:
diff changeset
47
anatofuz
parents:
diff changeset
48 // Class message sends
anatofuz
parents:
diff changeset
49 @interface I3
anatofuz
parents:
diff changeset
50 + (int*)method;
anatofuz
parents:
diff changeset
51 @end
anatofuz
parents:
diff changeset
52
anatofuz
parents:
diff changeset
53 @interface I4 : I3
anatofuz
parents:
diff changeset
54 + (int*)otherMethod;
anatofuz
parents:
diff changeset
55 @end
anatofuz
parents:
diff changeset
56
anatofuz
parents:
diff changeset
57 template<typename T>
anatofuz
parents:
diff changeset
58 struct identity {
anatofuz
parents:
diff changeset
59 typedef T type;
anatofuz
parents:
diff changeset
60 };
anatofuz
parents:
diff changeset
61
anatofuz
parents:
diff changeset
62 @implementation I4
anatofuz
parents:
diff changeset
63 + (int *)otherMethod {
anatofuz
parents:
diff changeset
64 // Test class messages that use non-trivial simple-type-specifiers
anatofuz
parents:
diff changeset
65 // or typename-specifiers.
anatofuz
parents:
diff changeset
66 if (false) {
anatofuz
parents:
diff changeset
67 if (true)
anatofuz
parents:
diff changeset
68 return [typename identity<I3>::type method];
anatofuz
parents:
diff changeset
69 #if __cplusplus <= 199711L
anatofuz
parents:
diff changeset
70 // expected-warning@-2 {{'typename' occurs outside of a template}}
anatofuz
parents:
diff changeset
71 #endif
anatofuz
parents:
diff changeset
72
anatofuz
parents:
diff changeset
73 return [::I3 method];
anatofuz
parents:
diff changeset
74 }
anatofuz
parents:
diff changeset
75
anatofuz
parents:
diff changeset
76 int* ip1 = {[super method]};
anatofuz
parents:
diff changeset
77 int* ip2 = {[::I3 method]};
anatofuz
parents:
diff changeset
78 int* ip3 = {[typename identity<I3>::type method]};
anatofuz
parents:
diff changeset
79 #if __cplusplus <= 199711L
anatofuz
parents:
diff changeset
80 // expected-warning@-2 {{'typename' occurs outside of a template}}
anatofuz
parents:
diff changeset
81 #endif
anatofuz
parents:
diff changeset
82
anatofuz
parents:
diff changeset
83 int* ip4 = {[typename identity<I2_holder>::type().get() method]};
anatofuz
parents:
diff changeset
84 #if __cplusplus <= 199711L
anatofuz
parents:
diff changeset
85 // expected-warning@-2 {{'typename' occurs outside of a template}}
anatofuz
parents:
diff changeset
86 #endif
anatofuz
parents:
diff changeset
87 int array[5] = {[3] = 2}; // expected-warning {{C99 extension}}
anatofuz
parents:
diff changeset
88 return [super method];
anatofuz
parents:
diff changeset
89 }
anatofuz
parents:
diff changeset
90 @end
anatofuz
parents:
diff changeset
91
anatofuz
parents:
diff changeset
92 struct String {
anatofuz
parents:
diff changeset
93 String(const char *);
anatofuz
parents:
diff changeset
94 };
anatofuz
parents:
diff changeset
95
anatofuz
parents:
diff changeset
96 struct MutableString : public String { };
anatofuz
parents:
diff changeset
97
anatofuz
parents:
diff changeset
98 // C++-specific parameter types
anatofuz
parents:
diff changeset
99 @interface I5
anatofuz
parents:
diff changeset
100 - method:(const String&)str1
anatofuz
parents:
diff changeset
101 other:(String&)str2; // expected-note{{passing argument to parameter 'str2' here}}
anatofuz
parents:
diff changeset
102 @end
anatofuz
parents:
diff changeset
103
anatofuz
parents:
diff changeset
104 void test_I5(I5 *i5, String s) {
anatofuz
parents:
diff changeset
105 [i5 method:"hello" other:s];
anatofuz
parents:
diff changeset
106 [i5 method:s other:"world"]; // expected-error{{non-const lvalue reference to type 'String' cannot bind to a value of unrelated type 'const char [6]'}}
anatofuz
parents:
diff changeset
107 }
anatofuz
parents:
diff changeset
108
anatofuz
parents:
diff changeset
109 // <rdar://problem/8483253>
anatofuz
parents:
diff changeset
110 @interface A
anatofuz
parents:
diff changeset
111
anatofuz
parents:
diff changeset
112 struct X { };
anatofuz
parents:
diff changeset
113
anatofuz
parents:
diff changeset
114 + (A *)create:(void (*)(void *x, X r, void *data))callback
anatofuz
parents:
diff changeset
115 callbackData:(void *)callback_data;
anatofuz
parents:
diff changeset
116
anatofuz
parents:
diff changeset
117 @end
anatofuz
parents:
diff changeset
118
anatofuz
parents:
diff changeset
119
anatofuz
parents:
diff changeset
120 void foo(void)
anatofuz
parents:
diff changeset
121 {
anatofuz
parents:
diff changeset
122 void *fun;
anatofuz
parents:
diff changeset
123 void *ptr;
anatofuz
parents:
diff changeset
124 X r;
anatofuz
parents:
diff changeset
125 A *im = [A create:(void (*)(void *cgl_ctx, X r, void *data)) fun
anatofuz
parents:
diff changeset
126 callbackData:ptr];
anatofuz
parents:
diff changeset
127 }
anatofuz
parents:
diff changeset
128
anatofuz
parents:
diff changeset
129 // <rdar://problem/8807070>
anatofuz
parents:
diff changeset
130 template<typename T> struct X1; // expected-note{{template is declared here}}
anatofuz
parents:
diff changeset
131
anatofuz
parents:
diff changeset
132 @interface B
anatofuz
parents:
diff changeset
133 + (X1<int>)blah;
anatofuz
parents:
diff changeset
134 + (X1<float>&)blarg;
anatofuz
parents:
diff changeset
135 @end
anatofuz
parents:
diff changeset
136
anatofuz
parents:
diff changeset
137 void f() {
anatofuz
parents:
diff changeset
138 [B blah]; // expected-error{{implicit instantiation of undefined template 'X1<int>'}}
anatofuz
parents:
diff changeset
139 [B blarg];
anatofuz
parents:
diff changeset
140 }