1 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -std=c++11 %s -Wuninitialized 2 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -fopenmp-version=50 -std=c++11 %s -Wuninitialized 3 4 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -std=c++11 %s -Wuninitialized 5 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -fopenmp-version=50 -std=c++11 %s -Wuninitialized 6 xxx(int argc)7void xxx(int argc) { 8 int x; // expected-note {{initialize the variable 'x' to silence this warning}} 9 #pragma omp target 10 #pragma omp teams 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 foo()15void foo() { 16 } 17 18 static int pvt; 19 #pragma omp threadprivate(pvt) 20 21 #pragma omp teams distribute parallel for // expected-error {{unexpected OpenMP directive '#pragma omp teams distribute parallel for'}} 22 main(int argc,char ** argv)23int main(int argc, char **argv) { 24 #pragma omp target 25 #pragma omp teams distribute parallel for 26 f; // expected-error {{use of undeclared identifier 'f'}} 27 #pragma omp target 28 #pragma omp teams distribute parallel for { // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} 29 for (int i = 0; i < argc; ++i) 30 foo(); 31 #pragma omp target 32 #pragma omp teams distribute parallel for ( // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} 33 for (int i = 0; i < argc; ++i) 34 foo(); 35 #pragma omp target 36 #pragma omp teams distribute parallel for[ // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} 37 for (int i = 0; i < argc; ++i) 38 foo(); 39 #pragma omp target 40 #pragma omp teams distribute parallel for] // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} 41 for (int i = 0; i < argc; ++i) 42 foo(); 43 #pragma omp target 44 #pragma omp teams distribute parallel for) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} 45 for (int i = 0; i < argc; ++i) 46 foo(); 47 #pragma omp target 48 #pragma omp teams distribute parallel for } // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} 49 for (int i = 0; i < argc; ++i) 50 foo(); 51 #pragma omp target 52 #pragma omp teams distribute parallel for linear(argc) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp teams distribute parallel for'}} 53 for (int i = 0; i < argc; ++i) 54 foo(); 55 // expected-warning@+2 {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}} 56 #pragma omp target 57 #pragma omp teams distribute parallel for unknown() 58 for (int i = 0; i < argc; ++i) 59 foo(); 60 L1: 61 for (int i = 0; i < argc; ++i) 62 foo(); 63 #pragma omp target 64 #pragma omp teams distribute parallel for 65 for (int i = 0; i < argc; ++i) 66 foo(); 67 #pragma omp target 68 #pragma omp teams 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 distribute parallel for 79 for (int i = 0; i < argc; ++i) { 80 foo(); 81 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}} 82 continue; 83 } 84 default: 85 break; 86 } 87 } 88 #pragma omp target 89 #pragma omp teams distribute parallel for default(none) // expected-note {{explicit data sharing attribute requested here}} 90 for (int i = 0; i < 10; ++i) 91 ++argc; // expected-error {{ariable 'argc' must have explicitly specified data sharing attributes}} 92 93 goto L2; // expected-error {{use of undeclared label 'L2'}} 94 #pragma omp target 95 #pragma omp teams distribute parallel for 96 for (int i = 0; i < argc; ++i) 97 L2: 98 foo(); 99 #pragma omp target 100 #pragma omp teams distribute parallel for 101 for (int i = 0; i < argc; ++i) { 102 return 1; // expected-error {{cannot return from OpenMP region}} 103 } 104 105 [[]] // expected-error {{an attribute list cannot appear here}} 106 #pragma omp target 107 #pragma omp teams distribute parallel for 108 for (int n = 0; n < 100; ++n) { 109 } 110 111 #pragma omp target 112 #pragma omp teams distribute parallel for copyin(pvt) 113 for (int n = 0; n < 100; ++n) {} 114 115 return 0; 116 } 117 test_ordered()118void test_ordered() { 119 #pragma omp target 120 #pragma omp teams distribute parallel for ordered // expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp teams distribute parallel for'}} 121 for (int i = 0; i < 16; ++i) 122 ; 123 #pragma omp target 124 #pragma omp teams distribute parallel for order // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} expected-error {{expected '(' after 'order'}} 125 for (int i = 0; i < 10; ++i) 126 ; 127 #pragma omp target 128 #pragma omp teams distribute parallel for order( // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}} 129 for (int i = 0; i < 10; ++i) 130 ; 131 #pragma omp target 132 #pragma omp teams distribute parallel for order(none // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}} 133 for (int i = 0; i < 10; ++i) 134 ; 135 #pragma omp target 136 #pragma omp teams distribute parallel for order(concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} 137 for (int i = 0; i < 10; ++i) 138 ; 139 #pragma omp target 140 #pragma omp teams distribute parallel for order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} 141 for (int i = 0; i < 10; ++i) 142 ; 143 } 144 test_cancel()145void test_cancel() { 146 #pragma omp target 147 #pragma omp teams distribute parallel for 148 for (int i = 0; i < 16; ++i) { 149 #pragma omp cancel for 150 ; 151 } 152 } 153 154