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