blob: 9d1be5ccaedf61cd4e0c0688fad779ffb4fc90fe [file] [log] [blame]
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00001// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s
2
3void foo() {
4}
5
6bool foobool(int argc) {
7 return argc;
8}
9
10struct S1; // expected-note 2 {{declared here}}
11extern S1 a;
12class S2 {
13 mutable int a;
14public:
15 S2():a(0) { }
16 S2(S2 &s2):a(s2.a) { }
17 static float S2s; // expected-note 4 {{mappable type cannot contain static members}}
18 static const float S2sc; // expected-note 4 {{mappable type cannot contain static members}}
19};
20const float S2::S2sc = 0;
21const S2 b;
22const S2 ba[5];
23class S3 {
24 int a;
25public:
26 S3():a(0) { }
27 S3(S3 &s3):a(s3.a) { }
28};
29const S3 c;
30const S3 ca[5];
31extern const int f;
32class S4 {
33 int a;
34 S4();
35 S4(const S4 &s4);
36public:
37 S4(int v):a(v) { }
38};
39class S5 {
40 int a;
41 S5():a(0) {}
42 S5(const S5 &s5):a(s5.a) { }
43public:
44 S5(int v):a(v) { }
45};
46
47S3 h;
48#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
49
50typedef int from;
51
52template <typename T, int I> // expected-note {{declared here}}
53T tmain(T argc) {
54 const T d = 5;
55 const T da[5] = { 0 };
56 S4 e(4);
57 S5 g(5);
58 T i, t[20];
59 T &j = i;
60 T *k = &j;
61 T x;
62 T y;
63 T to, tofrom, always;
64 const T (&l)[5] = da;
65
66
67#pragma omp target parallel map // expected-error {{expected '(' after 'map'}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000068 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000069#pragma omp target parallel map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000070 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000071#pragma omp target parallel map() // expected-error {{expected expression}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000072 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000073#pragma omp target parallel map(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000074 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000075#pragma omp target parallel map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000076 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000077#pragma omp target parallel map(to:) // expected-error {{expected expression}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000078 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000079#pragma omp target parallel map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000080 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000081#pragma omp target parallel map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000082 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000083#pragma omp target parallel map(x)
84 foo();
85#pragma omp target parallel map(tofrom: t[:I])
86 foo();
87#pragma omp target parallel 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}}
88 foo();
89#pragma omp target parallel map(T) // expected-error {{'T' does not refer to a value}}
90 foo();
91#pragma omp target parallel map(I) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
92 foo();
93#pragma omp target parallel map(S2::S2s)
94 foo();
95#pragma omp target parallel map(S2::S2sc)
96 foo();
97#pragma omp target parallel map(x)
98 foo();
99#pragma omp target parallel map(to: x)
100 foo();
101#pragma omp target parallel map(to: to)
102 foo();
103#pragma omp target parallel map(to)
104 foo();
105#pragma omp target parallel map(to, x)
106 foo();
107#pragma omp target parallel map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000108 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000109#pragma omp target parallel map(tofrom: argc > 0 ? x : y) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000110 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000111#pragma omp target parallel map(argc)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000112 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000113#pragma omp target parallel map(S1) // expected-error {{'S1' does not refer to a value}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000114 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000115#pragma omp target parallel map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} expected-error 2 {{type 'S2' is not mappable to target}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000116 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000117#pragma omp target parallel map(ba) // expected-error 2 {{type 'S2' is not mappable to target}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000118 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000119#pragma omp target parallel map(ca)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000120 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000121#pragma omp target parallel map(da)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000122 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000123#pragma omp target parallel map(S2::S2s)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000124 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000125#pragma omp target parallel map(S2::S2sc)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000126 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000127#pragma omp target parallel map(e, g)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000128 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000129#pragma omp target parallel map(h) // expected-error {{threadprivate variables are not allowed in map clause}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000130 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000131#pragma omp target parallel map(k), map(k) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000132 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000133#pragma omp target parallel map(k), map(k[:5]) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}} expected-note 2 {{used here}}
134 foo();
135#pragma omp target parallel map(da)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000136 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000137#pragma omp target parallel map(da[:4])
138 foo();
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000139#pragma omp target data map(k, j, l) // expected-note 2 {{used here}}
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000140#pragma omp target parallel map(k[:4]) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000141 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000142#pragma omp target parallel map(j)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000143 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000144#pragma omp target parallel map(l) map(l[:5]) // expected-error 2 {{variable already marked as mapped in current construct}} expected-note 2 {{used here}}
145 foo();
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000146#pragma omp target data map(k[:4], j, l[:5]) // expected-note 4 {{used here}}
147{
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000148#pragma omp target parallel map(k) // expected-error 2 {{pointer cannot be mapped along with a section derived from itself}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000149 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000150#pragma omp target parallel map(j)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000151 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000152#pragma omp target parallel map(l) // expected-error 2 {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
153 foo();
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000154}
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000155
156#pragma omp target parallel map(always, tofrom: x)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000157 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000158#pragma omp target parallel map(always: x) // expected-error {{missing map type}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000159 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000160#pragma omp target parallel 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'}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000161 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000162#pragma omp target parallel map(always, tofrom: always, tofrom, x)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000163 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000164#pragma omp target parallel map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
165 foo();
166
167 return 0;
168}
169
170int main(int argc, char **argv) {
171 const int d = 5;
172 const int da[5] = { 0 };
173 S4 e(4);
174 S5 g(5);
175 int i;
176 int &j = i;
177 int *k = &j;
178 int x;
179 int y;
180 int to, tofrom, always;
181 const int (&l)[5] = da;
182#pragma omp target parallel map // expected-error {{expected '(' after 'map'}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000183 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000184#pragma omp target parallel map( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000185 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000186#pragma omp target parallel map() // expected-error {{expected expression}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000187 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000188#pragma omp target parallel map(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000189 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000190#pragma omp target parallel map(to argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000191 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000192#pragma omp target parallel map(to:) // expected-error {{expected expression}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000193 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000194#pragma omp target parallel map(from: argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000195 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000196#pragma omp target parallel map(x: y) // expected-error {{incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000197 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000198#pragma omp target parallel map(x)
199 foo();
200#pragma omp target parallel map(to: x)
201 foo();
202#pragma omp target parallel map(to: to)
203 foo();
204#pragma omp target parallel map(to)
205 foo();
206#pragma omp target parallel map(to, x)
207 foo();
208#pragma omp target parallel map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000209 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000210#pragma omp target parallel map(tofrom: argc > 0 ? argv[1] : argv[2]) // expected-error {{expected expression containing only member accesses and/or array sections based on named variables}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000211 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000212#pragma omp target parallel map(argc)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000213 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000214#pragma omp target parallel map(S1) // expected-error {{'S1' does not refer to a value}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000215 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000216#pragma omp target parallel map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}} expected-error 2 {{type 'S2' is not mappable to target}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000217 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000218#pragma omp target parallel map(argv[1])
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000219 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000220#pragma omp target parallel map(ba) // expected-error 2 {{type 'S2' is not mappable to target}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000221 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000222#pragma omp target parallel map(ca)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000223 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000224#pragma omp target parallel map(da)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000225 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000226#pragma omp target parallel map(S2::S2s)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000227 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000228#pragma omp target parallel map(S2::S2sc)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000229 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000230#pragma omp target parallel map(e, g)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000231 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000232#pragma omp target parallel map(h) // expected-error {{threadprivate variables are not allowed in map clause}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000233 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000234#pragma omp target parallel map(k), map(k) // expected-error {{variable already marked as mapped in current construct}} expected-note {{used here}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000235 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000236#pragma omp target parallel map(k), map(k[:5]) // expected-error {{pointer cannot be mapped along with a section derived from itself}} expected-note {{used here}}
237 foo();
238#pragma omp target parallel map(da)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000239 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000240#pragma omp target parallel map(da[:4])
241 foo();
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000242#pragma omp target data map(k, j, l) // expected-note {{used here}}
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000243#pragma omp target parallel map(k[:4]) // expected-error {{pointer cannot be mapped along with a section derived from itself}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000244 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000245#pragma omp target parallel map(j)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000246 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000247#pragma omp target parallel map(l) map(l[:5]) // expected-error 1 {{variable already marked as mapped in current construct}} expected-note 1 {{used here}}
248 foo();
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000249#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
250{
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000251#pragma omp target parallel map(k) // expected-error {{pointer cannot be mapped along with a section derived from itself}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000252 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000253#pragma omp target parallel map(j)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000254 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000255#pragma omp target parallel map(l) // expected-error {{original storage of expression in data environment is shared but data environment do not fully contain mapped expression storage}}
256 foo();
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000257}
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000258
259#pragma omp target parallel map(always, tofrom: x)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000260 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000261#pragma omp target parallel map(always: x) // expected-error {{missing map type}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000262 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000263#pragma omp target parallel 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'}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000264 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000265#pragma omp target parallel map(always, tofrom: always, tofrom, x)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000266 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000267#pragma omp target parallel map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
268 foo();
269
270 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}}
271}
272