1 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-version=45 -fopenmp -ferror-limit 200 -std=c++11 -o - %s -Wuninitialized
2 // RUN: %clang_cc1 -verify=expected,omp5 -fopenmp-version=50 -fopenmp -ferror-limit 200 -std=c++11 -o - %s -Wuninitialized
4 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-version=45 -fopenmp-simd -ferror-limit 200 -std=c++11 -o - %s -Wuninitialized
5 // RUN: %clang_cc1 -verify=expected,omp5 -fopenmp-version=50 -fopenmp-simd -ferror-limit 200 -std=c++11 -o - %s -Wuninitialized
7 // RUN: %clang_cc1 -verify=expected,omp5 -DOMP51 -fopenmp -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
8 // RUN: %clang_cc1 -verify=expected,omp5 -DOMP51 -fopenmp-simd -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
11 int x
; // expected-note {{initialize the variable 'x' to silence this warning}}
13 argc
= x
; // expected-warning {{variable 'x' is uninitialized when used here}}
17 #pragma omp task detach(0) // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} omp5-error {{'omp_event_handle_t' type not found; include <omp.h>}}
21 typedef unsigned long omp_event_handle_t
;
27 #pragma omp task // expected-error {{unexpected OpenMP directive '#pragma omp task'}}
30 S(const S
&s
) { a
= s
.a
+ 12; } // expected-note 16 {{implicitly declared private here}}
36 operator int() { return a
; }
37 S
&operator++() { return *this; }
38 S
operator+(const S
&) { return *this; }
46 S1
&operator++() { return *this; }
47 S1(const S1
&) = delete; // expected-note 2 {{'S1' has been explicitly marked deleted here}}
56 // expected-error@+1 2 {{call to deleted constructor of 'S1'}}
59 #pragma omp task default(none) // expected-note 2 {{explicit data sharing attribute requested here}}
60 #pragma omp task default(shared)
61 ++a
; // expected-error 2 {{variable 'a' must have explicitly specified data sharing attributes}}
63 #pragma omp task default(firstprivate) // omp5-note 4 {{explicit data sharing attribute requested here}}
66 ++x
; // omp5-error 2 {{variable 'x' must have explicitly specified data sharing attributes}}
67 ++y
; // omp5-error 2 {{variable 'y' must have explicitly specified data sharing attributes}}
71 #pragma omp task default(none) // expected-note 2 {{explicit data sharing attribute requested here}}
73 // expected-error@+1 {{calling a private constructor of class 'S'}}
74 ++a
; // expected-error 2 {{variable 'a' must have explicitly specified data sharing attributes}}
77 // expected-error@+1 {{calling a private constructor of class 'S'}}
78 ++a
; // expected-error {{calling a private constructor of class 'S'}}
79 #pragma omp task default(shared)
81 // expected-error@+1 {{calling a private constructor of class 'S'}}
83 #pragma omp parallel shared(a)
87 #pragma omp parallel shared(a)
88 #pragma omp task default(shared)
93 ++a
; // expected-error {{calling a private constructor of class 'S'}}
94 // expected-error@+2 {{calling a private constructor of class 'S'}}
98 // expected-error@+1 2 {{calling a private constructor of class 'S'}}
99 #pragma omp parallel shared(a, b)
101 // expected-note@+1 2 {{defined as reduction}}
102 #pragma omp parallel reduction(+ : r)
103 // expected-error@+1 2 {{argument of a reduction clause of a parallel construct must not appear in a firstprivate clause on a task construct}}
104 #pragma omp task firstprivate(r)
106 // expected-note@+1 2 {{defined as reduction}}
107 #pragma omp parallel reduction(+ : r)
108 #pragma omp task default(shared)
109 // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}}
111 // expected-note@+1 2 {{defined as reduction}}
112 #pragma omp parallel reduction(+ : r)
114 // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}}
117 // expected-note@+1 2 {{defined as reduction}}
118 #pragma omp for reduction(+ : r)
119 for (int i
= 0; i
< 10; ++i
)
120 // expected-error@+1 2 {{argument of a reduction clause of a for construct must not appear in a firstprivate clause on a task construct}}
121 #pragma omp task firstprivate(r)
124 // expected-note@+1 2 {{defined as reduction}}
125 #pragma omp for reduction(+ : r)
126 for (int i
= 0; i
< 10; ++i
)
127 #pragma omp task default(shared)
128 // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}}
131 // expected-note@+1 2 {{defined as reduction}}
132 #pragma omp for reduction(+ : r)
133 for (int i
= 0; i
< 10; ++i
)
135 // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}}
137 // expected-note@+1 {{non-shared variable in a task construct is predetermined as firstprivate}}
139 // expected-error@+2 {{reduction variable must be shared}}
140 // expected-error@+1 {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
141 #pragma omp for reduction(+ : r)
143 // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'untied' clause}}
144 #pragma omp task untied untied
146 // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'mergeable' clause}}
147 #pragma omp task mergeable mergeable
149 volatile omp_event_handle_t evt
;
150 const omp_event_handle_t cevt
= 0;
151 omp_event_handle_t sevt
;
152 omp_event_handle_t
&revt
= sevt
;
153 #pragma omp task detach // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} expected-error {{expected '(' after 'detach'}}
154 #pragma omp task detach( // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
155 #pragma omp task detach() // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} expected-error {{expected expression}}
156 #pragma omp task detach(a) // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} omp5-error {{expected variable of the 'omp_event_handle_t' type, not 'int'}} omp5-error {{expected variable of the 'omp_event_handle_t' type, not 'S'}}
158 #pragma omp task detach(evt) detach(evt) // omp45-error 2 {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} expected-error {{directive '#pragma omp task' cannot contain more than one 'detach' clause}}
159 #pragma omp task detach(cevt) detach(revt) // omp45-error 2 {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} expected-error {{directive '#pragma omp task' cannot contain more than one 'detach' clause}} omp5-error {{expected variable of the 'omp_event_handle_t' type, not 'const omp_event_handle_t' (aka 'const unsigned long')}} omp5-error {{expected variable of the 'omp_event_handle_t' type, not 'omp_event_handle_t &' (aka 'unsigned long &')}}
160 #pragma omp task detach(evt) mergeable // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} omp5-error {{'mergeable' and 'detach' clause are mutually exclusive and may not appear on the same directive}} omp5-note {{'detach' clause is specified here}}
162 #pragma omp task mergeable detach(evt) // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} omp5-error {{'detach' and 'mergeable' clause are mutually exclusive and may not appear on the same directive}} omp5-note {{'mergeable' clause is specified here}}
163 #pragma omp task detach(-evt) // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} omp5-error {{expected variable of the 'omp_event_handle_t' type}}
165 #pragma omp task detach(evt) shared(evt) // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}}
166 #pragma omp task detach(evt) firstprivate(evt) // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}}
171 int main(int argc
, char **argv
) {
176 int r
; // expected-note {{declared here}}
177 #pragma omp task { // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
179 #pragma omp task( // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
181 #pragma omp task[ // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
183 #pragma omp task] // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
185 #pragma omp task) // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
187 #pragma omp task } // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
190 // expected-warning@+1 {{extra tokens at the end of '#pragma omp task' are ignored}}
191 #pragma omp task unknown()
199 goto L1
; // expected-error {{use of undeclared label 'L1'}}
203 for (int i
= 0; i
< 10; ++i
) {
209 break; // expected-error {{'break' statement not in loop or switch statement}}
210 continue; // expected-error {{'continue' statement not in loop statement}}
216 #pragma omp task default(none) // expected-note {{explicit data sharing attribute requested here}}
217 ++argc
; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
219 goto L2
; // expected-error {{use of undeclared label 'L2'}}
225 return 1; // expected-error {{cannot return from OpenMP region}}
228 [[]] // expected-error {{an attribute list cannot appear here}}
230 for (int n
= 0; n
< 100; ++n
) {
233 #pragma omp task default(none) // expected-note {{explicit data sharing attribute requested here}}
234 #pragma omp task default(shared)
235 ++a
; // expected-error {{variable 'a' must have explicitly specified data sharing attributes}}
236 #pragma omp task default(none) // expected-note {{explicit data sharing attribute requested here}}
238 ++a
; // expected-error {{variable 'a' must have explicitly specified data sharing attributes}}
239 #pragma omp task default(shared)
248 #pragma omp parallel shared(a, b)
250 #pragma omp task default(none) // expected-note {{explicit data sharing attribute requested here}}
251 #pragma omp task default(shared)
252 ++sa
; // expected-error {{variable 'sa' must have explicitly specified data sharing attributes}}
253 #pragma omp task default(none) // expected-note {{explicit data sharing attribute requested here}}
255 // expected-error@+1 {{calling a private constructor of class 'S'}}
256 ++sa
; // expected-error {{variable 'sa' must have explicitly specified data sharing attributes}}
259 // expected-error@+1 {{calling a private constructor of class 'S'}}
260 ++sa
; // expected-error {{calling a private constructor of class 'S'}}
261 #pragma omp task default(shared)
263 // expected-error@+1 {{calling a private constructor of class 'S'}}
265 #pragma omp parallel shared(sa)
269 #pragma omp parallel shared(sa)
270 #pragma omp task default(shared)
275 ++sa
; // expected-error {{calling a private constructor of class 'S'}}
276 // expected-error@+2 {{calling a private constructor of class 'S'}}
279 // expected-error@+2 2 {{calling a private constructor of class 'S'}}
281 #pragma omp parallel shared(sa, sb)
283 // expected-note@+1 2 {{defined as reduction}}
284 #pragma omp parallel reduction(+ : r)
285 // expected-error@+1 {{argument of a reduction clause of a parallel construct must not appear in a firstprivate clause on a task construct}}
286 #pragma omp task firstprivate(r)
287 // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
289 // expected-note@+1 {{defined as reduction}}
290 #pragma omp parallel reduction(+ : r)
291 #pragma omp task default(shared)
292 // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
294 // expected-note@+1 {{defined as reduction}}
295 #pragma omp parallel reduction(+ : r)
297 // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
300 // expected-note@+1 2 {{defined as reduction}}
301 #pragma omp for reduction(+ : r)
302 for (int i
= 0; i
< 10; ++i
)
303 // expected-error@+1 {{argument of a reduction clause of a for construct must not appear in a firstprivate clause on a task construct}}
304 #pragma omp task firstprivate(r)
305 // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
308 // expected-note@+1 {{defined as reduction}}
309 #pragma omp for reduction(+ : r)
310 for (int i
= 0; i
< 10; ++i
)
311 #pragma omp task default(shared)
312 // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
315 // expected-note@+1 {{defined as reduction}}
316 #pragma omp for reduction(+ : r)
317 for (int i
= 0; i
< 10; ++i
)
319 // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
321 // expected-note@+1 {{non-shared variable in a task construct is predetermined as firstprivate}}
323 // expected-error@+2 {{reduction variable must be shared}}
324 // expected-error@+1 {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
325 #pragma omp for reduction(+ : r)
327 // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'untied' clause}}
328 #pragma omp task untied untied
330 // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'mergeable' clause}}
331 #pragma omp task mergeable mergeable
333 // expected-error@+4 {{variable length arrays are not supported in OpenMP tasking regions with 'untied' clause}}
334 // expected-note@+3 {{read of non-const variable 'r' is not allowed in a constant expression}}
335 #pragma omp task untied
339 volatile omp_event_handle_t evt
;
340 omp_event_handle_t sevt
;
341 const omp_event_handle_t cevt
= evt
;
342 omp_event_handle_t
&revt
= sevt
;
343 #pragma omp task detach // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} expected-error {{expected '(' after 'detach'}}
344 #pragma omp task detach( // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
345 #pragma omp task detach() // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} expected-error {{expected expression}}
346 #pragma omp task detach(a) // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} omp5-error {{expected variable of the 'omp_event_handle_t' type, not 'int'}}
347 #pragma omp task detach(evt) detach(evt) // omp45-error 2 {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} expected-error {{directive '#pragma omp task' cannot contain more than one 'detach' clause}}
348 #pragma omp task detach(cevt) detach(revt) // omp45-error 2 {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} expected-error {{directive '#pragma omp task' cannot contain more than one 'detach' clause}} omp5-error {{expected variable of the 'omp_event_handle_t' type, not 'const omp_event_handle_t' (aka 'const unsigned long')}} omp5-error {{expected variable of the 'omp_event_handle_t' type, not 'omp_event_handle_t &' (aka 'unsigned long &')}}
349 #pragma omp task detach(evt) mergeable // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} omp5-error {{'mergeable' and 'detach' clause are mutually exclusive and may not appear on the same directive}} omp5-note {{'detach' clause is specified here}}
351 #pragma omp task mergeable detach(evt) // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} omp5-error {{'detach' and 'mergeable' clause are mutually exclusive and may not appear on the same directive}} omp5-note {{'mergeable' clause is specified here}}
352 #pragma omp task detach(-evt) // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}} omp5-error {{expected variable of the 'omp_event_handle_t' type}}
354 #pragma omp task detach(evt) shared(evt) // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}}
355 #pragma omp task detach(evt) firstprivate(evt) // omp45-error {{unexpected OpenMP clause 'detach' in directive '#pragma omp task'}}
357 // expected-note@+2 {{in instantiation of function template specialization 'foo<int>' requested here}}
358 // expected-note@+1 {{in instantiation of function template specialization 'foo<S>' requested here}}
359 return foo
<int>() + foo
<S
>();