1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 -o - %s
3 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++11 -o - %s
8 #pragma omp task // expected-error {{unexpected OpenMP directive '#pragma omp task'}}
11 S(const S &s) { a = s.a + 12; } // expected-note 10 {{implicitly declared private here}}
17 operator int() { return a; }
18 S &operator++() { return *this; }
19 S operator+(const S &) { return *this; }
27 S1 &operator++() { return *this; }
28 S1(const S1 &) = delete; // expected-note 2 {{'S1' has been explicitly marked deleted here}}
37 // expected-error@+1 2 {{call to deleted constructor of 'S1'}}
39 // expected-note@+1 2 {{predetermined as a firstprivate in a task construct here}}
41 #pragma omp task default(none)
42 #pragma omp task default(shared)
44 #pragma omp task default(none)
46 // expected-error@+1 {{calling a private constructor of class 'S'}}
50 // expected-error@+1 {{calling a private constructor of class 'S'}}
52 #pragma omp task default(shared)
58 // expected-error@+2 {{calling a private constructor of class 'S'}}
62 // expected-error@+1 2 {{calling a private constructor of class 'S'}}
63 #pragma omp parallel shared(a, b)
65 // expected-note@+1 2 {{defined as reduction}}
66 #pragma omp parallel reduction(+ : r)
67 // expected-error@+1 2 {{argument of a reduction clause of a parallel construct must not appear in a firstprivate clause on a task construct}}
68 #pragma omp task firstprivate(r)
70 // expected-note@+1 2 {{defined as reduction}}
71 #pragma omp parallel reduction(+ : r)
72 #pragma omp task default(shared)
73 // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}}
75 // expected-note@+1 2 {{defined as reduction}}
76 #pragma omp parallel reduction(+ : r)
78 // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}}
81 // expected-note@+1 2 {{defined as reduction}}
82 #pragma omp for reduction(+ : r)
83 for (int i = 0; i < 10; ++i)
84 // expected-error@+1 2 {{argument of a reduction clause of a for construct must not appear in a firstprivate clause on a task construct}}
85 #pragma omp task firstprivate(r)
88 // expected-note@+1 2 {{defined as reduction}}
89 #pragma omp for reduction(+ : r)
90 for (int i = 0; i < 10; ++i)
91 #pragma omp task default(shared)
92 // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}}
95 // expected-note@+1 2 {{defined as reduction}}
96 #pragma omp for reduction(+ : r)
97 for (int i = 0; i < 10; ++i)
99 // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}}
101 // expected-note@+1 {{non-shared variable in a task construct is predetermined as firstprivate}}
103 // expected-error@+2 {{reduction variable must be shared}}
104 // expected-error@+1 {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
105 #pragma omp for reduction(+ : r)
107 // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'untied' clause}}
108 #pragma omp task untied untied
110 // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'mergeable' clause}}
111 #pragma omp task mergeable mergeable
116 int main(int argc, char **argv) {
122 #pragma omp task { // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
124 #pragma omp task( // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
126 #pragma omp task[ // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
128 #pragma omp task] // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
130 #pragma omp task) // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
132 #pragma omp task } // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
135 // expected-warning@+1 {{extra tokens at the end of '#pragma omp task' are ignored}}
136 #pragma omp task unknown()
144 goto L1; // expected-error {{use of undeclared label 'L1'}}
148 for (int i = 0; i < 10; ++i) {
154 break; // expected-error {{'break' statement not in loop or switch statement}}
155 continue; // expected-error {{'continue' statement not in loop statement}}
161 #pragma omp task default(none)
162 ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
164 goto L2; // expected-error {{use of undeclared label 'L2'}}
170 return 1; // expected-error {{cannot return from OpenMP region}}
173 [[]] // expected-error {{an attribute list cannot appear here}}
175 for (int n = 0; n < 100; ++n) {
178 #pragma omp task default(none)
179 #pragma omp task default(shared)
181 #pragma omp task default(none)
184 #pragma omp task default(shared)
193 #pragma omp parallel shared(a, b)
195 #pragma omp task default(none)
196 #pragma omp task default(shared)
198 #pragma omp task default(none)
200 // expected-error@+1 {{calling a private constructor of class 'S'}}
204 // expected-error@+1 {{calling a private constructor of class 'S'}}
206 #pragma omp task default(shared)
212 // expected-error@+2 {{calling a private constructor of class 'S'}}
215 // expected-error@+2 2 {{calling a private constructor of class 'S'}}
217 #pragma omp parallel shared(sa, sb)
219 // expected-note@+1 2 {{defined as reduction}}
220 #pragma omp parallel reduction(+ : r)
221 // expected-error@+1 {{argument of a reduction clause of a parallel construct must not appear in a firstprivate clause on a task construct}}
222 #pragma omp task firstprivate(r)
223 // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
225 // expected-note@+1 {{defined as reduction}}
226 #pragma omp parallel reduction(+ : r)
227 #pragma omp task default(shared)
228 // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
230 // expected-note@+1 {{defined as reduction}}
231 #pragma omp parallel reduction(+ : r)
233 // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
236 // expected-note@+1 2 {{defined as reduction}}
237 #pragma omp for reduction(+ : r)
238 for (int i = 0; i < 10; ++i)
239 // expected-error@+1 {{argument of a reduction clause of a for construct must not appear in a firstprivate clause on a task construct}}
240 #pragma omp task firstprivate(r)
241 // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
244 // expected-note@+1 {{defined as reduction}}
245 #pragma omp for reduction(+ : r)
246 for (int i = 0; i < 10; ++i)
247 #pragma omp task default(shared)
248 // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
251 // expected-note@+1 {{defined as reduction}}
252 #pragma omp for reduction(+ : r)
253 for (int i = 0; i < 10; ++i)
255 // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
257 // expected-note@+1 {{non-shared variable in a task construct is predetermined as firstprivate}}
259 // expected-error@+2 {{reduction variable must be shared}}
260 // expected-error@+1 {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
261 #pragma omp for reduction(+ : r)
263 // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'untied' clause}}
264 #pragma omp task untied untied
266 // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'mergeable' clause}}
267 #pragma omp task mergeable mergeable
269 // expected-note@+2 {{in instantiation of function template specialization 'foo<int>' requested here}}
270 // expected-note@+1 {{in instantiation of function template specialization 'foo<S>' requested here}}
271 return foo<int>() + foo<S>();