1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 -o - %s
6 #pragma omp task // expected-error {{unexpected OpenMP directive '#pragma omp task'}}
9 S(const S &s) { a = s.a + 12; } // expected-note 10 {{implicitly declared private here}}
15 operator int() { return a; }
16 S &operator++() { return *this; }
17 S operator+(const S &) { return *this; }
25 S1 &operator++() { return *this; }
26 S1(const S1 &) = delete; // expected-note 2 {{'S1' has been explicitly marked deleted here}}
35 // expected-error@+1 2 {{call to deleted constructor of 'S1'}}
37 // expected-note@+1 2 {{predetermined as a firstprivate in a task construct here}}
39 #pragma omp task default(none)
40 #pragma omp task default(shared)
42 #pragma omp task default(none)
44 // expected-error@+1 {{calling a private constructor of class 'S'}}
48 // expected-error@+1 {{calling a private constructor of class 'S'}}
50 #pragma omp task default(shared)
56 // expected-error@+2 {{calling a private constructor of class 'S'}}
60 // expected-error@+1 2 {{calling a private constructor of class 'S'}}
61 #pragma omp parallel shared(a, b)
63 // expected-note@+1 2 {{defined as reduction}}
64 #pragma omp parallel reduction(+ : r)
65 // expected-error@+1 2 {{argument of a reduction clause of a parallel construct must not appear in a firstprivate clause on a task construct}}
66 #pragma omp task firstprivate(r)
68 // expected-note@+1 2 {{defined as reduction}}
69 #pragma omp parallel reduction(+ : r)
70 #pragma omp task default(shared)
71 // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}}
73 // expected-note@+1 2 {{defined as reduction}}
74 #pragma omp parallel reduction(+ : r)
76 // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}}
79 // expected-note@+1 2 {{defined as reduction}}
80 #pragma omp for reduction(+ : r)
81 for (int i = 0; i < 10; ++i)
82 // expected-error@+1 2 {{argument of a reduction clause of a for construct must not appear in a firstprivate clause on a task construct}}
83 #pragma omp task firstprivate(r)
86 // expected-note@+1 2 {{defined as reduction}}
87 #pragma omp for reduction(+ : r)
88 for (int i = 0; i < 10; ++i)
89 #pragma omp task default(shared)
90 // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}}
93 // expected-note@+1 2 {{defined as reduction}}
94 #pragma omp for reduction(+ : r)
95 for (int i = 0; i < 10; ++i)
97 // expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}}
99 // expected-note@+1 {{non-shared variable in a task construct is predetermined as firstprivate}}
101 // expected-error@+2 {{reduction variable must be shared}}
102 // expected-error@+1 {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
103 #pragma omp for reduction(+ : r)
105 // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'untied' clause}}
106 #pragma omp task untied untied
108 // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'mergeable' clause}}
109 #pragma omp task mergeable mergeable
114 int main(int argc, char **argv) {
120 #pragma omp task { // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}}
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}}
133 // expected-warning@+1 {{extra tokens at the end of '#pragma omp task' are ignored}}
134 #pragma omp task unknown()
142 goto L1; // expected-error {{use of undeclared label 'L1'}}
146 for (int i = 0; i < 10; ++i) {
152 break; // expected-error {{'break' statement not in loop or switch statement}}
153 continue; // expected-error {{'continue' statement not in loop statement}}
159 #pragma omp task default(none)
160 ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
162 goto L2; // expected-error {{use of undeclared label 'L2'}}
168 return 1; // expected-error {{cannot return from OpenMP region}}
171 [[]] // expected-error {{an attribute list cannot appear here}}
173 for (int n = 0; n < 100; ++n) {
176 #pragma omp task default(none)
177 #pragma omp task default(shared)
179 #pragma omp task default(none)
182 #pragma omp task default(shared)
191 #pragma omp parallel shared(a, b)
193 #pragma omp task default(none)
194 #pragma omp task default(shared)
196 #pragma omp task default(none)
198 // expected-error@+1 {{calling a private constructor of class 'S'}}
202 // expected-error@+1 {{calling a private constructor of class 'S'}}
204 #pragma omp task default(shared)
210 // expected-error@+2 {{calling a private constructor of class 'S'}}
213 // expected-error@+2 2 {{calling a private constructor of class 'S'}}
215 #pragma omp parallel shared(sa, sb)
217 // expected-note@+1 2 {{defined as reduction}}
218 #pragma omp parallel reduction(+ : r)
219 // expected-error@+1 {{argument of a reduction clause of a parallel construct must not appear in a firstprivate clause on a task construct}}
220 #pragma omp task firstprivate(r)
221 // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
223 // expected-note@+1 {{defined as reduction}}
224 #pragma omp parallel reduction(+ : r)
225 #pragma omp task default(shared)
226 // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
228 // expected-note@+1 {{defined as reduction}}
229 #pragma omp parallel reduction(+ : r)
231 // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
234 // expected-note@+1 2 {{defined as reduction}}
235 #pragma omp for reduction(+ : r)
236 for (int i = 0; i < 10; ++i)
237 // expected-error@+1 {{argument of a reduction clause of a for construct must not appear in a firstprivate clause on a task construct}}
238 #pragma omp task firstprivate(r)
239 // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
242 // expected-note@+1 {{defined as reduction}}
243 #pragma omp for reduction(+ : r)
244 for (int i = 0; i < 10; ++i)
245 #pragma omp task default(shared)
246 // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
249 // expected-note@+1 {{defined as reduction}}
250 #pragma omp for reduction(+ : r)
251 for (int i = 0; i < 10; ++i)
253 // expected-error@+1 {{reduction variables may not be accessed in an explicit task}}
255 // expected-note@+1 {{non-shared variable in a task construct is predetermined as firstprivate}}
257 // expected-error@+2 {{reduction variable must be shared}}
258 // expected-error@+1 {{region cannot be closely nested inside 'task' region; perhaps you forget to enclose 'omp for' directive into a parallel region?}}
259 #pragma omp for reduction(+ : r)
261 // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'untied' clause}}
262 #pragma omp task untied untied
264 // expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'mergeable' clause}}
265 #pragma omp task mergeable mergeable
267 // expected-note@+2 {{in instantiation of function template specialization 'foo<int>' requested here}}
268 // expected-note@+1 {{in instantiation of function template specialization 'foo<S>' requested here}}
269 return foo<int>() + foo<S>();