1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized 2 3 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized 4 5 void foo() { 6 } 7 8 void xxx(int argc) { 9 int x; // expected-note {{initialize the variable 'x' to silence this warning}} 10 #pragma omp distribute parallel for 11 for (int i = 0; i < 10; ++i) 12 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}} 13 } 14 15 #pragma omp distribute parallel for // expected-error {{unexpected OpenMP directive '#pragma omp distribute parallel for'}} 16 17 int main(int argc, char **argv) { 18 #pragma omp target 19 #pragma omp teams 20 #pragma omp distribute parallel for { // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}} 21 for (int i = 0; i < argc; ++i) 22 foo(); 23 #pragma omp target 24 #pragma omp teams 25 #pragma omp distribute parallel for ( // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}} 26 for (int i = 0; i < argc; ++i) 27 foo(); 28 #pragma omp target 29 #pragma omp teams 30 #pragma omp distribute parallel for[ // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}} 31 for (int i = 0; i < argc; ++i) 32 foo(); 33 #pragma omp target 34 #pragma omp teams 35 #pragma omp distribute parallel for] // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}} 36 for (int i = 0; i < argc; ++i) 37 foo(); 38 #pragma omp target 39 #pragma omp teams 40 #pragma omp distribute parallel for) // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}} 41 for (int i = 0; i < argc; ++i) 42 foo(); 43 #pragma omp target 44 #pragma omp teams 45 #pragma omp distribute parallel for } // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}} 46 for (int i = 0; i < argc; ++i) 47 foo(); 48 #pragma omp target 49 #pragma omp teams 50 #pragma omp distribute parallel for linear(argc) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp distribute parallel for'}} 51 for (int i = 0; i < argc; ++i) 52 foo(); 53 #pragma omp target 54 #pragma omp teams 55 #pragma omp distribute parallel for unknown() // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}} 56 for (int i = 0; i < argc; ++i) 57 foo(); 58 L1: 59 for (int i = 0; i < argc; ++i) 60 foo(); 61 #pragma omp target 62 #pragma omp teams 63 #pragma omp distribute parallel for 64 for (int i = 0; i < argc; ++i) 65 foo(); 66 #pragma omp target 67 #pragma omp teams 68 #pragma omp distribute parallel for 69 for (int i = 0; i < argc; ++i) { 70 goto L1; // expected-error {{use of undeclared label 'L1'}} 71 argc++; 72 } 73 74 for (int i = 0; i < 10; ++i) { 75 switch (argc) { 76 case (0): 77 #pragma omp target 78 #pragma omp teams 79 #pragma omp distribute parallel for 80 for (int i = 0; i < argc; ++i) { 81 foo(); 82 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}} 83 continue; 84 } 85 default: 86 break; 87 } 88 } 89 #pragma omp target 90 #pragma omp teams 91 #pragma omp distribute parallel for default(none) // expected-note {{explicit data sharing attribute requested here}} 92 for (int i = 0; i < 10; ++i) 93 ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}} 94 95 goto L2; // expected-error {{use of undeclared label 'L2'}} 96 #pragma omp target 97 #pragma omp teams 98 #pragma omp distribute parallel for 99 for (int i = 0; i < argc; ++i) 100 L2: 101 foo(); 102 #pragma omp target 103 #pragma omp teams 104 #pragma omp distribute parallel for 105 for (int i = 0; i < argc; ++i) { 106 return 1; // expected-error {{cannot return from OpenMP region}} 107 } 108 109 [[]] // expected-error {{an attribute list cannot appear here}} 110 #pragma omp target 111 #pragma omp teams 112 #pragma omp distribute parallel for 113 for (int n = 0; n < 100; ++n) { 114 } 115 116 return 0; 117 } 118 119 void test_ordered() { 120 #pragma omp target 121 #pragma omp teams 122 #pragma omp distribute parallel for collapse(2) collapse(3) // expected-error {{directive '#pragma omp distribute parallel for' cannot contain more than one 'collapse' clause}} 123 for (int i = 0; i < 16; ++i) 124 for (int j = 0; j < 16; ++j) 125 ; 126 } 127 128 void test_cancel() { 129 #pragma omp target 130 #pragma omp teams 131 #pragma omp distribute parallel for 132 for (int i = 0; i < 16; ++i) 133 for (int j = 0; j < 16; ++j) { 134 #pragma omp cancel for 135 ; 136 } 137 } 138 139