Kelvin Li | 787f3fc | 2016-07-06 04:45:38 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -verify -fopenmp %s |
| 2 | |
Alexey Bataev | a8a9153a | 2017-12-29 18:07:07 +0000 | [diff] [blame^] | 3 | // RUN: %clang_cc1 -verify -fopenmp-simd %s |
| 4 | |
Kelvin Li | 787f3fc | 2016-07-06 04:45:38 +0000 | [diff] [blame] | 5 | void foo() { |
| 6 | } |
| 7 | |
| 8 | bool foobool(int argc) { |
| 9 | return argc; |
| 10 | } |
| 11 | |
| 12 | struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}} |
| 13 | extern S1 a; |
| 14 | class S2 { |
| 15 | mutable int a; |
| 16 | |
| 17 | public: |
| 18 | S2() : a(0) {} |
| 19 | S2(S2 &s2) : a(s2.a) {} |
| 20 | const S2 &operator =(const S2&) const; |
| 21 | S2 &operator =(const S2&); |
| 22 | static float S2s; // expected-note {{static data member is predetermined as shared}} |
Alexey Bataev | 4d4624c | 2017-07-20 16:47:47 +0000 | [diff] [blame] | 23 | static const float S2sc; // expected-note {{static data member is predetermined as shared}} |
Kelvin Li | 787f3fc | 2016-07-06 04:45:38 +0000 | [diff] [blame] | 24 | }; |
Alexey Bataev | 4d4624c | 2017-07-20 16:47:47 +0000 | [diff] [blame] | 25 | const float S2::S2sc = 0; |
Kelvin Li | 787f3fc | 2016-07-06 04:45:38 +0000 | [diff] [blame] | 26 | const S2 b; |
| 27 | const S2 ba[5]; |
| 28 | class S3 { |
| 29 | int a; |
Alexey Bataev | b358f99 | 2017-12-01 17:40:15 +0000 | [diff] [blame] | 30 | S3 &operator=(const S3 &s3); // expected-note {{implicitly declared private here}} |
Kelvin Li | 787f3fc | 2016-07-06 04:45:38 +0000 | [diff] [blame] | 31 | |
| 32 | public: |
| 33 | S3() : a(0) {} |
| 34 | S3(S3 &s3) : a(s3.a) {} |
| 35 | }; |
| 36 | const S3 c; // expected-note {{global variable is predetermined as shared}} |
| 37 | const S3 ca[5]; // expected-note {{global variable is predetermined as shared}} |
| 38 | extern const int f; // expected-note {{global variable is predetermined as shared}} |
| 39 | class S4 { |
| 40 | int a; |
| 41 | S4(); // expected-note 3 {{implicitly declared private here}} |
| 42 | S4(const S4 &s4); |
| 43 | |
| 44 | public: |
| 45 | S4(int v) : a(v) {} |
| 46 | }; |
| 47 | class S5 { |
| 48 | int a; |
| 49 | S5() : a(0) {} // expected-note {{implicitly declared private here}} |
| 50 | |
| 51 | public: |
| 52 | S5(const S5 &s5) : a(s5.a) {} |
| 53 | S5(int v) : a(v) {} |
| 54 | }; |
| 55 | class S6 { |
| 56 | int a; |
Alexey Bataev | b358f99 | 2017-12-01 17:40:15 +0000 | [diff] [blame] | 57 | S6() : a(0) {} // expected-note {{implicitly declared private here}} |
Kelvin Li | 787f3fc | 2016-07-06 04:45:38 +0000 | [diff] [blame] | 58 | |
| 59 | public: |
| 60 | S6(const S6 &s6) : a(s6.a) {} |
| 61 | S6(int v) : a(v) {} |
| 62 | }; |
| 63 | |
| 64 | S3 h; |
| 65 | #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} |
| 66 | |
| 67 | template <class I, class C> |
| 68 | int foomain(int argc, char **argv) { |
| 69 | I e(4); |
| 70 | I g(5); |
| 71 | int i; |
| 72 | int &j = i; |
| 73 | #pragma omp target |
| 74 | #pragma omp teams |
| 75 | #pragma omp distribute simd lastprivate // expected-error {{expected '(' after 'lastprivate'}} |
| 76 | for (int k = 0; k < argc; ++k) |
| 77 | ++k; |
| 78 | #pragma omp target |
| 79 | #pragma omp teams |
| 80 | #pragma omp distribute simd lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 81 | for (int k = 0; k < argc; ++k) |
| 82 | ++k; |
| 83 | #pragma omp target |
| 84 | #pragma omp teams |
| 85 | #pragma omp distribute simd lastprivate() // expected-error {{expected expression}} |
| 86 | for (int k = 0; k < argc; ++k) |
| 87 | ++k; |
| 88 | #pragma omp target |
| 89 | #pragma omp teams |
| 90 | #pragma omp distribute simd lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 91 | for (int k = 0; k < argc; ++k) |
| 92 | ++k; |
| 93 | #pragma omp target |
| 94 | #pragma omp teams |
| 95 | #pragma omp distribute simd lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 96 | for (int k = 0; k < argc; ++k) |
| 97 | ++k; |
| 98 | #pragma omp target |
| 99 | #pragma omp teams |
| 100 | #pragma omp distribute simd lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
| 101 | for (int k = 0; k < argc; ++k) |
| 102 | ++k; |
| 103 | #pragma omp target |
| 104 | #pragma omp teams |
| 105 | #pragma omp distribute simd lastprivate(argc) |
| 106 | for (int k = 0; k < argc; ++k) |
| 107 | ++k; |
| 108 | #pragma omp target |
| 109 | #pragma omp teams |
| 110 | #pragma omp distribute simd lastprivate(S1) // expected-error {{'S1' does not refer to a value}} |
| 111 | for (int k = 0; k < argc; ++k) |
| 112 | ++k; |
| 113 | #pragma omp target |
| 114 | #pragma omp teams |
| 115 | #pragma omp distribute simd lastprivate(a, b) // expected-error {{lastprivate variable with incomplete type 'S1'}} |
| 116 | for (int k = 0; k < argc; ++k) |
| 117 | ++k; |
| 118 | #pragma omp target |
| 119 | #pragma omp teams |
| 120 | #pragma omp distribute simd lastprivate(argv[1]) // expected-error {{expected variable name}} |
| 121 | for (int k = 0; k < argc; ++k) |
| 122 | ++k; |
| 123 | #pragma omp target |
| 124 | #pragma omp teams |
| 125 | #pragma omp distribute simd lastprivate(e, g) // expected-error 2 {{calling a private constructor of class 'S4'}} |
| 126 | for (int k = 0; k < argc; ++k) |
| 127 | ++k; |
| 128 | #pragma omp target |
| 129 | #pragma omp teams |
| 130 | #pragma omp distribute simd lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} |
| 131 | for (int k = 0; k < argc; ++k) |
| 132 | ++k; |
| 133 | |
| 134 | int v = 0; |
| 135 | #pragma omp target |
| 136 | #pragma omp teams |
| 137 | { |
| 138 | #pragma omp distribute simd lastprivate(i) |
| 139 | for (int k = 0; k < argc; ++k) { |
| 140 | i = k; |
| 141 | v += i; |
| 142 | } |
| 143 | } |
| 144 | #pragma omp target |
| 145 | #pragma omp teams private(i) |
| 146 | #pragma omp distribute simd lastprivate(j) |
| 147 | for (int k = 0; k < argc; ++k) |
| 148 | ++k; |
| 149 | #pragma omp target |
| 150 | #pragma omp teams |
| 151 | #pragma omp distribute simd lastprivate(i) |
| 152 | for (int k = 0; k < argc; ++k) |
| 153 | ++k; |
| 154 | return 0; |
| 155 | } |
| 156 | |
| 157 | void bar(S4 a[2]) { |
| 158 | #pragma omp target |
| 159 | #pragma omp teams |
| 160 | #pragma omp distribute simd lastprivate(a) |
| 161 | for (int i = 0; i < 2; ++i) |
| 162 | foo(); |
| 163 | } |
| 164 | |
| 165 | namespace A { |
| 166 | double x; |
| 167 | #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} |
| 168 | } |
| 169 | namespace B { |
| 170 | using A::x; |
| 171 | } |
| 172 | |
| 173 | int main(int argc, char **argv) { |
| 174 | const int d = 5; // expected-note {{constant variable is predetermined as shared}} |
| 175 | const int da[5] = {0}; // expected-note {{constant variable is predetermined as shared}} |
| 176 | S4 e(4); |
| 177 | S5 g(5); |
| 178 | S3 m; |
| 179 | S6 n(2); |
| 180 | int i; |
| 181 | int &j = i; |
| 182 | #pragma omp target |
| 183 | #pragma omp teams |
| 184 | #pragma omp distribute simd lastprivate // expected-error {{expected '(' after 'lastprivate'}} |
| 185 | for (i = 0; i < argc; ++i) |
| 186 | foo(); |
| 187 | #pragma omp target |
| 188 | #pragma omp teams |
| 189 | #pragma omp distribute simd lastprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 190 | for (i = 0; i < argc; ++i) |
| 191 | foo(); |
| 192 | #pragma omp target |
| 193 | #pragma omp teams |
| 194 | #pragma omp distribute simd lastprivate() // expected-error {{expected expression}} |
| 195 | for (i = 0; i < argc; ++i) |
| 196 | foo(); |
| 197 | #pragma omp target |
| 198 | #pragma omp teams |
| 199 | #pragma omp distribute simd lastprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 200 | for (i = 0; i < argc; ++i) |
| 201 | foo(); |
| 202 | #pragma omp target |
| 203 | #pragma omp teams |
| 204 | #pragma omp distribute simd lastprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} |
| 205 | for (i = 0; i < argc; ++i) |
| 206 | foo(); |
| 207 | #pragma omp target |
| 208 | #pragma omp teams |
| 209 | #pragma omp distribute simd lastprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} |
| 210 | for (i = 0; i < argc; ++i) |
| 211 | foo(); |
| 212 | #pragma omp target |
| 213 | #pragma omp teams |
| 214 | #pragma omp distribute simd lastprivate(argc) |
| 215 | for (i = 0; i < argc; ++i) |
| 216 | foo(); |
| 217 | #pragma omp target |
| 218 | #pragma omp teams |
| 219 | #pragma omp distribute simd lastprivate(S1) // expected-error {{'S1' does not refer to a value}} |
| 220 | for (i = 0; i < argc; ++i) |
| 221 | foo(); |
| 222 | #pragma omp target |
| 223 | #pragma omp teams |
| 224 | #pragma omp distribute simd lastprivate(a, b, c, d, f) // expected-error {{lastprivate variable with incomplete type 'S1'}} expected-error 3 {{shared variable cannot be lastprivate}} |
| 225 | for (i = 0; i < argc; ++i) |
| 226 | foo(); |
| 227 | #pragma omp target |
| 228 | #pragma omp teams |
| 229 | #pragma omp distribute simd lastprivate(argv[1]) // expected-error {{expected variable name}} |
| 230 | for (i = 0; i < argc; ++i) |
| 231 | foo(); |
| 232 | #pragma omp target |
| 233 | #pragma omp teams |
| 234 | #pragma omp distribute simd lastprivate(2 * 2) // expected-error {{expected variable name}} |
| 235 | for (i = 0; i < argc; ++i) |
| 236 | foo(); |
| 237 | #pragma omp target |
| 238 | #pragma omp teams |
| 239 | #pragma omp distribute simd lastprivate(ba) |
| 240 | for (i = 0; i < argc; ++i) |
| 241 | foo(); |
| 242 | #pragma omp target |
| 243 | #pragma omp teams |
| 244 | #pragma omp distribute simd lastprivate(ca) // expected-error {{shared variable cannot be lastprivate}} |
| 245 | for (i = 0; i < argc; ++i) |
| 246 | foo(); |
| 247 | #pragma omp target |
| 248 | #pragma omp teams |
| 249 | #pragma omp distribute simd lastprivate(da) // expected-error {{shared variable cannot be lastprivate}} |
| 250 | for (i = 0; i < argc; ++i) |
| 251 | foo(); |
| 252 | int xa; |
| 253 | #pragma omp target |
| 254 | #pragma omp teams |
| 255 | #pragma omp distribute simd lastprivate(xa) // OK |
| 256 | for (i = 0; i < argc; ++i) |
| 257 | foo(); |
| 258 | #pragma omp target |
| 259 | #pragma omp teams |
| 260 | #pragma omp distribute simd lastprivate(S2::S2s) // expected-error {{shared variable cannot be lastprivate}} |
| 261 | for (i = 0; i < argc; ++i) |
| 262 | foo(); |
| 263 | #pragma omp target |
| 264 | #pragma omp teams |
| 265 | #pragma omp distribute simd lastprivate(S2::S2sc) // expected-error {{shared variable cannot be lastprivate}} |
| 266 | for (i = 0; i < argc; ++i) |
| 267 | foo(); |
| 268 | #pragma omp target |
| 269 | #pragma omp teams |
| 270 | #pragma omp distribute simd safelen(5) // OK |
| 271 | for (i = 0; i < argc; ++i) |
| 272 | foo(); |
| 273 | #pragma omp target |
| 274 | #pragma omp teams |
| 275 | #pragma omp distribute simd lastprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}} |
| 276 | for (i = 0; i < argc; ++i) |
| 277 | foo(); |
| 278 | #pragma omp target |
| 279 | #pragma omp teams |
| 280 | #pragma omp distribute simd lastprivate(m) // expected-error {{'operator=' is a private member of 'S3'}} |
| 281 | for (i = 0; i < argc; ++i) |
| 282 | foo(); |
| 283 | #pragma omp target |
| 284 | #pragma omp teams |
| 285 | #pragma omp distribute simd lastprivate(h) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} |
| 286 | for (i = 0; i < argc; ++i) |
| 287 | foo(); |
| 288 | #pragma omp target |
| 289 | #pragma omp teams |
| 290 | #pragma omp distribute simd lastprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be lastprivate}} |
| 291 | for (i = 0; i < argc; ++i) |
| 292 | foo(); |
| 293 | #pragma omp target |
| 294 | #pragma omp teams |
| 295 | #pragma omp distribute simd private(xa), lastprivate(xa) // expected-error {{private variable cannot be lastprivate}} expected-note {{defined as private}} |
| 296 | for (i = 0; i < argc; ++i) |
| 297 | foo(); |
| 298 | #pragma omp target |
| 299 | #pragma omp teams |
| 300 | #pragma omp distribute simd lastprivate(i) // expected-note {{defined as lastprivate}} |
| 301 | for (i = 0; i < argc; ++i) // expected-error{{loop iteration variable in the associated loop of 'omp distribute simd' directive may not be lastprivate, predetermined as linear}} |
| 302 | foo(); |
| 303 | #pragma omp target |
| 304 | #pragma omp teams |
| 305 | #pragma omp distribute simd lastprivate(xa) |
| 306 | for (i = 0; i < argc; ++i) |
| 307 | foo(); |
| 308 | #pragma omp target |
| 309 | #pragma omp teams |
| 310 | #pragma omp distribute simd lastprivate(xa) |
| 311 | for (i = 0; i < argc; ++i) |
| 312 | foo(); |
| 313 | #pragma omp target |
| 314 | #pragma omp teams |
| 315 | #pragma omp distribute simd lastprivate(j) |
| 316 | for (i = 0; i < argc; ++i) |
| 317 | foo(); |
Alexey Bataev | b358f99 | 2017-12-01 17:40:15 +0000 | [diff] [blame] | 318 | // expected-error@+3 {{firstprivate variable cannot be lastprivate}} expected-note@+3 {{defined as firstprivate}} |
Kelvin Li | 787f3fc | 2016-07-06 04:45:38 +0000 | [diff] [blame] | 319 | #pragma omp target |
| 320 | #pragma omp teams |
Alexey Bataev | b358f99 | 2017-12-01 17:40:15 +0000 | [diff] [blame] | 321 | #pragma omp distribute simd firstprivate(m) lastprivate(m) |
Kelvin Li | 787f3fc | 2016-07-06 04:45:38 +0000 | [diff] [blame] | 322 | for (i = 0; i < argc; ++i) |
| 323 | foo(); |
Alexey Bataev | b358f99 | 2017-12-01 17:40:15 +0000 | [diff] [blame] | 324 | // expected-error@+3 {{lastprivate variable cannot be firstprivate}} expected-note@+3 {{defined as lastprivate}} |
Kelvin Li | 787f3fc | 2016-07-06 04:45:38 +0000 | [diff] [blame] | 325 | #pragma omp target |
| 326 | #pragma omp teams |
Alexey Bataev | b358f99 | 2017-12-01 17:40:15 +0000 | [diff] [blame] | 327 | #pragma omp distribute simd lastprivate(n) firstprivate(n) // expected-error {{calling a private constructor of class 'S6'}} |
Kelvin Li | 787f3fc | 2016-07-06 04:45:38 +0000 | [diff] [blame] | 328 | for (i = 0; i < argc; ++i) |
| 329 | foo(); |
| 330 | static int si; |
| 331 | #pragma omp target |
| 332 | #pragma omp teams |
| 333 | #pragma omp distribute simd lastprivate(si) // OK |
| 334 | for (i = 0; i < argc; ++i) |
| 335 | si = i + 1; |
| 336 | return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}} |
| 337 | } |