1 // RUN: %clang_cc1 -verify -Wno-vla -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 -Wno-vla %s -ast-print | FileCheck %s
5 // RUN: %clang_cc1 -verify -Wno-vla -fopenmp-simd -ast-print %s | FileCheck %s
6 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
7 // RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify -Wno-vla %s -ast-print | FileCheck %s
8 // expected-no-diagnostics
13 typedef void *omp_depend_t
;
14 typedef unsigned long omp_event_handle_t
;
23 S1
operator +(const S1
&);
33 S7(typename
T::type v
) : a(v
) {
35 omp_event_handle_t evt
;
36 #pragma omp taskgroup allocate(b) task_reduction(+:b)
37 #pragma omp task private(a) private(this->a) private(T::a) in_reduction(+:this->b) allocate(b) depend(depobj:x) detach(evt) depend(iterator(i=0:10:1, T *k = &a:&b), in: c[i], d[(int)(k-&a)]) affinity(iterator(i=0:10:1, T *k = &a:&b): c[i], d[(int)(k-&a)])
38 for (int k
= 0; k
< a
.a
; ++k
)
41 S7
&operator=(S7
&s
) {
42 #pragma omp task private(a) private(this->a)
43 for (int k
= 0; k
< s
.a
.a
; ++k
)
49 // CHECK: #pragma omp taskgroup allocate(this->b) task_reduction(+: this->b)
50 // CHECK: #pragma omp task private(this->a) private(this->a) private(T::a) in_reduction(+: this->b) allocate(this->b) depend(depobj : x) detach(evt) depend(iterator(int i = 0:10:1, T * k = &this->a:&this->b), in : this->c[i],this->d[(int)(k - &this->a)]) affinity(iterator(int i = 0:10:1, T * k = &this->a:&this->b) : this->c[i],this->d[(int)(k - &this->a)]){{$}}
51 // CHECK: #pragma omp task private(this->a) private(this->a)
52 // CHECK: #pragma omp task private(this->a) private(this->a) private(this->S1::a) in_reduction(+: this->b) allocate(this->b) depend(depobj : x) detach(evt) depend(iterator(int i = 0:10:1, S1 * k = &this->a:&this->b), in : this->c[i],this->d[(int)(k - &this->a)]) affinity(iterator(int i = 0:10:1, S1 * k = &this->a:&this->b) : this->c[i],this->d[(int)(k - &this->a)])
54 class S8
: public S7
<S1
> {
58 S8(int v
) : S7
<S1
>(v
){
59 #pragma omp task private(a) private(this->a) private(S7<S1>::a)
60 for (int k
= 0; k
< a
.a
; ++k
)
63 S8
&operator=(S8
&s
) {
64 #pragma omp task private(a) private(this->a)
65 for (int k
= 0; k
< s
.a
.a
; ++k
)
71 // CHECK: #pragma omp task private(this->a) private(this->a) private(this->S7<S1>::a)
72 // CHECK: #pragma omp task private(this->a) private(this->a)
76 operator T() { return T(); }
78 #pragma omp threadprivate(TS)
81 // CHECK: template <class T> struct S {
82 // CHECK: static T TS;
83 // CHECK-NEXT: #pragma omp threadprivate(S::TS)
85 // CHECK: template<> struct S<int> {
86 // CHECK: static int TS;
87 // CHECK-NEXT: #pragma omp threadprivate(S<int>::TS)
89 // CHECK: template<> struct S<long> {
90 // CHECK: static long TS;
91 // CHECK-NEXT: #pragma omp threadprivate(S<long>::TS)
94 template <typename T
, int C
>
95 T
tmain(T argc
, T
*argv
) {
96 T b
= argc
, c
, d
, e
, f
, g
;
101 omp_event_handle_t evt
;
103 #pragma omp task untied depend(in : argc, argv[b:argc], arr[:], ([argc][sizeof(T)])argv, arr_double[argc]) if (task : argc > 0) depend(depobj: x) detach(evt)
105 #pragma omp task default(none), private(argc, b) firstprivate(argv) shared(d) if (argc > 0) final(S<T>::TS > 0) priority(argc) affinity(argc, argv[b:argc], arr[:], ([argc][sizeof(T)])argv)
107 #pragma omp taskgroup task_reduction(-: argc)
108 #pragma omp task if (C) mergeable priority(C) in_reduction(-: argc)
113 // CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
114 // CHECK-NEXT: T b = argc, c, d, e, f, g;
115 // CHECK-NEXT: static T a;
116 // CHECK-NEXT: S<T> s;
117 // CHECK-NEXT: T arr[argc];
118 // CHECK-NEXT: omp_depend_t x;
119 // CHECK-NEXT: omp_event_handle_t evt;
120 // CHECK-NEXT: double *arr_double;
121 // CHECK-NEXT: #pragma omp task untied depend(in : argc,argv[b:argc],arr[:],([argc][sizeof(T)])argv,arr_double[argc]) if(task: argc > 0) depend(depobj : x) detach(evt)
122 // CHECK-NEXT: a = 2;
123 // CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) final(S<T>::TS > 0) priority(argc) affinity(argc,argv[b:argc],arr[:],([argc][sizeof(T)])argv)
125 // CHECK-NEXT: #pragma omp taskgroup task_reduction(-: argc)
126 // CHECK-NEXT: #pragma omp task if(C) mergeable priority(C) in_reduction(-: argc)
128 // CHECK: template<> int tmain<int, 5>(int argc, int *argv) {
129 // CHECK-NEXT: int b = argc, c, d, e, f, g;
130 // CHECK-NEXT: static int a;
131 // CHECK-NEXT: S<int> s;
132 // CHECK-NEXT: int arr[argc];
133 // CHECK-NEXT: omp_depend_t x;
134 // CHECK-NEXT: omp_event_handle_t evt;
135 // CHECK-NEXT: double *arr_double;
136 // CHECK-NEXT: #pragma omp task untied depend(in : argc,argv[b:argc],arr[:],([argc][sizeof(int)])argv,arr_double[argc]) if(task: argc > 0) depend(depobj : x) detach(evt)
137 // CHECK-NEXT: a = 2;
138 // CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) final(S<int>::TS > 0) priority(argc) affinity(argc,argv[b:argc],arr[:],([argc][sizeof(int)])argv)
140 // CHECK-NEXT: #pragma omp taskgroup task_reduction(-: argc)
141 // CHECK-NEXT: #pragma omp task if(5) mergeable priority(5) in_reduction(-: argc)
143 // CHECK: template<> long tmain<long, 1>(long argc, long *argv) {
144 // CHECK-NEXT: long b = argc, c, d, e, f, g;
145 // CHECK-NEXT: static long a;
146 // CHECK-NEXT: S<long> s;
147 // CHECK-NEXT: long arr[argc];
148 // CHECK-NEXT: omp_depend_t x;
149 // CHECK-NEXT: omp_event_handle_t evt;
150 // CHECK-NEXT: double *arr_double;
151 // CHECK-NEXT: #pragma omp task untied depend(in : argc,argv[b:argc],arr[:],([argc][sizeof(long)])argv,arr_double[argc]) if(task: argc > 0) depend(depobj : x) detach(evt)
152 // CHECK-NEXT: a = 2;
153 // CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv) shared(d) if(argc > 0) final(S<long>::TS > 0) priority(argc) affinity(argc,argv[b:argc],arr[:],([argc][sizeof(long)])argv)
155 // CHECK-NEXT: #pragma omp taskgroup task_reduction(-: argc)
156 // CHECK-NEXT: #pragma omp task if(1) mergeable priority(1) in_reduction(-: argc)
161 int main(int argc
, char **argv
) {
163 int b
= argc
, c
, d
, e
, f
, g
;
165 int arr
[10], arr1
[argc
];
167 omp_event_handle_t evt
;
168 #pragma omp threadprivate(a)
171 #pragma omp task untied mergeable depend(out:argv[:a][1], (arr)[0:],([argc][10])argv,b) if(task: argc > 0) priority(f) depend(depobj:y)
172 // CHECK-NEXT: #pragma omp task untied mergeable depend(out : argv[:a][1],(arr)[0:],([argc][10])argv,b) if(task: argc > 0) priority(f) depend(depobj : y)
174 // CHECK-NEXT: a = 2;
175 #pragma omp taskgroup task_reduction(min: arr1)
176 #pragma omp task default(none), private(argc, b) firstprivate(argv, evt) if (argc > 0) final(a > 0) depend(inout : a, argv[:argc],arr[:a], ([10][argc])argv) priority(23) in_reduction(min: arr1), detach(evt)
177 // CHECK-NEXT: #pragma omp taskgroup task_reduction(min: arr1)
178 // CHECK-NEXT: #pragma omp task default(none) private(argc,b) firstprivate(argv,evt) if(argc > 0) final(a > 0) depend(inout : a,argv[:argc],arr[:a],([10][argc])argv) priority(23) in_reduction(min: arr1) detach(evt)
180 // CHECK-NEXT: foo();
181 #pragma omp taskgroup task_reduction(min: arr1)
182 #pragma omp parallel reduction(+:arr1)
183 #pragma omp task in_reduction(min: arr1) depend(iterator(i=0:argc, unsigned j=argc:0:a), out: argv[i][j])
184 // CHECK-NEXT: #pragma omp taskgroup task_reduction(min: arr1)
185 // CHECK-NEXT: #pragma omp parallel reduction(+: arr1)
186 // CHECK-NEXT: #pragma omp task in_reduction(min: arr1) depend(iterator(int i = 0:argc, unsigned int j = argc:0:a), out : argv[i][j])
188 // CHECK-NEXT: foo();
189 // CHECK-NEXT: #pragma omp task in_reduction(+: arr1)
190 #pragma omp task in_reduction(+: arr1)
192 // CHECK-NEXT: foo();
193 // CHECK-NEXT: #pragma omp task depend(out : arr,omp_all_memory)
194 #pragma omp task depend(out: omp_all_memory, arr)
196 // CHECK-NEXT: foo();
197 // CHECK-NEXT: #pragma omp task depend(inout : b,arr,a,x,omp_all_memory)
198 #pragma omp task depend(inout: b, arr, omp_all_memory, a, x)
200 // CHECK-NEXT: foo();
201 // CHECK-NEXT: #pragma omp task depend(inout : omp_all_memory)
202 #pragma omp task depend(inout: omp_all_memory)
204 // CHECK-NEXT: foo();
205 return tmain
<int, 5>(b
, &b
) + tmain
<long, 1>(x
, &x
);
208 extern template int S
<int>::TS
;
209 extern template long S
<long>::TS
;