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