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