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