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