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