Kelvin Li | 83c451e | 2016-12-25 04:52:54 +0000 | [diff] [blame^] | 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 teams distribute // expected-error {{unexpected OpenMP directive '#pragma omp target teams distribute'}} |
| 10 | |
| 11 | int main(int argc, char **argv) { |
| 12 | #pragma omp target teams distribute { // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} |
| 13 | for (int i = 0; i < argc; ++i) |
| 14 | foo(); |
| 15 | #pragma omp target teams distribute ( // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} |
| 16 | for (int i = 0; i < argc; ++i) |
| 17 | foo(); |
| 18 | #pragma omp target teams distribute[ // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} |
| 19 | for (int i = 0; i < argc; ++i) |
| 20 | foo(); |
| 21 | #pragma omp target teams distribute] // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} |
| 22 | for (int i = 0; i < argc; ++i) |
| 23 | foo(); |
| 24 | #pragma omp target teams distribute) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} |
| 25 | for (int i = 0; i < argc; ++i) |
| 26 | foo(); |
| 27 | #pragma omp target teams distribute } // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} |
| 28 | for (int i = 0; i < argc; ++i) |
| 29 | foo(); |
| 30 | #pragma omp target teams distribute |
| 31 | for (int i = 0; i < argc; ++i) |
| 32 | foo(); |
| 33 | // expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute' are ignored}} |
| 34 | #pragma omp target teams distribute 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 teams distribute |
| 41 | for (int i = 0; i < argc; ++i) |
| 42 | foo(); |
| 43 | #pragma omp target teams distribute |
| 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 teams distribute |
| 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 teams distribute 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 teams distribute |
| 68 | for (int i = 0; i < argc; ++i) |
| 69 | L2: |
| 70 | foo(); |
| 71 | #pragma omp target teams distribute |
| 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 teams distribute |
| 78 | for (int n = 0; n < 100; ++n) { |
| 79 | } |
| 80 | |
| 81 | #pragma omp target teams distribute copyin(pvt) // expected-error {{unexpected OpenMP clause 'copyin' in directive '#pragma omp target teams distribute'}} |
| 82 | for (int n = 0; n < 100; ++n) {} |
| 83 | |
| 84 | return 0; |
| 85 | } |
| 86 | |
| 87 | void test_ordered() { |
| 88 | #pragma omp target teams distribute ordered // expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp target teams distribute'}} |
| 89 | for (int i = 0; i < 16; ++i) |
| 90 | ; |
| 91 | } |
| 92 | |