| 1 |
// RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized |
| 2 |
|
| 3 |
// RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized |
| 4 |
|
| 5 |
void xxx(int argc) { |
| 6 |
int x; // expected-note {{initialize the variable 'x' to silence this warning}} |
| 7 |
#pragma omp parallel master |
| 8 |
argc = x; // expected-warning {{variable 'x' is uninitialized when used here}} |
| 9 |
} |
| 10 |
|
| 11 |
#pragma omp parallel master // expected-error {{unexpected OpenMP directive '#pragma omp parallel master'}} |
| 12 |
|
| 13 |
int foo() { |
| 14 |
return 0; |
| 15 |
} |
| 16 |
|
| 17 |
int a; |
| 18 |
struct S; |
| 19 |
S& bar(); |
| 20 |
int main(int argc, char **argv) { |
| 21 |
#pragma omp parallel master nowait // expected-error {{unexpected OpenMP clause 'nowait' in directive '#pragma omp parallel master'}} |
| 22 |
#pragma omp parallel master unknown // expected-warning {{extra tokens at the end of '#pragma omp parallel master' are ignored}} |
| 23 |
foo(); |
| 24 |
{ |
| 25 |
#pragma omp master |
| 26 |
} // expected-error {{expected statement}} |
| 27 |
{ |
| 28 |
#pragma omp parallel master |
| 29 |
} // expected-error {{expected statement}} |
| 30 |
|
| 31 |
S &s = bar(); |
| 32 |
#pragma omp parallel master |
| 33 |
(void)&s; |
| 34 |
#pragma omp parallel master { // expected-warning {{extra tokens at the end of '#pragma omp parallel master' are ignored}} |
| 35 |
foo(); |
| 36 |
#pragma omp parallel master ( // expected-warning {{extra tokens at the end of '#pragma omp parallel master' are ignored}} |
| 37 |
foo(); |
| 38 |
#pragma omp parallel master [ // expected-warning {{extra tokens at the end of '#pragma omp parallel master' are ignored}} |
| 39 |
foo(); |
| 40 |
#pragma omp parallel master ] // expected-warning {{extra tokens at the end of '#pragma omp parallel master' are ignored}} |
| 41 |
foo(); |
| 42 |
#pragma omp parallel master ) // expected-warning {{extra tokens at the end of '#pragma omp parallel master' are ignored}} |
| 43 |
foo(); |
| 44 |
#pragma omp parallel master } // expected-warning {{extra tokens at the end of '#pragma omp parallel master' are ignored}} |
| 45 |
foo(); |
| 46 |
#pragma omp parallel master |
| 47 |
// expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel master' are ignored}} |
| 48 |
#pragma omp parallel master unknown() |
| 49 |
foo(); |
| 50 |
L1: |
| 51 |
foo(); |
| 52 |
#pragma omp parallel master |
| 53 |
; |
| 54 |
#pragma omp parallel master |
| 55 |
{ |
| 56 |
|
| 57 |
for (int i = 0; i < 10; ++i) { |
| 58 |
switch(argc) { |
| 59 |
case (0): |
| 60 |
#pragma omp parallel master |
| 61 |
{ |
| 62 |
foo(); |
| 63 |
break; // expected-error {{'break' statement not in loop or switch statement}} |
| 64 |
continue; // expected-error {{'continue' statement not in loop statement}} |
| 65 |
} |
| 66 |
default: |
| 67 |
break; |
| 68 |
} |
| 69 |
} |
| 70 |
goto L1; // expected-error {{use of undeclared label 'L1'}} |
| 71 |
argc++; |
| 72 |
} |
| 73 |
#pragma omp parallel master default(none) // expected-note 2 {{explicit data sharing attribute requested here}} |
| 74 |
{ |
| 75 |
++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}} |
| 76 |
++a; // expected-error {{variable 'a' must have explicitly specified data sharing attributes}} |
| 77 |
} |
| 78 |
|
| 79 |
goto L2; // expected-error {{use of undeclared label 'L2'}} |
| 80 |
#pragma omp parallel master |
| 81 |
L2: |
| 82 |
foo(); |
| 83 |
#pragma omp parallel master |
| 84 |
{ |
| 85 |
return 1; // expected-error {{cannot return from OpenMP region}} |
| 86 |
} |
| 87 |
return 0; |
| 88 |
} |