1 // RUN: %clang_cc1 -verify -fopenmp %s -Wno-openmp-mapping -Wuninitialized 2 3 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wno-openmp-mapping -Wuninitialized 4 5 void foo() { 6 } 7 8 bool foobool(int argc) { 9 return argc; 10 } 11 12 void xxx(int argc) { 13 int map; // expected-note {{initialize the variable 'map' to silence this warning}} 14 #pragma omp target parallel for simd map(map) // expected-warning {{variable 'map' is uninitialized when used here}} 15 for (int i = 0; i < 10; ++i) 16 ; 17 } 18 19 struct S1; // expected-note 2 {{declared here}} 20 extern S1 a; 21 class S2 { 22 mutable int a; 23 public: 24 S2():a(0) { } 25 S2(S2 &s2):a(s2.a) { } 26 static float S2s; 27 static const float S2sc; 28 }; 29 const float S2::S2sc = 0; 30 const S2 b; 31 const S2 ba[5]; 32 class S3 { 33 int a; 34 public: 35 S3():a(0) { } 36 S3(S3 &s3):a(s3.a) { } 37 }; 38 const S3 c; 39 const S3 ca[5]; 40 extern const int f; 41 class S4 { 42 int a; 43 S4(); 44 S4(const S4 &s4); 45 public: 46 S4(int v):a(v) { } 47 }; 48 class S5 { 49 int a; 50 S5():a(0) {} 51 S5(const S5 &s5):a(s5.a) { } 52 public: 53 S5(int v):a(v) { } 54 }; 55 56 S3 h; 57 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} 58 59 typedef int from; 60 61 template <typename T, int I> // expected-note {{declared here}} 62 T tmain(T argc) { 63 const T d = 5; 64 const T da[5] = { 0 }; 65 S4 e(4); 66 S5 g(5); 67 T i, t[20]; 68 T &j = i; 69 T *k = &j; 70 T x; 71 T y ,z; 72 T to, tofrom, always; 73 const T (&l)[5] = da; 74 75 76 #pragma omp target parallel for simd map // expected-error {{expected '(' after 'map'}} 77 for (i = 0; i < argc; ++i) foo(); 78 #pragma omp target parallel for simd map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} 79 for (i = 0; i < argc; ++i) foo(); 80 #pragma omp target parallel for simd map() // expected-error {{expected expression}} 81 for (i = 0; i < argc; ++i) foo(); 82 #pragma omp target parallel for simd map(alloc) // expected-error {{use of undeclared identifier 'alloc'}} 83 for (i = 0; i < argc; ++i) foo(); 84 #pragma omp target parallel for simd map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}} 85 for (i = 0; i < argc; ++i) foo(); 86 #pragma omp target parallel for simd map(to:) // expected-error {{expected expression}} 87 for (i = 0; i < argc; ++i) foo(); 88 #pragma omp target parallel for simd map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 89 for (i = 0; i < argc; ++i) foo(); 90 #pragma omp target parallel for simd map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} 91 for (i = 0; i < argc; ++i) foo(); 92 #pragma omp target parallel for simd map(l[-1:]) // expected-error 2 {{array section must be a subset of the original array}} 93 for (i = 0; i < argc; ++i) foo(); 94 #pragma omp target parallel for simd map(l[:-1]) // expected-error 2 {{section length is evaluated to a negative value -1}} 95 for (i = 0; i < argc; ++i) foo(); 96 #pragma omp target parallel for simd map(l[true:true]) 97 for (i = 0; i < argc; ++i) foo(); 98 #pragma omp target parallel for simd map(x) 99 for (i = 0; i < argc; ++i) foo(); 100 #pragma omp target parallel for simd map(tofrom: t[:I]) 101 for (i = 0; i < argc; ++i) foo(); 102 #pragma omp target parallel for simd map(T: a) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} expected-error {{incomplete type 'S1' where a complete type is required}} 103 for (i = 0; i < argc; ++i) foo(); 104 #pragma omp target parallel for simd map(T) // expected-error {{'T' does not refer to a value}} 105 for (i = 0; i < argc; ++i) foo(); 106 #pragma omp target parallel for simd map(I) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}} 107 for (i = 0; i < argc; ++i) foo(); 108 #pragma omp target parallel for simd map(S2::S2s) 109 for (i = 0; i < argc; ++i) foo(); 110 #pragma omp target parallel for simd map(S2::S2sc) 111 for (i = 0; i < argc; ++i) foo(); 112 #pragma omp target parallel for simd map(x, z) 113 for (i = 0; i < argc; ++i) foo(); 114 #pragma omp target parallel for simd map(to: x) 115 for (i = 0; i < argc; ++i) foo(); 116 #pragma omp target parallel for simd map(to: to) 117 for (i = 0; i < argc; ++i) foo(); 118 #pragma omp target parallel for simd map(to) 119 for (i = 0; i < argc; ++i) foo(); 120 #pragma omp target parallel for simd map(to, x) 121 for (i = 0; i < argc; ++i) foo(); 122 #pragma omp target parallel for simd map(to x) // expected-error {{expected ',' or ')' in 'map' clause}} 123 for (i = 0; i < argc; ++i) foo(); 124 #pragma omp target parallel for simd map(tofrom: argc > 0 ? x : y) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}} 125 for (i = 0; i < argc; ++i) foo(); 126 #pragma omp target parallel for simd map(argc) 127 for (i = 0; i < argc; ++i) foo(); 128 #pragma omp target parallel for simd map(S1) // expected-error {{'S1' does not refer to a value}} 129 for (i = 0; i < argc; ++i) foo(); 130 #pragma omp target parallel for simd map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} 131 for (i = 0; i < argc; ++i) foo(); 132 #pragma omp target parallel for simd map(ba) 133 for (i = 0; i < argc; ++i) foo(); 134 #pragma omp target parallel for simd map(ca) 135 for (i = 0; i < argc; ++i) foo(); 136 #pragma omp target parallel for simd map(da) 137 for (i = 0; i < argc; ++i) foo(); 138 #pragma omp target parallel for simd map(S2::S2s) 139 for (i = 0; i < argc; ++i) foo(); 140 #pragma omp target parallel for simd map(S2::S2sc) 141 for (i = 0; i < argc; ++i) foo(); 142 #pragma omp target parallel for simd map(e, g) 143 for (i = 0; i < argc; ++i) foo(); 144 #pragma omp target parallel for simd map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}} 145 for (i = 0; i < argc; ++i) foo(); 146 #pragma omp target parallel for simd map(k), map(k) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}} 147 for (i = 0; i < argc; ++i) foo(); 148 #pragma omp target parallel for simd map(k), map(k[:5]) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}} expected-note 2 {{used here}} 149 for (i = 0; i < argc; ++i) foo(); 150 #pragma omp target parallel for simd map(da) 151 for (i = 0; i < argc; ++i) foo(); 152 #pragma omp target parallel for simd map(da[:4]) 153 for (i = 0; i < argc; ++i) foo(); 154 #pragma omp target data map(k, j, l) // expected-note 2 {{used here}} 155 #pragma omp target parallel for simd map(k[:4]) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}} 156 for (i = 0; i < argc; ++i) foo(); 157 #pragma omp target parallel for simd map(j) 158 for (i = 0; i < argc; ++i) foo(); 159 #pragma omp target parallel for simd map(l) map(l[:5]) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}} 160 for (i = 0; i < argc; ++i) foo(); 161 #pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}} 162 { 163 #pragma omp target parallel for simd map(k) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}} 164 for (i = 0; i < argc; ++i) foo(); 165 #pragma omp target parallel for simd map(j) 166 for (i = 0; i < argc; ++i) foo(); 167 #pragma omp target parallel for simd map(l) 168 for (i = 0; i < argc; ++i) foo(); 169 } 170 171 #pragma omp target parallel for simd map(always, tofrom: x) 172 for (i = 0; i < argc; ++i) foo(); 173 #pragma omp target parallel for simd map(always: x) // expected-error {{missing map type}} 174 for (i = 0; i < argc; ++i) foo(); 175 #pragma omp target parallel for simd map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', or 'mapper'}} expected-error {{missing map type}} 176 for (i = 0; i < argc; ++i) foo(); 177 #pragma omp target parallel for simd map(always, tofrom: always, tofrom, x) 178 for (i = 0; i < argc; ++i) foo(); 179 #pragma omp target parallel for simd map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}} 180 for (i = 0; i < argc; ++i) foo(); 181 182 return 0; 183 } 184 185 int main(int argc, char **argv) { 186 const int d = 5; 187 const int da[5] = { 0 }; 188 S4 e(4); 189 S5 g(5); 190 int i; 191 int &j = i; 192 int *k = &j; 193 int x; 194 int y, z; 195 int to, tofrom, always; 196 const int (&l)[5] = da; 197 198 #pragma omp target parallel for simd map // expected-error {{expected '(' after 'map'}} 199 for (i = 0; i < argc; ++i) foo(); 200 #pragma omp target parallel for simd map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} 201 for (i = 0; i < argc; ++i) foo(); 202 #pragma omp target parallel for simd map() // expected-error {{expected expression}} 203 for (i = 0; i < argc; ++i) foo(); 204 #pragma omp target parallel for simd map(alloc) // expected-error {{use of undeclared identifier 'alloc'}} 205 for (i = 0; i < argc; ++i) foo(); 206 #pragma omp target parallel for simd map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}} 207 for (i = 0; i < argc; ++i) foo(); 208 #pragma omp target parallel for simd map(to:) // expected-error {{expected expression}} 209 for (i = 0; i < argc; ++i) foo(); 210 #pragma omp target parallel for simd map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 211 for (i = 0; i < argc; ++i) foo(); 212 #pragma omp target parallel for simd map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} 213 for (i = 0; i < argc; ++i) foo(); 214 #pragma omp target parallel map(l[-1:]) // expected-error {{array section must be a subset of the original array}} 215 for (i = 0; i < argc; ++i) foo(); 216 #pragma omp target parallel map(l[:-1]) // expected-error {{section length is evaluated to a negative value -1}} 217 for (i = 0; i < argc; ++i) foo(); 218 #pragma omp target parallel map(l[true:true]) 219 for (i = 0; i < argc; ++i) foo(); 220 #pragma omp target parallel for simd map(x) 221 for (i = 0; i < argc; ++i) foo(); 222 #pragma omp target parallel for simd map(to: x) 223 for (i = 0; i < argc; ++i) foo(); 224 #pragma omp target parallel for simd map(to: to) 225 for (i = 0; i < argc; ++i) foo(); 226 #pragma omp target parallel for simd map(to, z) 227 for (i = 0; i < argc; ++i) foo(); 228 #pragma omp target parallel for simd map(to, x) 229 for (i = 0; i < argc; ++i) foo(); 230 #pragma omp target parallel for simd map(to x) // expected-error {{expected ',' or ')' in 'map' clause}} 231 for (i = 0; i < argc; ++i) foo(); 232 #pragma omp target parallel for simd map(tofrom: argc > 0 ? argv[1] : argv[2]) // expected-error {{expected expression containing only member accesses and/or array sections based on named variables}} 233 for (i = 0; i < argc; ++i) foo(); 234 #pragma omp target parallel for simd map(argc) 235 for (i = 0; i < argc; ++i) foo(); 236 #pragma omp target parallel for simd map(S1) // expected-error {{'S1' does not refer to a value}} 237 for (i = 0; i < argc; ++i) foo(); 238 #pragma omp target parallel for simd map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} 239 for (i = 0; i < argc; ++i) foo(); 240 #pragma omp target parallel for simd map(argv[1]) 241 for (i = 0; i < argc; ++i) foo(); 242 #pragma omp target parallel for simd map(ba) 243 for (i = 0; i < argc; ++i) foo(); 244 #pragma omp target parallel for simd map(ca) 245 for (i = 0; i < argc; ++i) foo(); 246 #pragma omp target parallel for simd map(da) 247 for (i = 0; i < argc; ++i) foo(); 248 #pragma omp target parallel for simd map(S2::S2s) 249 for (i = 0; i < argc; ++i) foo(); 250 #pragma omp target parallel for simd map(S2::S2sc) 251 for (i = 0; i < argc; ++i) foo(); 252 #pragma omp target parallel for simd map(e, g) 253 for (i = 0; i < argc; ++i) foo(); 254 #pragma omp target parallel for simd map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}} 255 for (i = 0; i < argc; ++i) foo(); 256 #pragma omp target parallel for simd map(k), map(k) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}} 257 for (i = 0; i < argc; ++i) foo(); 258 #pragma omp target parallel for simd map(k), map(k[:5]) // expected-error {{pointer cannot be mapped along with a section derived from itself}} expected-note {{used here}} 259 for (i = 0; i < argc; ++i) foo(); 260 #pragma omp target parallel for simd map(da) 261 for (i = 0; i < argc; ++i) foo(); 262 #pragma omp target parallel for simd map(da[:4]) 263 for (i = 0; i < argc; ++i) foo(); 264 #pragma omp target data map(k, j, l) // expected-note {{used here}} 265 #pragma omp target parallel for simd map(k[:4]) // expected-error {{pointer cannot be mapped along with a section derived from itself}} 266 for (i = 0; i < argc; ++i) foo(); 267 #pragma omp target parallel for simd map(j) 268 for (i = 0; i < argc; ++i) foo(); 269 #pragma omp target parallel for simd map(l) map(l[:5]) // expected-error 1 {{variable already marked as mapped in current construct}} expected-note 1 {{used here}} 270 for (i = 0; i < argc; ++i) foo(); 271 #pragma omp target data map(k[:4], j, l[:5]) // expected-note {{used here}} 272 { 273 #pragma omp target parallel for simd map(k) // expected-error {{pointer cannot be mapped along with a section derived from itself}} 274 for (i = 0; i < argc; ++i) foo(); 275 #pragma omp target parallel for simd map(j) 276 for (i = 0; i < argc; ++i) foo(); 277 #pragma omp target parallel for simd map(l) 278 for (i = 0; i < argc; ++i) foo(); 279 } 280 281 #pragma omp target parallel for simd map(always, tofrom: x) 282 for (i = 0; i < argc; ++i) foo(); 283 #pragma omp target parallel for simd map(always: x) // expected-error {{missing map type}} 284 for (i = 0; i < argc; ++i) foo(); 285 #pragma omp target parallel for simd map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', or 'mapper'}} expected-error {{missing map type}} 286 for (i = 0; i < argc; ++i) foo(); 287 #pragma omp target parallel for simd map(always, tofrom: always, tofrom, x) 288 for (i = 0; i < argc; ++i) foo(); 289 #pragma omp target parallel for simd map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}} 290 for (i = 0; i < argc; ++i) foo(); 291 #pragma omp target parallel for simd map(delete: j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target parallel for simd'}} 292 for (i = 0; i < argc; ++i) 293 foo(); 294 #pragma omp target parallel for simd map(release: j) // expected-error {{map type 'release' is not allowed for '#pragma omp target parallel for simd'}} 295 for (i = 0; i < argc; ++i) 296 foo(); 297 298 return tmain<int, 3>(argc)+tmain<from, 4>(argc); // expected-note {{in instantiation of function template specialization 'tmain<int, 3>' requested here}} expected-note {{in instantiation of function template specialization 'tmain<int, 4>' requested here}} 299 } 300 301