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