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 simd map(to: 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; 72 T to, tofrom, always; 73 const T (&l)[5] = da; 74 75 76 #pragma omp target simd map // expected-error {{expected '(' after 'map'}} 77 for (i = 0; i < argc; ++i) foo(); 78 #pragma omp target 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 simd map() // expected-error {{expected expression}} 81 for (i = 0; i < argc; ++i) foo(); 82 #pragma omp target simd map(alloc) // expected-error {{use of undeclared identifier 'alloc'}} 83 for (i = 0; i < argc; ++i) foo(); 84 #pragma omp target 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 simd map(to:) // expected-error {{expected expression}} 87 for (i = 0; i < argc; ++i) foo(); 88 #pragma omp target 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 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 simd map(x) 93 for (i = 0; i < argc; ++i) foo(); 94 #pragma omp target simd map(tofrom: t[:I]) 95 for (i = 0; i < argc; ++i) foo(); 96 #pragma omp target 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}} 97 for (i = 0; i < argc; ++i) foo(); 98 #pragma omp target simd map(T) // expected-error {{'T' does not refer to a value}} 99 for (i = 0; i < argc; ++i) foo(); 100 #pragma omp target simd map(I) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}} 101 for (i = 0; i < argc; ++i) foo(); 102 #pragma omp target simd map(S2::S2s) 103 for (i = 0; i < argc; ++i) foo(); 104 #pragma omp target simd map(S2::S2sc) 105 for (i = 0; i < argc; ++i) foo(); 106 #pragma omp target simd map(x) 107 for (i = 0; i < argc; ++i) foo(); 108 #pragma omp target simd map(to: x) 109 for (i = 0; i < argc; ++i) foo(); 110 #pragma omp target simd map(to: to) 111 for (i = 0; i < argc; ++i) foo(); 112 #pragma omp target simd map(to) 113 for (i = 0; i < argc; ++i) foo(); 114 #pragma omp target simd map(to, x) 115 for (i = 0; i < argc; ++i) foo(); 116 #pragma omp target simd map(to x) // expected-error {{expected ',' or ')' in 'map' clause}} 117 for (i = 0; i < argc; ++i) foo(); 118 #pragma omp target simd map(tofrom: argc > 0 ? x : y) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}} 119 for (i = 0; i < argc; ++i) foo(); 120 #pragma omp target simd map(argc) 121 for (i = 0; i < argc; ++i) foo(); 122 #pragma omp target simd map(S1) // expected-error {{'S1' does not refer to a value}} 123 for (i = 0; i < argc; ++i) foo(); 124 #pragma omp target simd map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} 125 for (i = 0; i < argc; ++i) foo(); 126 #pragma omp target simd map(ba) 127 for (i = 0; i < argc; ++i) foo(); 128 #pragma omp target simd map(ca) 129 for (i = 0; i < argc; ++i) foo(); 130 #pragma omp target simd map(da) 131 for (i = 0; i < argc; ++i) foo(); 132 #pragma omp target simd map(S2::S2s) 133 for (i = 0; i < argc; ++i) foo(); 134 #pragma omp target simd map(S2::S2sc) 135 for (i = 0; i < argc; ++i) foo(); 136 #pragma omp target simd map(e, g) 137 for (i = 0; i < argc; ++i) foo(); 138 #pragma omp target simd map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}} 139 for (i = 0; i < argc; ++i) foo(); 140 #pragma omp target simd map(k), map(k) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}} 141 for (i = 0; i < argc; ++i) foo(); 142 #pragma omp target 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}} 143 for (i = 0; i < argc; ++i) foo(); 144 #pragma omp target simd map(da) 145 for (i = 0; i < argc; ++i) foo(); 146 #pragma omp target simd map(da[:4]) 147 for (i = 0; i < argc; ++i) foo(); 148 #pragma omp target data map(k, j, l) // expected-note 2 {{used here}} 149 #pragma omp target simd map(k[:4]) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}} 150 for (i = 0; i < argc; ++i) foo(); 151 #pragma omp target simd map(j) 152 for (i = 0; i < argc; ++i) foo(); 153 #pragma omp target simd map(l) map(l[:5]) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}} 154 for (i = 0; i < argc; ++i) foo(); 155 #pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}} 156 { 157 #pragma omp target simd map(k) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}} 158 for (i = 0; i < argc; ++i) foo(); 159 #pragma omp target simd map(j) 160 for (i = 0; i < argc; ++i) foo(); 161 #pragma omp target simd map(l) // OK 162 for (i = 0; i < argc; ++i) foo(); 163 } 164 165 #pragma omp target simd map(always, tofrom: x) 166 for (i = 0; i < argc; ++i) foo(); 167 #pragma omp target simd map(always: x) // expected-error {{missing map type}} 168 for (i = 0; i < argc; ++i) foo(); 169 #pragma omp target simd map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', or 'mapper'}} expected-error {{missing map type}} 170 for (i = 0; i < argc; ++i) foo(); 171 #pragma omp target simd map(always, tofrom: always, tofrom, x) 172 for (i = 0; i < argc; ++i) foo(); 173 #pragma omp target simd map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}} 174 for (i = 0; i < argc; ++i) foo(); 175 176 return 0; 177 } 178 179 int main(int argc, char **argv) { 180 const int d = 5; 181 const int da[5] = { 0 }; 182 S4 e(4); 183 S5 g(5); 184 int i; 185 int &j = i; 186 int *k = &j; 187 int x; 188 int y; 189 int to, tofrom, always; 190 const int (&l)[5] = da; 191 192 #pragma omp target simd map // expected-error {{expected '(' after 'map'}} 193 for (i = 0; i < argc; ++i) foo(); 194 #pragma omp target simd map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} 195 for (i = 0; i < argc; ++i) foo(); 196 #pragma omp target simd map() // expected-error {{expected expression}} 197 for (i = 0; i < argc; ++i) foo(); 198 #pragma omp target simd map(alloc) // expected-error {{use of undeclared identifier 'alloc'}} 199 for (i = 0; i < argc; ++i) foo(); 200 #pragma omp target simd map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}} 201 for (i = 0; i < argc; ++i) foo(); 202 #pragma omp target simd map(to:) // expected-error {{expected expression}} 203 for (i = 0; i < argc; ++i) foo(); 204 #pragma omp target simd map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} 205 for (i = 0; i < argc; ++i) foo(); 206 #pragma omp target simd map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}} 207 for (i = 0; i < argc; ++i) foo(); 208 #pragma omp target simd map(x) 209 for (i = 0; i < argc; ++i) foo(); 210 #pragma omp target simd map(to: x) 211 for (i = 0; i < argc; ++i) foo(); 212 #pragma omp target simd map(to: to) 213 for (i = 0; i < argc; ++i) foo(); 214 #pragma omp target simd map(to) 215 for (i = 0; i < argc; ++i) foo(); 216 #pragma omp target simd map(to, x) 217 for (i = 0; i < argc; ++i) foo(); 218 #pragma omp target simd map(to x) // expected-error {{expected ',' or ')' in 'map' clause}} 219 for (i = 0; i < argc; ++i) foo(); 220 #pragma omp target 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}} 221 for (i = 0; i < argc; ++i) foo(); 222 #pragma omp target simd map(argc) 223 for (i = 0; i < argc; ++i) foo(); 224 #pragma omp target simd map(S1) // expected-error {{'S1' does not refer to a value}} 225 for (i = 0; i < argc; ++i) foo(); 226 #pragma omp target simd map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} 227 for (i = 0; i < argc; ++i) foo(); 228 #pragma omp target simd map(argv[1]) 229 for (i = 0; i < argc; ++i) foo(); 230 #pragma omp target simd map(ba) 231 for (i = 0; i < argc; ++i) foo(); 232 #pragma omp target simd map(ca) 233 for (i = 0; i < argc; ++i) foo(); 234 #pragma omp target simd map(da) 235 for (i = 0; i < argc; ++i) foo(); 236 #pragma omp target simd map(S2::S2s) 237 for (i = 0; i < argc; ++i) foo(); 238 #pragma omp target simd map(S2::S2sc) 239 for (i = 0; i < argc; ++i) foo(); 240 #pragma omp target simd map(e, g) 241 for (i = 0; i < argc; ++i) foo(); 242 #pragma omp target simd map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}} 243 for (i = 0; i < argc; ++i) foo(); 244 #pragma omp target simd map(k), map(k) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}} 245 for (i = 0; i < argc; ++i) foo(); 246 #pragma omp target simd map(k), map(k[:5]) // expected-error {{pointer cannot be mapped along with a section derived from itself}} expected-note {{used here}} 247 for (i = 0; i < argc; ++i) foo(); 248 #pragma omp target simd map(da) 249 for (i = 0; i < argc; ++i) foo(); 250 #pragma omp target simd map(da[:4]) 251 for (i = 0; i < argc; ++i) foo(); 252 #pragma omp target data map(k, j, l) // expected-note {{used here}} 253 #pragma omp target simd map(k[:4]) // expected-error {{pointer cannot be mapped along with a section derived from itself}} 254 for (i = 0; i < argc; ++i) foo(); 255 #pragma omp target simd map(j) 256 for (i = 0; i < argc; ++i) foo(); 257 #pragma omp target simd map(l) map(l[:5]) // expected-error 1 {{variable already marked as mapped in current construct}} expected-note 1 {{used here}} 258 for (i = 0; i < argc; ++i) foo(); 259 #pragma omp target data map(k[:4], j, l[:5]) // expected-note 1 {{used here}} 260 { 261 #pragma omp target simd map(k) // expected-error {{pointer cannot be mapped along with a section derived from itself}} 262 for (i = 0; i < argc; ++i) foo(); 263 #pragma omp target simd map(j) 264 for (i = 0; i < argc; ++i) foo(); 265 #pragma omp target simd map(l) // 266 for (i = 0; i < argc; ++i) foo(); 267 } 268 269 #pragma omp target simd map(always, tofrom: x) 270 for (i = 0; i < argc; ++i) foo(); 271 #pragma omp target simd map(always: x) // expected-error {{missing map type}} 272 for (i = 0; i < argc; ++i) foo(); 273 #pragma omp target simd map(tofrom, always: x) // expected-error {{incorrect map type modifier, expected 'always', 'close', or 'mapper'}} expected-error {{missing map type}} 274 for (i = 0; i < argc; ++i) foo(); 275 #pragma omp target simd map(always, tofrom: always, tofrom, x) 276 for (i = 0; i < argc; ++i) foo(); 277 #pragma omp target simd map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}} 278 for (i = 0; i < argc; ++i) foo(); 279 #pragma omp target simd map(delete: j) // expected-error {{map type 'delete' is not allowed for '#pragma omp target simd'}} 280 for (i = 0; i < argc; ++i) 281 foo(); 282 #pragma omp target simd map(release: j) // expected-error {{map type 'release' is not allowed for '#pragma omp target simd'}} 283 for (i = 0; i < argc; ++i) 284 foo(); 285 286 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}} 287 } 288 289