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