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