Alexey Bataev | 84d0b3e | 2014-07-08 08:12:03 +0000 | [diff] [blame^] | 1 | // RUN: %clang_cc1 -verify -fopenmp=libiomp5 -ferror-limit 100 %s |
| 2 | |
| 3 | void foo() { |
| 4 | } |
| 5 | |
| 6 | bool foobool(int argc) { |
| 7 | return argc; |
| 8 | } |
| 9 | |
| 10 | struct S1; // expected-note {{declared here}} |
| 11 | extern S1 a; |
| 12 | class S2 { |
| 13 | mutable int a; |
| 14 | |
| 15 | public: |
| 16 | S2() : a(0) {} |
| 17 | S2(S2 &s2) : a(s2.a) {} |
| 18 | }; |
| 19 | const S2 b; |
| 20 | const S2 ba[5]; |
| 21 | class S3 { |
| 22 | int a; |
| 23 | |
| 24 | public: |
| 25 | S3() : a(0) {} |
| 26 | S3(S3 &s3) : a(s3.a) {} |
| 27 | }; |
| 28 | const S3 c; |
| 29 | const S3 ca[5]; |
| 30 | extern const int f; |
| 31 | class S4 { |
| 32 | int a; |
| 33 | S4(); |
| 34 | S4(const S4 &s4); |
| 35 | |
| 36 | public: |
| 37 | S4(int v) : a(v) {} |
| 38 | }; |
| 39 | class S5 { |
| 40 | int a; |
| 41 | S5() : a(0) {} |
| 42 | S5(const S5 &s5) : a(s5.a) {} |
| 43 | |
| 44 | public: |
| 45 | S5(int v) : a(v) {} |
| 46 | }; |
| 47 | |
| 48 | S3 h; |
| 49 | #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}} |
| 50 | |
| 51 | int main(int argc, char **argv) { |
| 52 | const int d = 5; |
| 53 | const int da[5] = {0}; |
| 54 | S4 e(4); |
| 55 | S5 g(5); |
| 56 | int i; |
| 57 | int &j = i; |
| 58 | #pragma omp parallel sections shared // expected-error {{expected '(' after 'shared'}} |
| 59 | { foo(); } |
| 60 | #pragma omp parallel sections shared( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 61 | { foo(); } |
| 62 | #pragma omp parallel sections shared() // expected-error {{expected expression}} |
| 63 | { foo(); } |
| 64 | #pragma omp parallel sections shared(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 65 | { foo(); } |
| 66 | #pragma omp parallel sections shared(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 67 | { foo(); } |
| 68 | #pragma omp parallel sections shared(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
| 69 | { foo(); } |
| 70 | #pragma omp parallel sections shared(argc) |
| 71 | { foo(); } |
| 72 | #pragma omp parallel sections shared(S1) // expected-error {{'S1' does not refer to a value}} |
| 73 | { foo(); } |
| 74 | #pragma omp parallel sections shared(a, b, c, d, f) |
| 75 | { foo(); } |
| 76 | #pragma omp parallel sections shared(argv[1]) // expected-error {{expected variable name}} |
| 77 | { foo(); } |
| 78 | #pragma omp parallel sections shared(ba) |
| 79 | { foo(); } |
| 80 | #pragma omp parallel sections shared(ca) |
| 81 | { foo(); } |
| 82 | #pragma omp parallel sections shared(da) |
| 83 | { foo(); } |
| 84 | #pragma omp parallel sections shared(e, g) |
| 85 | { foo(); } |
| 86 | #pragma omp parallel sections shared(h) // expected-error {{threadprivate or thread local variable cannot be shared}} |
| 87 | { foo(); } |
| 88 | #pragma omp parallel sections private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}} |
| 89 | { foo(); } |
| 90 | #pragma omp parallel sections firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}} |
| 91 | { foo(); } |
| 92 | #pragma omp parallel sections private(i) |
| 93 | { |
| 94 | #pragma omp parallel sections shared(i) |
| 95 | { |
| 96 | #pragma omp parallel sections shared(j) |
| 97 | { foo(); } |
| 98 | } |
| 99 | } |
| 100 | #pragma omp parallel sections firstprivate(i) |
| 101 | { |
| 102 | #pragma omp parallel sections shared(i) |
| 103 | { |
| 104 | #pragma omp parallel sections shared(j) |
| 105 | { foo(); } |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | return 0; |
| 110 | } |