Alexey Bataev | 4db4868 | 2019-12-06 09:49:07 -0500 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify -fopenmp %s -Wno-openmp-mapping -Wuninitialized |
Kelvin Li | 4e325f7 | 2016-10-25 12:50:55 +0000 | [diff] [blame] | 2 | |
Alexey Bataev | 4db4868 | 2019-12-06 09:49:07 -0500 | [diff] [blame] | 3 | // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wno-openmp-mapping -Wuninitialized |
Alexey Bataev | a8a9153a | 2017-12-29 18:07:07 +0000 | [diff] [blame] | 4 | |
Kelvin Li | 4e325f7 | 2016-10-25 12:50:55 +0000 | [diff] [blame] | 5 | void foo() { |
| 6 | } |
| 7 | |
| 8 | bool foobool(int argc) { |
| 9 | return argc; |
| 10 | } |
| 11 | |
Jennifer Yu | 656d022 | 2021-08-03 10:35:04 -0700 | [diff] [blame] | 12 | struct S1; // expected-note {{declared here}} // expected-note {{forward declaration of 'S1'}} |
Kelvin Li | 4e325f7 | 2016-10-25 12:50:55 +0000 | [diff] [blame] | 13 | extern S1 a; |
| 14 | class S2 { |
| 15 | mutable int a; |
| 16 | public: |
| 17 | S2():a(0) { } |
| 18 | S2(S2 &s2):a(s2.a) { } |
| 19 | }; |
| 20 | const S2 b; |
| 21 | const S2 ba[5]; |
| 22 | class S3 { |
| 23 | int a; |
| 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 | public: |
| 36 | S4(int v):a(v) { } |
| 37 | }; |
| 38 | class S5 { |
| 39 | int a; |
| 40 | S5():a(0) {} |
| 41 | S5(const S5 &s5):a(s5.a) { } |
| 42 | public: |
| 43 | S5(int v):a(v) { } |
| 44 | }; |
| 45 | |
| 46 | S3 h; |
| 47 | #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}} |
| 48 | |
| 49 | namespace A { |
| 50 | double x; |
| 51 | #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} |
| 52 | } |
| 53 | namespace B { |
| 54 | using A::x; |
| 55 | } |
| 56 | |
| 57 | int main(int argc, char **argv) { |
| 58 | const int d = 5; |
| 59 | const int da[5] = { 0 }; |
| 60 | S4 e(4); |
| 61 | S5 g(5); |
Alexey Bataev | a914888 | 2019-07-08 15:45:24 +0000 | [diff] [blame] | 62 | int i, z; |
Kelvin Li | 4e325f7 | 2016-10-25 12:50:55 +0000 | [diff] [blame] | 63 | int &j = i; |
| 64 | #pragma omp target |
| 65 | #pragma omp teams distribute simd shared // expected-error {{expected '(' after 'shared'}} |
| 66 | for (int j=0; j<100; j++) foo(); |
| 67 | #pragma omp target |
| 68 | #pragma omp teams distribute simd shared ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 69 | for (int j=0; j<100; j++) foo(); |
| 70 | #pragma omp target |
| 71 | #pragma omp teams distribute simd shared () // expected-error {{expected expression}} |
| 72 | for (int j=0; j<100; j++) foo(); |
| 73 | #pragma omp target |
| 74 | #pragma omp teams distribute simd shared (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 75 | for (int j=0; j<100; j++) foo(); |
| 76 | #pragma omp target |
| 77 | #pragma omp teams distribute simd shared (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 78 | for (int j=0; j<100; j++) foo(); |
| 79 | #pragma omp target |
| 80 | #pragma omp teams distribute simd shared (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
| 81 | for (int j=0; j<100; j++) foo(); |
| 82 | #pragma omp target |
| 83 | #pragma omp teams distribute simd shared (argc) |
| 84 | for (int j=0; j<100; j++) foo(); |
| 85 | #pragma omp target |
| 86 | #pragma omp teams distribute simd shared (S1) // expected-error {{'S1' does not refer to a value}} |
| 87 | for (int j=0; j<100; j++) foo(); |
| 88 | #pragma omp target |
Alexey Bataev | f47c4b4 | 2017-09-26 13:47:31 +0000 | [diff] [blame] | 89 | #pragma omp teams distribute simd shared (a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} |
Kelvin Li | 4e325f7 | 2016-10-25 12:50:55 +0000 | [diff] [blame] | 90 | for (int j=0; j<100; j++) foo(); |
| 91 | #pragma omp target |
| 92 | #pragma omp teams distribute simd shared (argv[1]) // expected-error {{expected variable name}} |
| 93 | for (int j=0; j<100; j++) foo(); |
| 94 | #pragma omp target |
| 95 | #pragma omp teams distribute simd shared(ba) |
| 96 | for (int j=0; j<100; j++) foo(); |
| 97 | #pragma omp target |
| 98 | #pragma omp teams distribute simd shared(ca) |
| 99 | for (int j=0; j<100; j++) foo(); |
| 100 | #pragma omp target |
| 101 | #pragma omp teams distribute simd shared(da) |
| 102 | for (int j=0; j<100; j++) foo(); |
| 103 | #pragma omp target |
Alexey Bataev | a914888 | 2019-07-08 15:45:24 +0000 | [diff] [blame] | 104 | #pragma omp teams distribute simd shared(e, g, z) |
Kelvin Li | 4e325f7 | 2016-10-25 12:50:55 +0000 | [diff] [blame] | 105 | for (int j=0; j<100; j++) foo(); |
| 106 | #pragma omp target |
| 107 | #pragma omp teams distribute simd shared(h, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be shared}} |
| 108 | for (int j=0; j<100; j++) foo(); |
| 109 | #pragma omp target |
| 110 | #pragma omp teams distribute simd private(i), shared(i) // expected-error {{private variable cannot be shared}} expected-note {{defined as private}} |
| 111 | for (int j=0; j<100; j++) foo(); |
| 112 | #pragma omp target |
| 113 | #pragma omp teams distribute simd firstprivate(i), shared(i) // expected-error {{firstprivate variable cannot be shared}} expected-note {{defined as firstprivate}} |
| 114 | for (int j=0; j<100; j++) foo(); |
| 115 | #pragma omp target |
| 116 | #pragma omp teams distribute simd private(i) |
| 117 | for (int j=0; j<100; j++) foo(); |
| 118 | #pragma omp target |
| 119 | #pragma omp teams distribute simd shared(i) |
| 120 | for (int j=0; j<100; j++) foo(); |
| 121 | #pragma omp target |
| 122 | #pragma omp teams distribute simd shared(j) |
| 123 | for (int j=0; j<100; j++) foo(); |
| 124 | #pragma omp target |
| 125 | #pragma omp teams distribute simd firstprivate(i) |
| 126 | for (int j=0; j<100; j++) foo(); |
| 127 | |
| 128 | return 0; |
| 129 | } |