1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 -o - %s 2 3 void foo() { 4 } 5 6 static int pvt; 7 #pragma omp threadprivate(pvt) 8 9 #pragma omp target parallel for // expected-error {{unexpected OpenMP directive '#pragma omp target parallel for'}} 10 11 int main(int argc, char **argv) { 12 #pragma omp target parallel for { // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}} 13 for (int i = 0; i < argc; ++i) 14 foo(); 15 #pragma omp target parallel for ( // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}} 16 for (int i = 0; i < argc; ++i) 17 foo(); 18 #pragma omp target parallel for[ // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}} 19 for (int i = 0; i < argc; ++i) 20 foo(); 21 #pragma omp target parallel for] // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}} 22 for (int i = 0; i < argc; ++i) 23 foo(); 24 #pragma omp target parallel for) // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}} 25 for (int i = 0; i < argc; ++i) 26 foo(); 27 #pragma omp target parallel for } // expected-warning {{extra tokens at the end of '#pragma omp target parallel for' are ignored}} 28 for (int i = 0; i < argc; ++i) 29 foo(); 30 #pragma omp target parallel for 31 for (int i = 0; i < argc; ++i) 32 foo(); 33 // expected-warning@+1 {{extra tokens at the end of '#pragma omp target parallel for' are ignored}} 34 #pragma omp target parallel for unknown() 35 for (int i = 0; i < argc; ++i) 36 foo(); 37 L1: 38 for (int i = 0; i < argc; ++i) 39 foo(); 40 #pragma omp target parallel for 41 for (int i = 0; i < argc; ++i) 42 foo(); 43 #pragma omp target parallel for 44 for (int i = 0; i < argc; ++i) { 45 goto L1; // expected-error {{use of undeclared label 'L1'}} 46 argc++; 47 } 48 49 for (int i = 0; i < 10; ++i) { 50 switch (argc) { 51 case (0): 52 #pragma omp target parallel for 53 for (int i = 0; i < argc; ++i) { 54 foo(); 55 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}} 56 continue; 57 } 58 default: 59 break; 60 } 61 } 62 #pragma omp target parallel for default(none) 63 for (int i = 0; i < 10; ++i) 64 ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}} 65 66 goto L2; // expected-error {{use of undeclared label 'L2'}} 67 #pragma omp target parallel for 68 for (int i = 0; i < argc; ++i) 69 L2: 70 foo(); 71 #pragma omp target parallel for 72 for (int i = 0; i < argc; ++i) { 73 return 1; // expected-error {{cannot return from OpenMP region}} 74 } 75 76 [[]] // expected-error {{an attribute list cannot appear here}} 77 #pragma omp target parallel for 78 for (int n = 0; n < 100; ++n) { 79 } 80 81 #pragma omp target parallel for copyin(pvt) // expected-error {{unexpected OpenMP clause 'copyin' in directive '#pragma omp target parallel for'}} 82 for (int n = 0; n < 100; ++n) {} 83 84 return 0; 85 } 86 87 void test_ordered() { 88 #pragma omp target parallel for ordered ordered // expected-error {{directive '#pragma omp target parallel for' cannot contain more than one 'ordered' clause}} 89 for (int i = 0; i < 16; ++i) 90 ; 91 } 92 93