Alexey Bataev | 95c23e7 | 2018-02-27 21:31:11 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify -fopenmp %s -Wno-openmp-target |
Kelvin Li | 0253287 | 2016-08-05 14:37:37 +0000 | [diff] [blame] | 2 | |
Alexey Bataev | 95c23e7 | 2018-02-27 21:31:11 +0000 | [diff] [blame] | 3 | // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wno-openmp-target |
Alexey Bataev | a8a9153a | 2017-12-29 18:07:07 +0000 | [diff] [blame] | 4 | |
Kelvin Li | 0253287 | 2016-08-05 14:37:37 +0000 | [diff] [blame] | 5 | void foo() { |
| 6 | } |
| 7 | |
| 8 | bool foobool(int argc) { |
| 9 | return argc; |
| 10 | } |
| 11 | |
| 12 | struct S1; // expected-note {{declared here}} expected-note{{forward declaration of 'S1'}} |
| 13 | extern S1 a; |
| 14 | class S2 { |
| 15 | mutable int a; |
| 16 | |
| 17 | public: |
| 18 | S2() : a(0) {} |
| 19 | S2(const S2 &s2) : a(s2.a) {} |
| 20 | static float S2s; |
| 21 | static const float S2sc; |
| 22 | }; |
| 23 | const float S2::S2sc = 0; |
| 24 | const S2 b; |
| 25 | const S2 ba[5]; |
| 26 | class S3 { |
| 27 | int a; |
| 28 | S3 &operator=(const S3 &s3); |
| 29 | |
| 30 | public: |
| 31 | S3() : a(0) {} // expected-note {{candidate constructor not viable: requires 0 arguments, but 1 was provided}} |
| 32 | S3(S3 &s3) : a(s3.a) {} // expected-note {{candidate constructor not viable: 1st argument ('const S3') would lose const qualifier}} |
| 33 | }; |
| 34 | const S3 c; |
| 35 | const S3 ca[5]; |
| 36 | extern const int f; |
| 37 | class S4 { |
| 38 | int a; |
| 39 | S4(); |
| 40 | S4(const S4 &s4); |
| 41 | public: |
| 42 | S4(int v):a(v) { } |
| 43 | }; |
| 44 | class S5 { |
| 45 | int a; |
| 46 | S5():a(0) {} |
| 47 | S5(const S5 &s5):a(s5.a) { } |
| 48 | public: |
| 49 | S5(int v):a(v) { } |
| 50 | }; |
| 51 | class S6 { |
| 52 | int a; |
| 53 | public: |
| 54 | S6() : a(0) { } |
| 55 | }; |
| 56 | |
| 57 | S3 h; |
| 58 | #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}} |
| 59 | |
| 60 | int main(int argc, char **argv) { |
| 61 | const int d = 5; |
| 62 | const int da[5] = { 0 }; |
| 63 | S4 e(4); |
| 64 | S5 g(5); |
| 65 | S6 p; |
| 66 | int i; |
| 67 | int &j = i; |
| 68 | |
| 69 | #pragma omp target |
| 70 | #pragma omp teams distribute firstprivate // expected-error {{expected '(' after 'firstprivate'}} |
| 71 | for (i = 0; i < argc; ++i) foo(); |
| 72 | |
| 73 | #pragma omp target |
| 74 | #pragma omp teams distribute firstprivate ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 75 | for (i = 0; i < argc; ++i) foo(); |
| 76 | |
| 77 | #pragma omp target |
| 78 | #pragma omp teams distribute firstprivate () // expected-error {{expected expression}} |
| 79 | for (i = 0; i < argc; ++i) foo(); |
| 80 | |
| 81 | #pragma omp target |
| 82 | #pragma omp teams distribute firstprivate (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 83 | for (i = 0; i < argc; ++i) foo(); |
| 84 | |
| 85 | #pragma omp target |
| 86 | #pragma omp teams distribute firstprivate (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 87 | for (i = 0; i < argc; ++i) foo(); |
| 88 | |
| 89 | #pragma omp target |
| 90 | #pragma omp teams distribute firstprivate (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
| 91 | for (i = 0; i < argc; ++i) foo(); |
| 92 | |
| 93 | #pragma omp target |
| 94 | #pragma omp teams distribute firstprivate (argc) |
| 95 | for (i = 0; i < argc; ++i) foo(); |
| 96 | |
| 97 | #pragma omp target |
| 98 | #pragma omp teams distribute firstprivate (S1) // expected-error {{'S1' does not refer to a value}} |
| 99 | for (i = 0; i < argc; ++i) foo(); |
| 100 | |
| 101 | #pragma omp target |
| 102 | #pragma omp teams distribute firstprivate (a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} |
| 103 | for (i = 0; i < argc; ++i) foo(); |
| 104 | |
| 105 | #pragma omp target |
| 106 | #pragma omp teams distribute firstprivate (argv[1]) // expected-error {{expected variable name}} |
| 107 | for (i = 0; i < argc; ++i) foo(); |
| 108 | |
| 109 | #pragma omp target |
| 110 | #pragma omp teams distribute firstprivate(ba) |
| 111 | for (i = 0; i < argc; ++i) foo(); |
| 112 | |
| 113 | #pragma omp target |
| 114 | #pragma omp teams distribute firstprivate(ca) // expected-error {{no matching constructor for initialization of 'S3'}} |
| 115 | for (i = 0; i < argc; ++i) foo(); |
| 116 | |
| 117 | #pragma omp target |
| 118 | #pragma omp teams distribute firstprivate(da) |
| 119 | for (i = 0; i < argc; ++i) foo(); |
| 120 | |
| 121 | #pragma omp target |
| 122 | #pragma omp teams distribute firstprivate(S2::S2s) |
| 123 | for (i = 0; i < argc; ++i) foo(); |
| 124 | |
| 125 | #pragma omp target |
| 126 | #pragma omp teams distribute firstprivate(S2::S2sc) |
| 127 | for (i = 0; i < argc; ++i) foo(); |
| 128 | |
| 129 | #pragma omp target |
| 130 | #pragma omp teams distribute firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} |
| 131 | for (i = 0; i < argc; ++i) foo(); |
| 132 | |
| 133 | #pragma omp target |
| 134 | #pragma omp teams distribute private(i), firstprivate(i) // expected-error {{private variable cannot be firstprivate}} expected-note{{defined as private}} |
| 135 | for (i = 0; i < argc; ++i) foo(); |
| 136 | |
| 137 | #pragma omp target |
| 138 | #pragma omp teams distribute firstprivate(i) |
| 139 | for (j = 0; j < argc; ++j) foo(); |
| 140 | |
| 141 | #pragma omp target |
| 142 | #pragma omp teams distribute firstprivate(i) // expected-note {{defined as firstprivate}} |
| 143 | for (i = 0; i < argc; ++i) foo(); // expected-error {{loop iteration variable in the associated loop of 'omp teams distribute' directive may not be firstprivate, predetermined as private}} |
| 144 | |
| 145 | #pragma omp target |
| 146 | #pragma omp teams distribute firstprivate(j) |
| 147 | for (i = 0; i < argc; ++i) foo(); |
| 148 | |
Alexey Bataev | b358f99 | 2017-12-01 17:40:15 +0000 | [diff] [blame] | 149 | // expected-error@+2 {{lastprivate variable cannot be firstprivate}} expected-note@+2 {{defined as lastprivate}} |
Kelvin Li | 0253287 | 2016-08-05 14:37:37 +0000 | [diff] [blame] | 150 | #pragma omp target |
Alexey Bataev | b358f99 | 2017-12-01 17:40:15 +0000 | [diff] [blame] | 151 | #pragma omp teams distribute lastprivate(argc), firstprivate(argc) |
Kelvin Li | 0253287 | 2016-08-05 14:37:37 +0000 | [diff] [blame] | 152 | for (i = 0; i < argc; ++i) foo(); |
| 153 | |
| 154 | return 0; |
| 155 | } |