blob: 4bb14ea52f03e072b5f0af47e115361e6be1d360 [file] [log] [blame]
Alexey Bataev95c23e72018-02-27 21:31:11 +00001// RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 %s -Wno-openmp-target
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00002
Alexey Bataev95c23e72018-02-27 21:31:11 +00003// RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 %s -Wno-openmp-target
Alexey Bataeva8a9153a2017-12-29 18:07:07 +00004
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +00005void foo() {
6}
7
8bool foobool(int argc) {
9 return argc;
10}
11
12struct S1; // expected-note 2 {{declared here}}
13extern S1 a;
14class S2 {
15 mutable int a;
16public:
17 S2():a(0) { }
18 S2(S2 &s2):a(s2.a) { }
Alexey Bataeved94bd92017-09-13 11:12:35 +000019 static float S2s;
20 static const float S2sc;
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000021};
22const float S2::S2sc = 0;
23const S2 b;
24const S2 ba[5];
25class S3 {
26 int a;
27public:
28 S3():a(0) { }
29 S3(S3 &s3):a(s3.a) { }
30};
31const S3 c;
32const S3 ca[5];
33extern const int f;
34class S4 {
35 int a;
36 S4();
37 S4(const S4 &s4);
38public:
39 S4(int v):a(v) { }
40};
41class S5 {
42 int a;
43 S5():a(0) {}
44 S5(const S5 &s5):a(s5.a) { }
45public:
46 S5(int v):a(v) { }
47};
48
49S3 h;
50#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
51
52typedef int from;
53
54template <typename T, int I> // expected-note {{declared here}}
55T 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 map // expected-error {{expected '(' after 'map'}}
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 ')'}} expected-note {{to match this '('}} 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() // expected-error {{expected expression}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000074 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000075#pragma omp target parallel map(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
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 argc // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected ',' or ')' in 'map' clause}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000078 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000079#pragma omp target parallel map(to:) // expected-error {{expected expression}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +000080 foo();
Alexey Bataevc5970622016-04-01 08:43:42 +000081#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 +000082 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000083#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 +000084 foo();
Kelvin Liad9ecba2016-07-20 20:45:29 +000085#pragma omp target parallel map(l[-1:]) // expected-error 2 {{array section must be a subset of the original array}}
86 foo();
87#pragma omp target parallel map(l[:-1]) // expected-error 2 {{section length is evaluated to a negative value -1}}
88 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +000089#pragma omp target parallel map(x)
90 foo();
91#pragma omp target parallel map(tofrom: t[:I])
92 foo();
93#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}}
94 foo();
95#pragma omp target parallel map(T) // expected-error {{'T' does not refer to a value}}
96 foo();
97#pragma omp target parallel map(I) // expected-error 2 {{expected expression containing only member accesses and/or array sections based on named variables}}
98 foo();
99#pragma omp target parallel map(S2::S2s)
100 foo();
101#pragma omp target parallel map(S2::S2sc)
102 foo();
103#pragma omp target parallel map(x)
104 foo();
105#pragma omp target parallel map(to: x)
106 foo();
107#pragma omp target parallel map(to: to)
108 foo();
109#pragma omp target parallel map(to)
110 foo();
111#pragma omp target parallel map(to, x)
112 foo();
113#pragma omp target parallel map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000114 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000115#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 +0000116 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000117#pragma omp target parallel map(argc)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000118 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000119#pragma omp target parallel map(S1) // expected-error {{'S1' does not refer to a value}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000120 foo();
Alexey Bataeved94bd92017-09-13 11:12:35 +0000121#pragma omp target parallel map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000122 foo();
Alexey Bataeved94bd92017-09-13 11:12:35 +0000123#pragma omp target parallel map(ba)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000124 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000125#pragma omp target parallel map(ca)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000126 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000127#pragma omp target parallel map(da)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000128 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000129#pragma omp target parallel map(S2::S2s)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000130 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000131#pragma omp target parallel map(S2::S2sc)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000132 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000133#pragma omp target parallel map(e, g)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000134 foo();
Samuel Antao661c0902016-05-26 17:39:58 +0000135#pragma omp target parallel map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000136 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000137#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 +0000138 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000139#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}}
140 foo();
141#pragma omp target parallel map(da)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000142 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000143#pragma omp target parallel map(da[:4])
144 foo();
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000145#pragma omp target data map(k, j, l) // expected-note 2 {{used here}}
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000146#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 +0000147 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000148#pragma omp target parallel map(j)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000149 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000150#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}}
151 foo();
Kelvin Li9f645ae2016-07-18 22:49:16 +0000152#pragma omp target data map(k[:4], j, l[:5]) // expected-note 2 {{used here}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000153{
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000154#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 +0000155 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000156#pragma omp target parallel map(j)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000157 foo();
Kelvin Li9f645ae2016-07-18 22:49:16 +0000158#pragma omp target parallel map(l)
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000159 foo();
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000160}
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000161
162#pragma omp target parallel map(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(always: x) // expected-error {{missing map type}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000165 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000166#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 +0000167 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000168#pragma omp target parallel map(always, tofrom: always, tofrom, x)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000169 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000170#pragma omp target parallel map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
171 foo();
172
173 return 0;
174}
175
176int main(int argc, char **argv) {
177 const int d = 5;
178 const int da[5] = { 0 };
179 S4 e(4);
180 S5 g(5);
181 int i;
182 int &j = i;
183 int *k = &j;
184 int x;
185 int y;
186 int to, tofrom, always;
187 const int (&l)[5] = da;
188#pragma omp target parallel map // expected-error {{expected '(' after 'map'}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000189 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000190#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 +0000191 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000192#pragma omp target parallel map() // 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(alloc) // expected-error {{use of undeclared identifier 'alloc'}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000195 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000196#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 +0000197 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000198#pragma omp target parallel map(to:) // expected-error {{expected expression}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000199 foo();
Alexey Bataevc5970622016-04-01 08:43:42 +0000200#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 +0000201 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000202#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 +0000203 foo();
Kelvin Liad9ecba2016-07-20 20:45:29 +0000204#pragma omp target parallel map(l[-1:]) // expected-error {{array section must be a subset of the original array}}
205 foo();
206#pragma omp target parallel map(l[:-1]) // expected-error {{section length is evaluated to a negative value -1}}
207 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000208#pragma omp target parallel map(x)
209 foo();
210#pragma omp target parallel map(to: x)
211 foo();
212#pragma omp target parallel map(to: to)
213 foo();
214#pragma omp target parallel map(to)
215 foo();
216#pragma omp target parallel map(to, x)
217 foo();
218#pragma omp target parallel map(to x) // expected-error {{expected ',' or ')' in 'map' clause}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000219 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000220#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 +0000221 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000222#pragma omp target parallel map(argc)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000223 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000224#pragma omp target parallel map(S1) // expected-error {{'S1' does not refer to a value}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000225 foo();
Alexey Bataeved94bd92017-09-13 11:12:35 +0000226#pragma omp target parallel map(a, b, c, d, f) // expected-error {{incomplete type 'S1' where a complete type is required}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000227 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000228#pragma omp target parallel map(argv[1])
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000229 foo();
Alexey Bataeved94bd92017-09-13 11:12:35 +0000230#pragma omp target parallel map(ba)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000231 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000232#pragma omp target parallel map(ca)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000233 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000234#pragma omp target parallel map(da)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000235 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000236#pragma omp target parallel map(S2::S2s)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000237 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000238#pragma omp target parallel map(S2::S2sc)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000239 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000240#pragma omp target parallel map(e, g)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000241 foo();
Samuel Antao661c0902016-05-26 17:39:58 +0000242#pragma omp target parallel map(h) // expected-error {{threadprivate variables are not allowed in 'map' clause}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000243 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000244#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 +0000245 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000246#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}}
247 foo();
248#pragma omp target parallel map(da)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000249 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000250#pragma omp target parallel map(da[:4])
251 foo();
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000252#pragma omp target data map(k, j, l) // expected-note {{used here}}
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000253#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 +0000254 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000255#pragma omp target parallel map(j)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000256 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000257#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}}
258 foo();
Kelvin Li9f645ae2016-07-18 22:49:16 +0000259#pragma omp target data map(k[:4], j, l[:5]) // expected-note 1 {{used here}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000260{
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000261#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 +0000262 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000263#pragma omp target parallel map(j)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000264 foo();
Kelvin Li9f645ae2016-07-18 22:49:16 +0000265#pragma omp target parallel map(l)
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000266 foo();
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000267}
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000268
269#pragma omp target parallel map(always, tofrom: x)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000270 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000271#pragma omp target parallel map(always: x) // expected-error {{missing map type}}
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000272 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000273#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 +0000274 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000275#pragma omp target parallel map(always, tofrom: always, tofrom, x)
Arpith Chacko Jacob3d58f262016-02-02 04:00:47 +0000276 foo();
Arpith Chacko Jacobe955b3d2016-01-26 18:48:41 +0000277#pragma omp target parallel map(tofrom j) // expected-error {{expected ',' or ')' in 'map' clause}}
278 foo();
279
280 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}}
281}
282