1 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -ast-print %s | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -std=c++11 -include-pch %t -verify %s -ast-print | FileCheck %s
5 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -ast-print %s | FileCheck %s
6 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -emit-pch -o %t %s
7 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -std=c++11 -include-pch %t -verify %s -ast-print | FileCheck %s
9 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=52 -ast-print %s | FileCheck %s
10 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -x c++ -std=c++11 -emit-pch -o %t %s
11 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=52 -std=c++11 -include-pch %t -verify %s -ast-print | FileCheck %s
13 // RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
14 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
15 // RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -verify %s -ast-print | FileCheck %s
17 // RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s
18 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
19 // RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -verify %s -ast-print | FileCheck %s
21 // expected-no-diagnostics
26 template <typename T
, int C
>
27 T
tmain(T argc
, T
*argv
) {
28 T i
, j
, b
, c
, d
, e
, x
[20];
31 #pragma omp target enter data map(to: i)
33 #pragma omp target enter data map(to: i) if (target enter data: j > 0)
35 #pragma omp target enter data map(to: i) if (b)
37 #pragma omp target enter data map(to: c)
39 #pragma omp target enter data map(to: c) if(b>e)
41 #pragma omp target enter data map(alloc: x[0:10], c)
43 #pragma omp target enter data map(to: c) map(alloc: d)
45 #pragma omp target enter data map(always,alloc: e)
47 #pragma omp target enter data nowait map(to: i)
49 #pragma omp target enter data nowait map(to: i) if (target enter data: j > 0)
51 #pragma omp target enter data map(to: i) if (b) nowait
53 #pragma omp target enter data map(to: c) nowait
55 #pragma omp target enter data map(to: c) nowait if(b>e)
57 #pragma omp target enter data nowait map(alloc: x[0:10], c)
59 #pragma omp target enter data nowait map(to: c) map(alloc: d)
61 #pragma omp target enter data nowait map(always,alloc: e)
63 #pragma omp target enter data nowait depend(in : argc, argv[i:argc], x[:]) map(to: i)
65 #pragma omp target enter data nowait map(to: i) if (target enter data: j > 0) depend(in : argc, argv[i:argc], x[:])
67 #pragma omp target enter data depend(in : argc, argv[i:argc], x[:]) map(to: i) if (b) nowait
69 #pragma omp target enter data map(to: c) depend(in : argc, argv[i:argc], x[:]) nowait
71 #pragma omp target enter data map(to: c) nowait if(b>e) depend(in : argc, argv[i:argc], x[:])
73 #pragma omp target enter data nowait map(alloc: x[0:10], c) depend(in : argc, argv[i:argc], x[:])
75 #pragma omp target enter data nowait depend(in : argc, argv[i:argc], x[:]) map(to: c) map(alloc: d)
77 #pragma omp target enter data nowait map(always,alloc: e) depend(in : argc, argv[i:argc], x[:])
82 // CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
83 // CHECK-NEXT: T i, j, b, c, d, e, x[20];
84 // CHECK-NEXT: i = argc;
85 // CHECK-NEXT: #pragma omp target enter data map(to: i){{$}}
86 // CHECK-NEXT: #pragma omp target enter data map(to: i) if(target enter data: j > 0)
87 // CHECK-NEXT: #pragma omp target enter data map(to: i) if(b)
88 // CHECK-NEXT: #pragma omp target enter data map(to: c)
89 // CHECK-NEXT: #pragma omp target enter data map(to: c) if(b > e)
90 // CHECK-NEXT: #pragma omp target enter data map(alloc: x[0:10],c)
91 // CHECK-NEXT: #pragma omp target enter data map(to: c) map(alloc: d)
92 // CHECK-NEXT: #pragma omp target enter data map(always,alloc: e)
93 // CHECK-NEXT: #pragma omp target enter data nowait map(to: i)
94 // CHECK-NEXT: #pragma omp target enter data nowait map(to: i) if(target enter data: j > 0)
95 // CHECK-NEXT: #pragma omp target enter data map(to: i) if(b) nowait
96 // CHECK-NEXT: #pragma omp target enter data map(to: c) nowait
97 // CHECK-NEXT: #pragma omp target enter data map(to: c) nowait if(b > e)
98 // CHECK-NEXT: #pragma omp target enter data nowait map(alloc: x[0:10],c)
99 // CHECK-NEXT: #pragma omp target enter data nowait map(to: c) map(alloc: d)
100 // CHECK-NEXT: #pragma omp target enter data nowait map(always,alloc: e)
101 // CHECK-NEXT: #pragma omp target enter data nowait depend(in : argc,argv[i:argc],x[:]) map(to: i)
102 // CHECK-NEXT: #pragma omp target enter data nowait map(to: i) if(target enter data: j > 0) depend(in : argc,argv[i:argc],x[:])
103 // CHECK-NEXT: #pragma omp target enter data depend(in : argc,argv[i:argc],x[:]) map(to: i) if(b) nowait
104 // CHECK-NEXT: #pragma omp target enter data map(to: c) depend(in : argc,argv[i:argc],x[:]) nowait
105 // CHECK-NEXT: #pragma omp target enter data map(to: c) nowait if(b > e) depend(in : argc,argv[i:argc],x[:])
106 // CHECK-NEXT: #pragma omp target enter data nowait map(alloc: x[0:10],c) depend(in : argc,argv[i:argc],x[:])
107 // CHECK-NEXT: #pragma omp target enter data nowait depend(in : argc,argv[i:argc],x[:]) map(to: c) map(alloc: d)
108 // CHECK-NEXT: #pragma omp target enter data nowait map(always,alloc: e) depend(in : argc,argv[i:argc],x[:])
109 // CHECK: template<> int tmain<int, 5>(int argc, int *argv) {
110 // CHECK-NEXT: int i, j, b, c, d, e, x[20];
111 // CHECK-NEXT: i = argc;
112 // CHECK-NEXT: #pragma omp target enter data map(to: i)
113 // CHECK-NEXT: #pragma omp target enter data map(to: i) if(target enter data: j > 0)
114 // CHECK-NEXT: #pragma omp target enter data map(to: i) if(b)
115 // CHECK-NEXT: #pragma omp target enter data map(to: c)
116 // CHECK-NEXT: #pragma omp target enter data map(to: c) if(b > e)
117 // CHECK-NEXT: #pragma omp target enter data map(alloc: x[0:10],c)
118 // CHECK-NEXT: #pragma omp target enter data map(to: c) map(alloc: d)
119 // CHECK-NEXT: #pragma omp target enter data map(always,alloc: e)
120 // CHECK-NEXT: #pragma omp target enter data nowait map(to: i)
121 // CHECK-NEXT: #pragma omp target enter data nowait map(to: i) if(target enter data: j > 0)
122 // CHECK-NEXT: #pragma omp target enter data map(to: i) if(b) nowait
123 // CHECK-NEXT: #pragma omp target enter data map(to: c) nowait
124 // CHECK-NEXT: #pragma omp target enter data map(to: c) nowait if(b > e)
125 // CHECK-NEXT: #pragma omp target enter data nowait map(alloc: x[0:10],c)
126 // CHECK-NEXT: #pragma omp target enter data nowait map(to: c) map(alloc: d)
127 // CHECK-NEXT: #pragma omp target enter data nowait map(always,alloc: e)
128 // CHECK-NEXT: #pragma omp target enter data nowait depend(in : argc,argv[i:argc],x[:]) map(to: i)
129 // CHECK-NEXT: #pragma omp target enter data nowait map(to: i) if(target enter data: j > 0) depend(in : argc,argv[i:argc],x[:])
130 // CHECK-NEXT: #pragma omp target enter data depend(in : argc,argv[i:argc],x[:]) map(to: i) if(b) nowait
131 // CHECK-NEXT: #pragma omp target enter data map(to: c) depend(in : argc,argv[i:argc],x[:]) nowait
132 // CHECK-NEXT: #pragma omp target enter data map(to: c) nowait if(b > e) depend(in : argc,argv[i:argc],x[:])
133 // CHECK-NEXT: #pragma omp target enter data nowait map(alloc: x[0:10],c) depend(in : argc,argv[i:argc],x[:])
134 // CHECK-NEXT: #pragma omp target enter data nowait depend(in : argc,argv[i:argc],x[:]) map(to: c) map(alloc: d)
135 // CHECK-NEXT: #pragma omp target enter data nowait map(always,alloc: e) depend(in : argc,argv[i:argc],x[:])
136 // CHECK: template<> char tmain<char, 1>(char argc, char *argv) {
137 // CHECK-NEXT: char i, j, b, c, d, e, x[20];
138 // CHECK-NEXT: i = argc;
139 // CHECK-NEXT: #pragma omp target enter data map(to: i)
140 // CHECK-NEXT: #pragma omp target enter data map(to: i) if(target enter data: j > 0)
141 // CHECK-NEXT: #pragma omp target enter data map(to: i) if(b)
142 // CHECK-NEXT: #pragma omp target enter data map(to: c)
143 // CHECK-NEXT: #pragma omp target enter data map(to: c) if(b > e)
144 // CHECK-NEXT: #pragma omp target enter data map(alloc: x[0:10],c)
145 // CHECK-NEXT: #pragma omp target enter data map(to: c) map(alloc: d)
146 // CHECK-NEXT: #pragma omp target enter data map(always,alloc: e)
147 // CHECK-NEXT: #pragma omp target enter data nowait map(to: i)
148 // CHECK-NEXT: #pragma omp target enter data nowait map(to: i) if(target enter data: j > 0)
149 // CHECK-NEXT: #pragma omp target enter data map(to: i) if(b) nowait
150 // CHECK-NEXT: #pragma omp target enter data map(to: c) nowait
151 // CHECK-NEXT: #pragma omp target enter data map(to: c) nowait if(b > e)
152 // CHECK-NEXT: #pragma omp target enter data nowait map(alloc: x[0:10],c)
153 // CHECK-NEXT: #pragma omp target enter data nowait map(to: c) map(alloc: d)
154 // CHECK-NEXT: #pragma omp target enter data nowait map(always,alloc: e)
155 // CHECK-NEXT: #pragma omp target enter data nowait depend(in : argc,argv[i:argc],x[:]) map(to: i)
156 // CHECK-NEXT: #pragma omp target enter data nowait map(to: i) if(target enter data: j > 0) depend(in : argc,argv[i:argc],x[:])
157 // CHECK-NEXT: #pragma omp target enter data depend(in : argc,argv[i:argc],x[:]) map(to: i) if(b) nowait
158 // CHECK-NEXT: #pragma omp target enter data map(to: c) depend(in : argc,argv[i:argc],x[:]) nowait
159 // CHECK-NEXT: #pragma omp target enter data map(to: c) nowait if(b > e) depend(in : argc,argv[i:argc],x[:])
160 // CHECK-NEXT: #pragma omp target enter data nowait map(alloc: x[0:10],c) depend(in : argc,argv[i:argc],x[:])
161 // CHECK-NEXT: #pragma omp target enter data nowait depend(in : argc,argv[i:argc],x[:]) map(to: c) map(alloc: d)
162 // CHECK-NEXT: #pragma omp target enter data nowait map(always,alloc: e) depend(in : argc,argv[i:argc],x[:])
164 int main (int argc
, char **argv
) {
165 int b
= argc
, i
, c
, d
, e
, f
, g
, x
[20];
167 // CHECK: static int a;
169 #pragma omp target enter data map(to: a)
170 // CHECK: #pragma omp target enter data map(to: a)
172 // CHECK-NEXT: a = 2;
173 #pragma omp target enter data map(to: a) if (target enter data: b)
174 // CHECK: #pragma omp target enter data map(to: a) if(target enter data: b)
176 #pragma omp target enter data map(to: a) if (b > g)
177 // CHECK: #pragma omp target enter data map(to: a) if(b > g)
179 #pragma omp target enter data map(to: c)
180 // CHECK-NEXT: #pragma omp target enter data map(to: c)
182 #pragma omp target enter data map(alloc: c) if(b>g)
183 // CHECK-NEXT: #pragma omp target enter data map(alloc: c) if(b > g)
185 #pragma omp target enter data map(to: x[0:10], c)
186 // CHECK-NEXT: #pragma omp target enter data map(to: x[0:10],c)
188 #pragma omp target enter data map(to: c) map(alloc: d)
189 // CHECK-NEXT: #pragma omp target enter data map(to: c) map(alloc: d)
191 #pragma omp target enter data map(always,alloc: e)
192 // CHECK-NEXT: #pragma omp target enter data map(always,alloc: e)
194 #pragma omp target enter data nowait map(to: a)
195 // CHECK: #pragma omp target enter data nowait map(to: a)
197 #pragma omp target enter data nowait map(to: a) if (target enter data: b)
198 // CHECK: #pragma omp target enter data nowait map(to: a) if(target enter data: b)
200 #pragma omp target enter data map(to: a) if (b > g) nowait
201 // CHECK: #pragma omp target enter data map(to: a) if(b > g) nowait
203 #pragma omp target enter data map(to: c) nowait
204 // CHECK-NEXT: #pragma omp target enter data map(to: c) nowait
206 #pragma omp target enter data map(alloc: c) nowait if(b>g)
207 // CHECK-NEXT: #pragma omp target enter data map(alloc: c) nowait if(b > g)
209 #pragma omp target enter data nowait map(to: x[0:10], c)
210 // CHECK-NEXT: #pragma omp target enter data nowait map(to: x[0:10],c)
212 #pragma omp target enter data nowait map(to: c) map(alloc: d)
213 // CHECK-NEXT: #pragma omp target enter data nowait map(to: c) map(alloc: d)
215 #pragma omp target enter data nowait map(always,alloc: e)
216 // CHECK-NEXT: #pragma omp target enter data nowait map(always,alloc: e)
218 #pragma omp target enter data depend(in : argc, argv[i:argc], x[:]) nowait map(to: a)
219 // CHECK: #pragma omp target enter data depend(in : argc,argv[i:argc],x[:]) nowait map(to: a)
221 #pragma omp target enter data nowait depend(in : argc, argv[i:argc], x[:]) map(to: a) if (target enter data: b)
222 // CHECK: #pragma omp target enter data nowait depend(in : argc,argv[i:argc],x[:]) map(to: a) if(target enter data: b)
224 #pragma omp target enter data map(to: a) depend(in : argc, argv[i:argc], x[:]) if (b > g) nowait
225 // CHECK: #pragma omp target enter data map(to: a) depend(in : argc,argv[i:argc],x[:]) if(b > g) nowait
227 #pragma omp target enter data map(to: c) nowait depend(in : argc, argv[i:argc], x[:])
228 // CHECK-NEXT: #pragma omp target enter data map(to: c) nowait depend(in : argc,argv[i:argc],x[:])
230 #pragma omp target enter data depend(in : argc, argv[i:argc], x[:]) map(alloc: c) nowait if(b>g)
231 // CHECK-NEXT: #pragma omp target enter data depend(in : argc,argv[i:argc],x[:]) map(alloc: c) nowait if(b > g)
233 #pragma omp target enter data nowait map(to: x[0:10], c) depend(in : argc, argv[i:argc], x[:])
234 // CHECK-NEXT: #pragma omp target enter data nowait map(to: x[0:10],c) depend(in : argc,argv[i:argc],x[:])
236 #pragma omp target enter data nowait map(to: c) depend(in : argc, argv[i:argc], x[:]) map(alloc: d)
237 // CHECK-NEXT: #pragma omp target enter data nowait map(to: c) depend(in : argc,argv[i:argc],x[:]) map(alloc: d)
239 #pragma omp target enter data nowait map(always,alloc: e) depend(in : argc, argv[i:argc], x[:])
240 // CHECK-NEXT: #pragma omp target enter data nowait map(always,alloc: e) depend(in : argc,argv[i:argc],x[:])
242 return tmain
<int, 5>(argc
, &argc
) + tmain
<char, 1>(argv
[0][0], argv
[0]);