1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized 2 3 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized 4 5 extern int omp_default_mem_alloc; 6 7 void xxx(int argc) { 8 int i; 9 #pragma omp distribute simd linear(i) 10 for (i = 0; i < 10; ++i) 11 ; 12 } 13 14 namespace X { 15 int x; 16 }; 17 18 struct B { 19 static int ib; // expected-note {{'B::ib' declared here}} 20 static int bfoo() { return 8; } 21 }; 22 23 int bfoo() { return 4; } 24 25 int z; 26 const int C1 = 1; 27 const int C2 = 2; 28 void test_linear_colons() 29 { 30 int B = 0; 31 32 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} 33 #pragma omp target 34 #pragma omp teams 35 #pragma omp distribute simd linear(B:bfoo()) 36 for (int i = 0; i < 10; ++i) ; 37 38 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} 39 #pragma omp target 40 #pragma omp teams 41 #pragma omp distribute simd linear(B::ib:B:bfoo()) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'}} 42 for (int i = 0; i < 10; ++i) ; 43 44 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} 45 #pragma omp target 46 #pragma omp teams 47 #pragma omp distribute simd linear(B:ib) // expected-error {{use of undeclared identifier 'ib'; did you mean 'B::ib'}} 48 for (int i = 0; i < 10; ++i) ; 49 50 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} 51 #pragma omp target 52 #pragma omp teams 53 #pragma omp distribute simd linear(z:B:ib) // expected-error {{unexpected ':' in nested name specifier; did you mean '::'?}} 54 for (int i = 0; i < 10; ++i) ; 55 56 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} 57 #pragma omp target 58 #pragma omp teams 59 #pragma omp distribute simd linear(B:B::bfoo()) 60 for (int i = 0; i < 10; ++i) ; 61 62 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} 63 #pragma omp target 64 #pragma omp teams 65 #pragma omp distribute simd linear(X::x : ::z) 66 for (int i = 0; i < 10; ++i) ; 67 68 // expected-error@+3 3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} 69 #pragma omp target 70 #pragma omp teams 71 #pragma omp distribute simd linear(B,::z, X::x) 72 for (int i = 0; i < 10; ++i) ; 73 74 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} 75 #pragma omp target 76 #pragma omp teams 77 #pragma omp distribute simd linear(::z) 78 for (int i = 0; i < 10; ++i) ; 79 80 #pragma omp target 81 #pragma omp teams 82 #pragma omp distribute simd linear(B::bfoo()) // expected-error {{expected variable name}} 83 for (int i = 0; i < 10; ++i) ; 84 85 // expected-error@+3 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} 86 #pragma omp target 87 #pragma omp teams 88 #pragma omp distribute simd linear(B::ib,B:C1+C2) 89 for (int i = 0; i < 10; ++i) ; 90 } 91 92 template<int L, class T, class N> T test_template(T* arr, N num) { 93 N i; 94 T sum = (T)0; 95 T ind2 = - num * L; // expected-note {{'ind2' defined here}} 96 97 #pragma omp target 98 #pragma omp teams 99 #pragma omp distribute simd linear(ind2:L) // expected-error {{argument of a linear clause should be of integral or pointer type}} 100 for (i = 0; i < num; ++i) { 101 T cur = arr[(int)ind2]; 102 ind2 += L; 103 sum += cur; 104 } 105 return T(); 106 } 107 108 template<int LEN> int test_warn() { 109 int ind2 = 0; 110 #pragma omp target 111 #pragma omp teams 112 #pragma omp parallel for simd linear(ind2:LEN) // expected-warning {{zero linear step (ind2 should probably be const)}} 113 for (int i = 0; i < 100; i++) { 114 ind2 += LEN; 115 } 116 return ind2; 117 } 118 119 struct S1; // expected-note 2 {{declared here}} expected-note 3 {{forward declaration of 'S1'}} 120 extern S1 a; 121 class S2 { 122 mutable int a; 123 public: 124 S2():a(0) { } 125 }; 126 const S2 b; // expected-note 2 {{'b' defined here}} 127 const S2 ba[5]; 128 class S3 { 129 int a; 130 public: 131 S3():a(0) { } 132 }; 133 const S3 ca[5]; 134 class S4 { 135 int a; 136 S4(); 137 public: 138 S4(int v):a(v) { } 139 }; 140 class S5 { 141 int a; 142 S5():a(0) {} 143 public: 144 S5(int v):a(v) { } 145 }; 146 147 S3 h; 148 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} 149 150 template<class I, class C> int foomain(I argc, C **argv) { 151 I e(4); 152 I g(5); 153 int i; 154 int &j = i; 155 156 #pragma omp target 157 #pragma omp teams 158 #pragma omp distribute simd linear // expected-error {{expected '(' after 'linear'}} 159 for (int k = 0; k < argc; ++k) ++k; 160 161 #pragma omp target 162 #pragma omp teams 163 #pragma omp distribute simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 164 for (int k = 0; k < argc; ++k) ++k; 165 166 #pragma omp target 167 #pragma omp teams 168 #pragma omp distribute simd linear () // expected-error {{expected expression}} 169 for (int k = 0; k < argc; ++k) ++k; 170 171 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} 172 #pragma omp target 173 #pragma omp teams 174 #pragma omp distribute simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 175 for (int k = 0; k < argc; ++k) ++k; 176 177 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} 178 #pragma omp target 179 #pragma omp teams 180 #pragma omp distribute simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 181 for (int k = 0; k < argc; ++k) ++k; 182 183 #pragma omp target 184 #pragma omp teams 185 #pragma omp distribute simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 186 for (int k = 0; k < argc; ++k) ++k; 187 188 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} 189 #pragma omp target 190 #pragma omp teams 191 #pragma omp distribute simd linear (argc : 5) 192 for (int k = 0; k < argc; ++k) ++k; 193 194 #pragma omp target 195 #pragma omp teams 196 #pragma omp distribute simd linear (S1) // expected-error {{'S1' does not refer to a value}} 197 for (int k = 0; k < argc; ++k) ++k; 198 199 #pragma omp target 200 #pragma omp teams 201 #pragma omp distribute simd linear (a, b:B::ib) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}} 202 for (int k = 0; k < argc; ++k) ++k; 203 204 #pragma omp target 205 #pragma omp teams 206 #pragma omp distribute simd linear (argv[1]) // expected-error {{expected variable name}} 207 for (int k = 0; k < argc; ++k) ++k; 208 209 // expected-error@+3 2 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} 210 #pragma omp target 211 #pragma omp teams 212 #pragma omp distribute simd linear(e, g) 213 for (int k = 0; k < argc; ++k) ++k; 214 215 #pragma omp target 216 #pragma omp teams 217 #pragma omp distribute simd linear(h) // expected-error {{threadprivate or thread local variable cannot be linear}} 218 for (int k = 0; k < argc; ++k) ++k; 219 220 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} 221 #pragma omp target 222 #pragma omp teams 223 #pragma omp distribute simd linear(i) 224 for (int k = 0; k < argc; ++k) ++k; 225 226 return 0; 227 } 228 229 namespace A { 230 double x; 231 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} 232 } 233 namespace C { 234 using A::x; 235 } 236 237 int main(int argc, char **argv) { 238 double darr[100]; 239 // expected-note@+1 {{in instantiation of function template specialization 'test_template<-4, double, int>' requested here}} 240 test_template<-4>(darr, 4); 241 // expected-note@+1 {{in instantiation of function template specialization 'test_warn<0>' requested here}} 242 test_warn<0>(); 243 244 S4 e(4); // expected-note {{'e' defined here}} 245 S5 g(5); // expected-note {{'g' defined here}} 246 int i; 247 int &j = i; 248 249 #pragma omp target 250 #pragma omp teams 251 #pragma omp distribute simd linear // expected-error {{expected '(' after 'linear'}} 252 for (int k = 0; k < argc; ++k) ++k; 253 254 #pragma omp target 255 #pragma omp teams 256 #pragma omp distribute simd linear ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 257 for (int k = 0; k < argc; ++k) ++k; 258 259 #pragma omp target 260 #pragma omp teams 261 #pragma omp distribute simd linear () // expected-error {{expected expression}} 262 for (int k = 0; k < argc; ++k) ++k; 263 264 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} 265 #pragma omp target 266 #pragma omp teams 267 #pragma omp distribute simd linear (argc // expected-error {{expected ')'}} expected-note {{to match this '('}} 268 for (int k = 0; k < argc; ++k) ++k; 269 270 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} 271 #pragma omp target 272 #pragma omp teams 273 #pragma omp distribute simd linear (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 274 for (int k = 0; k < argc; ++k) ++k; 275 276 #pragma omp target 277 #pragma omp teams 278 #pragma omp distribute simd linear (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} 279 for (int k = 0; k < argc; ++k) ++k; 280 281 // expected-error@+3 {{only loop iteration variables are allowed in 'linear' clause in distribute directives}} 282 #pragma omp target 283 #pragma omp teams 284 #pragma omp distribute simd linear (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 '('}} 285 for (int k = 0; k < argc; ++k) ++k; 286 287 #pragma omp target 288 #pragma omp teams 289 #pragma omp distribute simd linear (S1) // expected-error {{'S1' does not refer to a value}} 290 for (int k = 0; k < argc; ++k) ++k; 291 292 293 #pragma omp target 294 #pragma omp teams 295 #pragma omp distribute simd linear (a, b) // expected-error {{linear variable with incomplete type 'S1'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S2'}} expected-error {{incomplete type 'S1' where a complete type is required}} 296 for (int k = 0; k < argc; ++k) ++k; 297 298 #pragma omp target 299 #pragma omp teams 300 #pragma omp distribute simd linear (argv[1]) // expected-error {{expected variable name}} 301 for (int k = 0; k < argc; ++k) ++k; 302 303 #pragma omp target 304 #pragma omp teams 305 #pragma omp distribute simd linear(e, g) // expected-error {{argument of a linear clause should be of integral or pointer type, not 'S4'}} expected-error {{argument of a linear clause should be of integral or pointer type, not 'S5'}} 306 for (int k = 0; k < argc; ++k) ++k; 307 308 #pragma omp target 309 #pragma omp teams 310 #pragma omp distribute simd linear(h, C::x) // expected-error 2 {{threadprivate or thread local variable cannot be linear}} 311 for (int k = 0; k < argc; ++k) ++k; 312 313 #pragma omp parallel 314 { 315 int k; 316 #pragma omp target 317 #pragma omp teams 318 #pragma omp distribute simd linear(k) 319 for (k = 0; k < argc; ++k) ++k; 320 321 #pragma omp target 322 #pragma omp teams 323 #pragma omp distribute simd linear(k : 4) 324 for (k = 0; k < argc; k+=4) { } 325 } 326 327 foomain<int,char>(argc,argv); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}} 328 return 0; 329 } 330 331