1 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
4 // expected-no-diagnostics
5
6 #ifndef HEADER
7 #define HEADER
8
9 template <typename T, int C>
tmain(T argc,T * argv)10 T tmain(T argc, T *argv) {
11 T i, j, b, c, d, e, x[20];
12
13 i = argc;
14 #pragma omp target enter data map(to: i)
15
16 #pragma omp target enter data map(to: i) if (target enter data: j > 0)
17
18 #pragma omp target enter data map(to: i) if (b)
19
20 #pragma omp target enter data map(to: c)
21
22 #pragma omp target enter data map(to: c) if(b>e)
23
24 #pragma omp target enter data map(alloc: x[0:10], c)
25
26 #pragma omp target enter data map(to: c) map(alloc: d)
27
28 #pragma omp target enter data map(always,alloc: e)
29
30 #pragma omp target enter data nowait map(to: i)
31
32 #pragma omp target enter data nowait map(to: i) if (target enter data: j > 0)
33
34 #pragma omp target enter data map(to: i) if (b) nowait
35
36 #pragma omp target enter data map(to: c) nowait
37
38 #pragma omp target enter data map(to: c) nowait if(b>e)
39
40 #pragma omp target enter data nowait map(alloc: x[0:10], c)
41
42 #pragma omp target enter data nowait map(to: c) map(alloc: d)
43
44 #pragma omp target enter data nowait map(always,alloc: e)
45
46 #pragma omp target enter data nowait depend(in : argc, argv[i:argc], x[:]) map(to: i)
47
48 #pragma omp target enter data nowait map(to: i) if (target enter data: j > 0) depend(in : argc, argv[i:argc], x[:])
49
50 #pragma omp target enter data depend(in : argc, argv[i:argc], x[:]) map(to: i) if (b) nowait
51
52 #pragma omp target enter data map(to: c) depend(in : argc, argv[i:argc], x[:]) nowait
53
54 #pragma omp target enter data map(to: c) nowait if(b>e) depend(in : argc, argv[i:argc], x[:])
55
56 #pragma omp target enter data nowait map(alloc: x[0:10], c) depend(in : argc, argv[i:argc], x[:])
57
58 #pragma omp target enter data nowait depend(in : argc, argv[i:argc], x[:]) map(to: c) map(alloc: d)
59
60 #pragma omp target enter data nowait map(always,alloc: e) depend(in : argc, argv[i:argc], x[:])
61
62 return 0;
63 }
64
65 // CHECK: template <typename T = int, int C = 5> int tmain(int argc, int *argv) {
66 // CHECK-NEXT: int i, j, b, c, d, e, x[20];
67 // CHECK-NEXT: i = argc;
68 // CHECK-NEXT: #pragma omp target enter data map(to: i)
69 // CHECK-NEXT: #pragma omp target enter data map(to: i) if(target enter data: j > 0)
70 // CHECK-NEXT: #pragma omp target enter data map(to: i) if(b)
71 // CHECK-NEXT: #pragma omp target enter data map(to: c)
72 // CHECK-NEXT: #pragma omp target enter data map(to: c) if(b > e)
73 // CHECK-NEXT: #pragma omp target enter data map(alloc: x[0:10],c)
74 // CHECK-NEXT: #pragma omp target enter data map(to: c) map(alloc: d)
75 // CHECK-NEXT: #pragma omp target enter data map(always,alloc: e)
76 // CHECK-NEXT: #pragma omp target enter data nowait map(to: i)
77 // CHECK-NEXT: #pragma omp target enter data nowait map(to: i) if(target enter data: j > 0)
78 // CHECK-NEXT: #pragma omp target enter data map(to: i) if(b) nowait
79 // CHECK-NEXT: #pragma omp target enter data map(to: c) nowait
80 // CHECK-NEXT: #pragma omp target enter data map(to: c) nowait if(b > e)
81 // CHECK-NEXT: #pragma omp target enter data nowait map(alloc: x[0:10],c)
82 // CHECK-NEXT: #pragma omp target enter data nowait map(to: c) map(alloc: d)
83 // CHECK-NEXT: #pragma omp target enter data nowait map(always,alloc: e)
84 // CHECK-NEXT: #pragma omp target enter data nowait depend(in : argc,argv[i:argc],x[:]) map(to: i)
85 // CHECK-NEXT: #pragma omp target enter data nowait map(to: i) if(target enter data: j > 0) depend(in : argc,argv[i:argc],x[:])
86 // CHECK-NEXT: #pragma omp target enter data depend(in : argc,argv[i:argc],x[:]) map(to: i) if(b) nowait
87 // CHECK-NEXT: #pragma omp target enter data map(to: c) depend(in : argc,argv[i:argc],x[:]) nowait
88 // CHECK-NEXT: #pragma omp target enter data map(to: c) nowait if(b > e) depend(in : argc,argv[i:argc],x[:])
89 // CHECK-NEXT: #pragma omp target enter data nowait map(alloc: x[0:10],c) depend(in : argc,argv[i:argc],x[:])
90 // CHECK-NEXT: #pragma omp target enter data nowait depend(in : argc,argv[i:argc],x[:]) map(to: c) map(alloc: d)
91 // CHECK-NEXT: #pragma omp target enter data nowait map(always,alloc: e) depend(in : argc,argv[i:argc],x[:])
92 // CHECK: template <typename T = char, int C = 1> char tmain(char argc, char *argv) {
93 // CHECK-NEXT: char i, j, b, c, d, e, x[20];
94 // CHECK-NEXT: i = argc;
95 // CHECK-NEXT: #pragma omp target enter data map(to: i)
96 // CHECK-NEXT: #pragma omp target enter data map(to: i) if(target enter data: j > 0)
97 // CHECK-NEXT: #pragma omp target enter data map(to: i) if(b)
98 // CHECK-NEXT: #pragma omp target enter data map(to: c)
99 // CHECK-NEXT: #pragma omp target enter data map(to: c) if(b > e)
100 // CHECK-NEXT: #pragma omp target enter data map(alloc: x[0:10],c)
101 // CHECK-NEXT: #pragma omp target enter data map(to: c) map(alloc: d)
102 // CHECK-NEXT: #pragma omp target enter data map(always,alloc: e)
103 // CHECK-NEXT: #pragma omp target enter data nowait map(to: i)
104 // CHECK-NEXT: #pragma omp target enter data nowait map(to: i) if(target enter data: j > 0)
105 // CHECK-NEXT: #pragma omp target enter data map(to: i) if(b) nowait
106 // CHECK-NEXT: #pragma omp target enter data map(to: c) nowait
107 // CHECK-NEXT: #pragma omp target enter data map(to: c) nowait if(b > e)
108 // CHECK-NEXT: #pragma omp target enter data nowait map(alloc: x[0:10],c)
109 // CHECK-NEXT: #pragma omp target enter data nowait map(to: c) map(alloc: d)
110 // CHECK-NEXT: #pragma omp target enter data nowait map(always,alloc: e)
111 // CHECK-NEXT: #pragma omp target enter data nowait depend(in : argc,argv[i:argc],x[:]) map(to: i)
112 // CHECK-NEXT: #pragma omp target enter data nowait map(to: i) if(target enter data: j > 0) depend(in : argc,argv[i:argc],x[:])
113 // CHECK-NEXT: #pragma omp target enter data depend(in : argc,argv[i:argc],x[:]) map(to: i) if(b) nowait
114 // CHECK-NEXT: #pragma omp target enter data map(to: c) depend(in : argc,argv[i:argc],x[:]) nowait
115 // CHECK-NEXT: #pragma omp target enter data map(to: c) nowait if(b > e) depend(in : argc,argv[i:argc],x[:])
116 // CHECK-NEXT: #pragma omp target enter data nowait map(alloc: x[0:10],c) depend(in : argc,argv[i:argc],x[:])
117 // CHECK-NEXT: #pragma omp target enter data nowait depend(in : argc,argv[i:argc],x[:]) map(to: c) map(alloc: d)
118 // CHECK-NEXT: #pragma omp target enter data nowait map(always,alloc: e) depend(in : argc,argv[i:argc],x[:])
119 // CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
120 // CHECK-NEXT: T i, j, b, c, d, e, x[20];
121 // CHECK-NEXT: i = argc;
122 // CHECK-NEXT: #pragma omp target enter data map(to: i)
123 // CHECK-NEXT: #pragma omp target enter data map(to: i) if(target enter data: j > 0)
124 // CHECK-NEXT: #pragma omp target enter data map(to: i) if(b)
125 // CHECK-NEXT: #pragma omp target enter data map(to: c)
126 // CHECK-NEXT: #pragma omp target enter data map(to: c) if(b > e)
127 // CHECK-NEXT: #pragma omp target enter data map(alloc: x[0:10],c)
128 // CHECK-NEXT: #pragma omp target enter data map(to: c) map(alloc: d)
129 // CHECK-NEXT: #pragma omp target enter data map(always,alloc: e)
130 // CHECK-NEXT: #pragma omp target enter data nowait map(to: i)
131 // CHECK-NEXT: #pragma omp target enter data nowait map(to: i) if(target enter data: j > 0)
132 // CHECK-NEXT: #pragma omp target enter data map(to: i) if(b) nowait
133 // CHECK-NEXT: #pragma omp target enter data map(to: c) nowait
134 // CHECK-NEXT: #pragma omp target enter data map(to: c) nowait if(b > e)
135 // CHECK-NEXT: #pragma omp target enter data nowait map(alloc: x[0:10],c)
136 // CHECK-NEXT: #pragma omp target enter data nowait map(to: c) map(alloc: d)
137 // CHECK-NEXT: #pragma omp target enter data nowait map(always,alloc: e)
138 // CHECK-NEXT: #pragma omp target enter data nowait depend(in : argc,argv[i:argc],x[:]) map(to: i)
139 // CHECK-NEXT: #pragma omp target enter data nowait map(to: i) if(target enter data: j > 0) depend(in : argc,argv[i:argc],x[:])
140 // CHECK-NEXT: #pragma omp target enter data depend(in : argc,argv[i:argc],x[:]) map(to: i) if(b) nowait
141 // CHECK-NEXT: #pragma omp target enter data map(to: c) depend(in : argc,argv[i:argc],x[:]) nowait
142 // CHECK-NEXT: #pragma omp target enter data map(to: c) nowait if(b > e) depend(in : argc,argv[i:argc],x[:])
143 // CHECK-NEXT: #pragma omp target enter data nowait map(alloc: x[0:10],c) depend(in : argc,argv[i:argc],x[:])
144 // CHECK-NEXT: #pragma omp target enter data nowait depend(in : argc,argv[i:argc],x[:]) map(to: c) map(alloc: d)
145 // CHECK-NEXT: #pragma omp target enter data nowait map(always,alloc: e) depend(in : argc,argv[i:argc],x[:])
146
main(int argc,char ** argv)147 int main (int argc, char **argv) {
148 int b = argc, i, c, d, e, f, g, x[20];
149 static int a;
150 // CHECK: static int a;
151
152 #pragma omp target enter data map(to: a)
153 // CHECK: #pragma omp target enter data map(to: a)
154 a=2;
155 // CHECK-NEXT: a = 2;
156 #pragma omp target enter data map(to: a) if (target enter data: b)
157 // CHECK: #pragma omp target enter data map(to: a) if(target enter data: b)
158
159 #pragma omp target enter data map(to: a) if (b > g)
160 // CHECK: #pragma omp target enter data map(to: a) if(b > g)
161
162 #pragma omp target enter data map(to: c)
163 // CHECK-NEXT: #pragma omp target enter data map(to: c)
164
165 #pragma omp target enter data map(alloc: c) if(b>g)
166 // CHECK-NEXT: #pragma omp target enter data map(alloc: c) if(b > g)
167
168 #pragma omp target enter data map(to: x[0:10], c)
169 // CHECK-NEXT: #pragma omp target enter data map(to: x[0:10],c)
170
171 #pragma omp target enter data map(to: c) map(alloc: d)
172 // CHECK-NEXT: #pragma omp target enter data map(to: c) map(alloc: d)
173
174 #pragma omp target enter data map(always,alloc: e)
175 // CHECK-NEXT: #pragma omp target enter data map(always,alloc: e)
176
177 #pragma omp target enter data nowait map(to: a)
178 // CHECK: #pragma omp target enter data nowait map(to: a)
179
180 #pragma omp target enter data nowait map(to: a) if (target enter data: b)
181 // CHECK: #pragma omp target enter data nowait map(to: a) if(target enter data: b)
182
183 #pragma omp target enter data map(to: a) if (b > g) nowait
184 // CHECK: #pragma omp target enter data map(to: a) if(b > g) nowait
185
186 #pragma omp target enter data map(to: c) nowait
187 // CHECK-NEXT: #pragma omp target enter data map(to: c) nowait
188
189 #pragma omp target enter data map(alloc: c) nowait if(b>g)
190 // CHECK-NEXT: #pragma omp target enter data map(alloc: c) nowait if(b > g)
191
192 #pragma omp target enter data nowait map(to: x[0:10], c)
193 // CHECK-NEXT: #pragma omp target enter data nowait map(to: x[0:10],c)
194
195 #pragma omp target enter data nowait map(to: c) map(alloc: d)
196 // CHECK-NEXT: #pragma omp target enter data nowait map(to: c) map(alloc: d)
197
198 #pragma omp target enter data nowait map(always,alloc: e)
199 // CHECK-NEXT: #pragma omp target enter data nowait map(always,alloc: e)
200
201 #pragma omp target enter data depend(in : argc, argv[i:argc], x[:]) nowait map(to: a)
202 // CHECK: #pragma omp target enter data depend(in : argc,argv[i:argc],x[:]) nowait map(to: a)
203
204 #pragma omp target enter data nowait depend(in : argc, argv[i:argc], x[:]) map(to: a) if (target enter data: b)
205 // CHECK: #pragma omp target enter data nowait depend(in : argc,argv[i:argc],x[:]) map(to: a) if(target enter data: b)
206
207 #pragma omp target enter data map(to: a) depend(in : argc, argv[i:argc], x[:]) if (b > g) nowait
208 // CHECK: #pragma omp target enter data map(to: a) depend(in : argc,argv[i:argc],x[:]) if(b > g) nowait
209
210 #pragma omp target enter data map(to: c) nowait depend(in : argc, argv[i:argc], x[:])
211 // CHECK-NEXT: #pragma omp target enter data map(to: c) nowait depend(in : argc,argv[i:argc],x[:])
212
213 #pragma omp target enter data depend(in : argc, argv[i:argc], x[:]) map(alloc: c) nowait if(b>g)
214 // CHECK-NEXT: #pragma omp target enter data depend(in : argc,argv[i:argc],x[:]) map(alloc: c) nowait if(b > g)
215
216 #pragma omp target enter data nowait map(to: x[0:10], c) depend(in : argc, argv[i:argc], x[:])
217 // CHECK-NEXT: #pragma omp target enter data nowait map(to: x[0:10],c) depend(in : argc,argv[i:argc],x[:])
218
219 #pragma omp target enter data nowait map(to: c) depend(in : argc, argv[i:argc], x[:]) map(alloc: d)
220 // CHECK-NEXT: #pragma omp target enter data nowait map(to: c) depend(in : argc,argv[i:argc],x[:]) map(alloc: d)
221
222 #pragma omp target enter data nowait map(always,alloc: e) depend(in : argc, argv[i:argc], x[:])
223 // CHECK-NEXT: #pragma omp target enter data nowait map(always,alloc: e) depend(in : argc,argv[i:argc],x[:])
224
225 return tmain<int, 5>(argc, &argc) + tmain<char, 1>(argv[0][0], argv[0]);
226 }
227
228 #endif
229