| 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 |
| 3 |
|
| 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 |
| 6 |
|
| 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 |
| 9 |
|
| 10 |
void xxx(int argc) { |
| 11 |
int x; // expected-note {{initialize the variable 'x' to silence this warning}} |
| 12 |
#pragma omp task |
| 13 |
argc = x; // expected-warning {{variable 'x' is uninitialized when used here}} |
| 14 |
} |
| 15 |
|
| 16 |
void foo() { |
| 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>}} |
| 18 |
; |
| 19 |
} |
| 20 |
|
| 21 |
typedef unsigned long omp_event_handle_t; |
| 22 |
namespace { |
| 23 |
static int y = 0; |
| 24 |
} |
| 25 |
static int x = 0; |
| 26 |
|
| 27 |
#pragma omp task // expected-error {{unexpected OpenMP directive '#pragma omp task'}} |
| 28 |
|
| 29 |
class S { |
| 30 |
S(const S &s) { a = s.a + 12; } // expected-note 16 {{implicitly declared private here}} |
| 31 |
int a; |
| 32 |
|
| 33 |
public: |
| 34 |
S() : a(0) {} |
| 35 |
S(int a) : a(a) {} |
| 36 |
operator int() { return a; } |
| 37 |
S &operator++() { return *this; } |
| 38 |
S operator+(const S &) { return *this; } |
| 39 |
}; |
| 40 |
|
| 41 |
class S1 { |
| 42 |
int a; |
| 43 |
|
| 44 |
public: |
| 45 |
S1() : a(0) {} |
| 46 |
S1 &operator++() { return *this; } |
| 47 |
S1(const S1 &) = delete; // expected-note 2 {{'S1' has been explicitly marked deleted here}} |
| 48 |
}; |
| 49 |
|
| 50 |
template <class T> |
| 51 |
int foo() { |
| 52 |
T a; |
| 53 |
T &b = a; |
| 54 |
int r; |
| 55 |
S1 s1; |
| 56 |
// expected-error@+1 2 {{call to deleted constructor of 'S1'}} |
| 57 |
#pragma omp task |
| 58 |
++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}} |
| 62 |
#ifdef OMP51 |
| 63 |
#pragma omp task default(firstprivate) // omp5-note 4 {{explicit data sharing attribute requested here}} |
| 64 |
#pragma omp task |
| 65 |
{ |
| 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}} |
| 68 |
} |
| 69 |
#endif |
| 70 |
|
| 71 |
#pragma omp task default(none) // expected-note 2 {{explicit data sharing attribute requested here}} |
| 72 |
#pragma omp task |
| 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}} |
| 75 |
#pragma omp task |
| 76 |
#pragma omp task |
| 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) |
| 80 |
#pragma omp task |
| 81 |
// expected-error@+1 {{calling a private constructor of class 'S'}} |
| 82 |
++a; |
| 83 |
#pragma omp parallel shared(a) |
| 84 |
#pragma omp task |
| 85 |
#pragma omp task |
| 86 |
++a; |
| 87 |
#pragma omp parallel shared(a) |
| 88 |
#pragma omp task default(shared) |
| 89 |
#pragma omp task |
| 90 |
++a; |
| 91 |
#pragma omp task |
| 92 |
#pragma omp parallel |
| 93 |
++a; // expected-error {{calling a private constructor of class 'S'}} |
| 94 |
// expected-error@+2 {{calling a private constructor of class 'S'}} |
| 95 |
#pragma omp task |
| 96 |
++b; |
| 97 |
#pragma omp task |
| 98 |
// expected-error@+1 2 {{calling a private constructor of class 'S'}} |
| 99 |
#pragma omp parallel shared(a, b) |
| 100 |
++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) |
| 105 |
++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}} |
| 110 |
++r; |
| 111 |
// expected-note@+1 2 {{defined as reduction}} |
| 112 |
#pragma omp parallel reduction(+ : r) |
| 113 |
#pragma omp task |
| 114 |
// expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}} |
| 115 |
++r; |
| 116 |
#pragma omp parallel |
| 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) |
| 122 |
++r; |
| 123 |
#pragma omp parallel |
| 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}} |
| 129 |
++r; |
| 130 |
#pragma omp parallel |
| 131 |
// expected-note@+1 2 {{defined as reduction}} |
| 132 |
#pragma omp for reduction(+ : r) |
| 133 |
for (int i = 0; i < 10; ++i) |
| 134 |
#pragma omp task |
| 135 |
// expected-error@+1 2 {{reduction variables may not be accessed in an explicit task}} |
| 136 |
++r; |
| 137 |
// expected-note@+1 {{non-shared variable in a task construct is predetermined as firstprivate}} |
| 138 |
#pragma omp task |
| 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) |
| 142 |
++r; |
| 143 |
// expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'untied' clause}} |
| 144 |
#pragma omp task untied untied |
| 145 |
++r; |
| 146 |
// expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'mergeable' clause}} |
| 147 |
#pragma omp task mergeable mergeable |
| 148 |
++r; |
| 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'}} |
| 157 |
; |
| 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}} |
| 161 |
; |
| 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}} |
| 164 |
; |
| 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'}} |
| 167 |
; |
| 168 |
return a + b; |
| 169 |
} |
| 170 |
|
| 171 |
int main(int argc, char **argv) { |
| 172 |
int a; |
| 173 |
int &b = a; |
| 174 |
S sa; |
| 175 |
S &sb = sa; |
| 176 |
int r; // expected-note {{declared here}} |
| 177 |
#pragma omp task { // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}} |
| 178 |
foo(); |
| 179 |
#pragma omp task( // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}} |
| 180 |
foo(); |
| 181 |
#pragma omp task[ // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}} |
| 182 |
foo(); |
| 183 |
#pragma omp task] // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}} |
| 184 |
foo(); |
| 185 |
#pragma omp task) // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}} |
| 186 |
foo(); |
| 187 |
#pragma omp task } // expected-warning {{extra tokens at the end of '#pragma omp task' are ignored}} |
| 188 |
foo(); |
| 189 |
#pragma omp task |
| 190 |
// expected-warning@+1 {{extra tokens at the end of '#pragma omp task' are ignored}} |
| 191 |
#pragma omp task unknown() |
| 192 |
foo(); |
| 193 |
L1: |
| 194 |
foo(); |
| 195 |
#pragma omp task |
| 196 |
; |
| 197 |
#pragma omp task |
| 198 |
{ |
| 199 |
goto L1; // expected-error {{use of undeclared label 'L1'}} |
| 200 |
argc++; |
| 201 |
} |
| 202 |
|
| 203 |
for (int i = 0; i < 10; ++i) { |
| 204 |
switch (argc) { |
| 205 |
case (0): |
| 206 |
#pragma omp task |
| 207 |
{ |
| 208 |
foo(); |
| 209 |
break; // expected-error {{'break' statement not in loop or switch statement}} |
| 210 |
continue; // expected-error {{'continue' statement not in loop statement}} |
| 211 |
} |
| 212 |
default: |
| 213 |
break; |
| 214 |
} |
| 215 |
} |
| 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}} |
| 218 |
|
| 219 |
goto L2; // expected-error {{use of undeclared label 'L2'}} |
| 220 |
#pragma omp task |
| 221 |
L2: |
| 222 |
foo(); |
| 223 |
#pragma omp task |
| 224 |
{ |
| 225 |
return 1; // expected-error {{cannot return from OpenMP region}} |
| 226 |
} |
| 227 |
|
| 228 |
[[]] // expected-error {{an attribute list cannot appear here}} |
| 229 |
#pragma omp task |
| 230 |
for (int n = 0; n < 100; ++n) { |
| 231 |
} |
| 232 |
|
| 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}} |
| 237 |
#pragma omp task |
| 238 |
++a; // expected-error {{variable 'a' must have explicitly specified data sharing attributes}} |
| 239 |
#pragma omp task default(shared) |
| 240 |
#pragma omp task |
| 241 |
++a; |
| 242 |
#pragma omp task |
| 243 |
#pragma omp parallel |
| 244 |
++a; |
| 245 |
#pragma omp task |
| 246 |
++b; |
| 247 |
#pragma omp task |
| 248 |
#pragma omp parallel shared(a, b) |
| 249 |
++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}} |
| 254 |
#pragma omp task |
| 255 |
// expected-error@+1 {{calling a private constructor of class 'S'}} |
| 256 |
++sa; // expected-error {{variable 'sa' must have explicitly specified data sharing attributes}} |
| 257 |
#pragma omp task |
| 258 |
#pragma omp task |
| 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) |
| 262 |
#pragma omp task |
| 263 |
// expected-error@+1 {{calling a private constructor of class 'S'}} |
| 264 |
++sa; |
| 265 |
#pragma omp parallel shared(sa) |
| 266 |
#pragma omp task |
| 267 |
#pragma omp task |
| 268 |
++sa; |
| 269 |
#pragma omp parallel shared(sa) |
| 270 |
#pragma omp task default(shared) |
| 271 |
#pragma omp task |
| 272 |
++sa; |
| 273 |
#pragma omp task |
| 274 |
#pragma omp parallel |
| 275 |
++sa; // expected-error {{calling a private constructor of class 'S'}} |
| 276 |
// expected-error@+2 {{calling a private constructor of class 'S'}} |
| 277 |
#pragma omp task |
| 278 |
++sb; |
| 279 |
// expected-error@+2 2 {{calling a private constructor of class 'S'}} |
| 280 |
#pragma omp task |
| 281 |
#pragma omp parallel shared(sa, sb) |
| 282 |
++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}} |
| 288 |
++r; |
| 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}} |
| 293 |
++r; |
| 294 |
// expected-note@+1 {{defined as reduction}} |
| 295 |
#pragma omp parallel reduction(+ : r) |
| 296 |
#pragma omp task |
| 297 |
// expected-error@+1 {{reduction variables may not be accessed in an explicit task}} |
| 298 |
++r; |
| 299 |
#pragma omp parallel |
| 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}} |
| 306 |
++r; |
| 307 |
#pragma omp parallel |
| 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}} |
| 313 |
++r; |
| 314 |
#pragma omp parallel |
| 315 |
// expected-note@+1 {{defined as reduction}} |
| 316 |
#pragma omp for reduction(+ : r) |
| 317 |
for (int i = 0; i < 10; ++i) |
| 318 |
#pragma omp task |
| 319 |
// expected-error@+1 {{reduction variables may not be accessed in an explicit task}} |
| 320 |
++r; |
| 321 |
// expected-note@+1 {{non-shared variable in a task construct is predetermined as firstprivate}} |
| 322 |
#pragma omp task |
| 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) |
| 326 |
++r; |
| 327 |
// expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'untied' clause}} |
| 328 |
#pragma omp task untied untied |
| 329 |
++r; |
| 330 |
// expected-error@+1 {{directive '#pragma omp task' cannot contain more than one 'mergeable' clause}} |
| 331 |
#pragma omp task mergeable mergeable |
| 332 |
++r; |
| 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 |
| 336 |
{ |
| 337 |
int array[r]; |
| 338 |
} |
| 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}} |
| 350 |
; |
| 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}} |
| 353 |
; |
| 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'}} |
| 356 |
; |
| 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>(); |
| 360 |
} |
| 361 |
|