1 | // RUN: %clang_cc1 -verify -fopenmp %s -Wno-openmp-target |
2 | |
3 | // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wno-openmp-target |
4 | |
5 | extern int omp_default_mem_alloc; |
6 | void foo() { |
7 | } |
8 | |
9 | bool foobool(int argc) { |
10 | return argc; |
11 | } |
12 | |
13 | struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}} |
14 | extern S1 a; |
15 | class S2 { |
16 | mutable int a; |
17 | |
18 | public: |
19 | S2() : a(0) {} |
20 | S2(S2 &s2) : a(s2.a) {} |
21 | const S2 &operator =(const S2&) const; |
22 | S2 &operator =(const S2&); |
23 | static float S2s; // expected-note {{static data member is predetermined as shared}} |
24 | static const float S2sc; // expected-note {{'S2sc' declared here}} |
25 | }; |
26 | const float S2::S2sc = 0; |
27 | const S2 b; |
28 | const S2 ba[5]; |
29 | class S3 { |
30 | int a; |
31 | S3 &operator=(const S3 &s3); // expected-note {{implicitly declared private here}} |
32 | |
33 | public: |
34 | S3() : a(0) {} |
35 | S3(S3 &s3) : a(s3.a) {} |
36 | }; |
37 | const S3 c; // expected-note {{'c' defined here}} |
38 | const S3 ca[5]; // expected-note {{'ca' defined here}} |
39 | extern const int f; // expected-note {{'f' declared here}} |
40 | class S4 { |
41 | int a; |
42 | S4(); // expected-note 3 {{implicitly declared private here}} |
43 | S4(const S4 &s4); |
44 | |
45 | public: |
46 | S4(int v) : a(v) {} |
47 | }; |
48 | class S5 { |
49 | int a; |
50 | S5() : a(0) {} // expected-note {{implicitly declared private here}} |
51 | |
52 | public: |
53 | S5(const S5 &s5) : a(s5.a) {} |
54 | S5(int v) : a(v) {} |
55 | }; |
56 | class S6 { |
57 | int a; |
58 | S6() : a(0) {} // expected-note {{implicitly declared private here}} |
59 | |
60 | public: |
61 | S6(const S6 &s6) : a(s6.a) {} |
62 | S6(int v) : a(v) {} |
63 | }; |
64 | |
65 | S3 h; |
66 | #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} |
67 | |
68 | template <class I, class C> |
69 | int foomain(int argc, char **argv) { |
70 | I e(4); |
71 | I g(5); |
72 | int i; |
73 | int &j = i; |
74 | #pragma omp target |
75 | #pragma omp teams distribute simd lastprivate // expected-error {{expected '(' after 'lastprivate'}} |
76 | for (int k = 0; k < argc; ++k) ++k; |
77 | |
78 | #pragma omp target |
79 | #pragma omp teams distribute simd lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
80 | for (int k = 0; k < argc; ++k) ++k; |
81 | |
82 | #pragma omp target |
83 | #pragma omp teams distribute simd lastprivate() // expected-error {{expected expression}} |
84 | for (int k = 0; k < argc; ++k) ++k; |
85 | |
86 | #pragma omp target |
87 | #pragma omp teams distribute simd lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
88 | for (int k = 0; k < argc; ++k) ++k; |
89 | |
90 | #pragma omp target |
91 | #pragma omp teams distribute simd lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
92 | for (int k = 0; k < argc; ++k) ++k; |
93 | |
94 | #pragma omp target |
95 | #pragma omp teams distribute simd lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
96 | for (int k = 0; k < argc; ++k) ++k; |
97 | |
98 | #pragma omp target |
99 | #pragma omp teams distribute simd lastprivate(argc) allocate , allocate(, allocate(omp_default , allocate(omp_default_mem_alloc, allocate(omp_default_mem_alloc:, allocate(omp_default_mem_alloc: argc, allocate(omp_default_mem_alloc: argv), allocate(argv) // expected-error {{expected '(' after 'allocate'}} expected-error 2 {{expected expression}} expected-error 2 {{expected ')'}} expected-error {{use of undeclared identifier 'omp_default'}} expected-note 2 {{to match this '('}} |
100 | for (int k = 0; k < argc; ++k) ++k; |
101 | |
102 | #pragma omp target |
103 | #pragma omp teams distribute simd lastprivate(S1) // expected-error {{'S1' does not refer to a value}} |
104 | for (int k = 0; k < argc; ++k) ++k; |
105 | |
106 | #pragma omp target |
107 | #pragma omp teams distribute simd lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}} |
108 | for (int k = 0; k < argc; ++k) ++k; |
109 | |
110 | #pragma omp target |
111 | #pragma omp teams distribute simd lastprivate(argv[1]) // expected-error {{expected variable name}} |
112 | for (int k = 0; k < argc; ++k) ++k; |
113 | |
114 | #pragma omp target |
115 | #pragma omp teams distribute simd lastprivate(e, g) // expected-error 2 {{calling a private constructor of class 'S4'}} |
116 | for (int k = 0; k < argc; ++k) ++k; |
117 | |
118 | #pragma omp target |
119 | #pragma omp teams distribute simd lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} |
120 | for (int k = 0; k < argc; ++k) ++k; |
121 | |
122 | int v = 0; |
123 | #pragma omp target |
124 | #pragma omp teams distribute simd lastprivate(i) |
125 | for (int k = 0; k < argc; ++k) { |
126 | i = k; |
127 | v += i; |
128 | } |
129 | |
130 | #pragma omp target |
131 | #pragma omp teams distribute simd lastprivate(j) private(i) |
132 | for (int k = 0; k < argc; ++k) ++k; |
133 | |
134 | #pragma omp target |
135 | #pragma omp teams distribute simd lastprivate(i) |
136 | for (int k = 0; k < argc; ++k) ++k; |
137 | |
138 | return 0; |
139 | } |
140 | |
141 | void bar(S4 a[2]) { |
142 | #pragma omp target |
143 | #pragma omp teams distribute simd lastprivate(a) |
144 | for (int i = 0; i < 2; ++i) foo(); |
145 | } |
146 | |
147 | namespace A { |
148 | double x; |
149 | #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} |
150 | } |
151 | namespace B { |
152 | using A::x; |
153 | } |
154 | |
155 | int main(int argc, char **argv) { |
156 | const int d = 5; // expected-note {{'d' defined here}} |
157 | const int da[5] = {0}; // expected-note {{'da' defined here}} |
158 | S4 e(4); |
159 | S5 g(5); |
160 | S3 m; |
161 | S6 n(2); |
162 | int i; |
163 | int &j = i; |
164 | #pragma omp target |
165 | #pragma omp teams distribute simd lastprivate // expected-error {{expected '(' after 'lastprivate'}} |
166 | for (i = 0; i < argc; ++i) foo(); |
167 | |
168 | #pragma omp target |
169 | #pragma omp teams distribute simd lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
170 | for (i = 0; i < argc; ++i) foo(); |
171 | |
172 | #pragma omp target |
173 | #pragma omp teams distribute simd lastprivate() // expected-error {{expected expression}} |
174 | for (i = 0; i < argc; ++i) foo(); |
175 | |
176 | #pragma omp target |
177 | #pragma omp teams distribute simd lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
178 | for (i = 0; i < argc; ++i) foo(); |
179 | |
180 | #pragma omp target |
181 | #pragma omp teams distribute simd lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
182 | for (i = 0; i < argc; ++i) foo(); |
183 | |
184 | #pragma omp target |
185 | #pragma omp teams distribute simd lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
186 | for (i = 0; i < argc; ++i) foo(); |
187 | |
188 | #pragma omp target |
189 | #pragma omp teams distribute simd lastprivate(argc) |
190 | for (i = 0; i < argc; ++i) foo(); |
191 | |
192 | #pragma omp target |
193 | #pragma omp teams distribute simd lastprivate(S1) // expected-error {{'S1' does not refer to a value}} |
194 | for (i = 0; i < argc; ++i) foo(); |
195 | |
196 | #pragma omp target |
197 | #pragma omp teams distribute simd lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 1 {{const-qualified variable without mutable fields cannot be lastprivate}} expected-error 2 {{const-qualified variable cannot be lastprivate}} |
198 | for (i = 0; i < argc; ++i) foo(); |
199 | |
200 | #pragma omp target |
201 | #pragma omp teams distribute simd lastprivate(argv[1]) // expected-error {{expected variable name}} |
202 | for (i = 0; i < argc; ++i) foo(); |
203 | |
204 | #pragma omp target |
205 | #pragma omp teams distribute simd lastprivate(2 * 2) // expected-error {{expected variable name}} |
206 | for (i = 0; i < argc; ++i) foo(); |
207 | |
208 | #pragma omp target |
209 | #pragma omp teams distribute simd lastprivate(ba) |
210 | for (i = 0; i < argc; ++i) foo(); |
211 | |
212 | #pragma omp target |
213 | #pragma omp teams distribute simd lastprivate(ca) // expected-error {{const-qualified variable without mutable fields cannot be lastprivate}} |
214 | for (i = 0; i < argc; ++i) foo(); |
215 | |
216 | #pragma omp target |
217 | #pragma omp teams distribute simd lastprivate(da) // expected-error {{const-qualified variable cannot be lastprivate}} |
218 | for (i = 0; i < argc; ++i) foo(); |
219 | |
220 | int xa; |
221 | #pragma omp target |
222 | #pragma omp teams distribute simd lastprivate(xa) // OK |
223 | for (i = 0; i < argc; ++i) foo(); |
224 | |
225 | #pragma omp target |
226 | #pragma omp teams distribute simd lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}} |
227 | for (i = 0; i < argc; ++i) foo(); |
228 | |
229 | #pragma omp target |
230 | #pragma omp teams distribute simd lastprivate(S2::S2sc) // expected-error {{const-qualified variable cannot be lastprivate}} |
231 | for (i = 0; i < argc; ++i) foo(); |
232 | |
233 | #pragma omp target |
234 | #pragma omp teams distribute simd lastprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} |
235 | for (i = 0; i < argc; ++i) foo(); |
236 | |
237 | #pragma omp target |
238 | #pragma omp teams distribute simd lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}} |
239 | for (i = 0; i < argc; ++i) foo(); |
240 | |
241 | #pragma omp target |
242 | #pragma omp teams distribute simd lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} |
243 | for (i = 0; i < argc; ++i) foo(); |
244 | |
245 | #pragma omp target |
246 | #pragma omp teams distribute simd lastprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} |
247 | for (i = 0; i < argc; ++i) foo(); |
248 | |
249 | #pragma omp target |
250 | #pragma omp teams distribute simd private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}} |
251 | for (i = 0; i < argc; ++i) foo(); |
252 | |
253 | #pragma omp target |
254 | #pragma omp teams distribute simd lastprivate(xa) |
255 | for (i = 0; i < argc; ++i) foo(); |
256 | |
257 | #pragma omp target |
258 | #pragma omp teams distribute simd lastprivate(j) |
259 | for (i = 0; i < argc; ++i) foo(); |
260 | |
261 | // expected-error@+2 {{firstprivate variable cannot be lastprivate}} expected-note@+2 {{defined as firstprivate}} |
262 | #pragma omp target |
263 | #pragma omp teams distribute simd firstprivate(m) lastprivate(m) |
264 | for (i = 0; i < argc; ++i) foo(); |
265 | |
266 | // expected-error@+2 {{lastprivate variable cannot be firstprivate}} expected-note@+2 {{defined as lastprivate}} |
267 | #pragma omp target |
268 | #pragma omp teams distribute simd lastprivate(n) firstprivate(n) // expected-error {{calling a private constructor of class 'S6'}} |
269 | for (i = 0; i < argc; ++i) foo(); |
270 | |
271 | static int si; |
272 | #pragma omp target |
273 | #pragma omp teams distribute simd lastprivate(si) // OK |
274 | for (i = 0; i < argc; ++i) si = i + 1; |
275 | |
276 | return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}} |
277 | } |
278 | |