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
20 S1
& operator +(const S1
&);
21 S1
& operator *(const S1
&);
22 S1
& operator &&(const S1
&);
23 S1
& operator ^(const S1
&);
34 S7(typename
T::type v
) : a(v
) {
36 // CHECK: #pragma omp parallel masked filter(tid) private(this->a) private(this->a) private(T::a)
37 #pragma omp parallel masked filter(tid) private(a) private(this->a) private(T::a)
38 for (int k
= 0; k
< a
.a
; ++k
)
40 // CHECK: #pragma omp parallel masked filter(tid) firstprivate(this->a) firstprivate(this->a) firstprivate(T::a)
41 #pragma omp parallel masked filter(tid) firstprivate(a) firstprivate(this->a) firstprivate(T::a)
42 for (int k
= 0; k
< a
.a
; ++k
)
44 // CHECK: #pragma omp parallel masked filter(tid) shared(this->a) shared(this->a) shared(T::a)
45 #pragma omp parallel masked filter(tid) shared(a) shared(this->a) shared(T::a)
46 for (int k
= 0; k
< a
.a
; ++k
)
48 // CHECK: #pragma omp parallel masked filter(tid) reduction(+: this->a) reduction(*: this->b[:])
49 #pragma omp parallel masked filter(tid) reduction(+ : a) reduction(*: b[:])
50 for (int k
= 0; k
< a
.a
; ++k
)
53 S7
&operator=(S7
&s
) {
55 // CHECK: #pragma omp parallel masked filter(tid) private(this->a) private(this->a)
56 #pragma omp parallel masked filter(tid) private(a) private(this->a)
57 for (int k
= 0; k
< s
.a
.a
; ++k
)
59 // CHECK: #pragma omp parallel masked filter(tid) firstprivate(this->a) firstprivate(this->a)
60 #pragma omp parallel masked filter(tid) firstprivate(a) firstprivate(this->a)
61 for (int k
= 0; k
< s
.a
.a
; ++k
)
63 // CHECK: #pragma omp parallel masked filter(tid) shared(this->a) shared(this->a)
64 #pragma omp parallel masked filter(tid) shared(a) shared(this->a)
65 for (int k
= 0; k
< s
.a
.a
; ++k
)
67 // CHECK: #pragma omp parallel masked filter(tid) reduction(&&: this->a) reduction(^: this->b[s.a.a])
68 #pragma omp parallel masked filter(tid) reduction(&& : this->a) reduction(^: b[s.a.a])
69 for (int k
= 0; k
< s
.a
.a
; ++k
)
75 // CHECK: #pragma omp parallel masked filter(tid) private(this->a) private(this->a) private(this->S1::a)
76 // CHECK: #pragma omp parallel masked filter(tid) firstprivate(this->a) firstprivate(this->a) firstprivate(this->S1::a)
77 // CHECK: #pragma omp parallel masked filter(tid) shared(this->a) shared(this->a) shared(this->S1::a)
78 // CHECK: #pragma omp parallel masked filter(tid) reduction(+: this->a) reduction(*: this->b[:])
80 class S8
: public S7
<S1
> {
84 S8(int v
) : S7
<S1
>(v
){
85 // CHECK: #pragma omp parallel masked private(this->a) private(this->a) private(this->S7<S1>::a)
86 #pragma omp parallel masked private(a) private(this->a) private(S7 < S1 > ::a)
87 for (int k
= 0; k
< a
.a
; ++k
)
89 // CHECK: #pragma omp parallel masked firstprivate(this->a) firstprivate(this->a) firstprivate(this->S7<S1>::a)
90 #pragma omp parallel masked firstprivate(a) firstprivate(this->a) firstprivate(S7 < S1 > ::a)
91 for (int k
= 0; k
< a
.a
; ++k
)
93 // CHECK: #pragma omp parallel masked shared(this->a) shared(this->a) shared(this->S7<S1>::a)
94 #pragma omp parallel masked shared(a) shared(this->a) shared(S7 < S1 > ::a)
95 for (int k
= 0; k
< a
.a
; ++k
)
97 // CHECK: #pragma omp parallel masked reduction(^: this->S7<S1>::a) reduction(+: this->S7<S1>::b[:this->S7<S1>::a.a])
98 #pragma omp parallel masked reduction(^ : S7 < S1 > ::a) reduction(+ : S7 < S1 > ::b[ : S7 < S1 > ::a.a])
99 for (int k
= 0; k
< a
.a
; ++k
)
102 S8
&operator=(S8
&s
) {
103 // CHECK: #pragma omp parallel masked private(this->a) private(this->a)
104 #pragma omp parallel masked private(a) private(this->a)
105 for (int k
= 0; k
< s
.a
.a
; ++k
)
107 // CHECK: #pragma omp parallel masked firstprivate(this->a) firstprivate(this->a)
108 #pragma omp parallel masked firstprivate(a) firstprivate(this->a)
109 for (int k
= 0; k
< s
.a
.a
; ++k
)
111 // CHECK: #pragma omp parallel masked shared(this->a) shared(this->a)
112 #pragma omp parallel masked shared(a) shared(this->a)
113 for (int k
= 0; k
< s
.a
.a
; ++k
)
115 // CHECK: #pragma omp parallel masked reduction(*: this->a) reduction(&&: this->b[this->a.a:])
116 #pragma omp parallel masked reduction(* : this->a) reduction(&&:this->b[a.a:])
117 for (int k
= 0; k
< s
.a
.a
; ++k
)
126 operator T() {return T();}
128 #pragma omp threadprivate(TS)
131 // CHECK: template <class T> struct S {
132 // CHECK: static T TS;
133 // CHECK-NEXT: #pragma omp threadprivate(S::TS)
135 // CHECK: template<> struct S<int> {
136 // CHECK: static int TS;
137 // CHECK-NEXT: #pragma omp threadprivate(S<int>::TS)
139 // CHECK: template<> struct S<long> {
140 // CHECK: static long TS;
141 // CHECK-NEXT: #pragma omp threadprivate(S<long>::TS)
145 #pragma omp threadprivate(thrp)
147 template <typename T
, int C
>
148 T
tmain(T argc
, T
*argv
) {
149 T b
= argc
, c
, d
, e
, f
, g
;
152 T arr
[C
][10], arr1
[C
];
153 #pragma omp parallel masked
155 #pragma omp parallel masked default(none), private(argc,b) firstprivate(argv) shared (d) if (parallel:argc > 0) num_threads(C) copyin(S<T>::TS, thrp) proc_bind(master) reduction(+:c, arr1[argc]) reduction(max:e, arr[:C][0:10])
157 #pragma omp parallel masked if (C) num_threads(s) proc_bind(close) reduction(^:e, f, arr[0:C][:argc]) reduction(task, && : g)
162 // CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
163 // CHECK-NEXT: T b = argc, c, d, e, f, g;
164 // CHECK-NEXT: static T a;
165 // CHECK-NEXT: S<T> s;
166 // CHECK-NEXT: T arr[C][10], arr1[C];
167 // CHECK-NEXT: #pragma omp parallel masked
168 // CHECK-NEXT: a = 2;
169 // CHECK-NEXT: #pragma omp parallel masked default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(C) copyin(S<T>::TS,thrp) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:C][0:10])
171 // CHECK-NEXT: #pragma omp parallel masked if(C) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:C][:argc]) reduction(task, &&: g)
173 // CHECK: template<> int tmain<int, 5>(int argc, int *argv) {
174 // CHECK-NEXT: int b = argc, c, d, e, f, g;
175 // CHECK-NEXT: static int a;
176 // CHECK-NEXT: S<int> s;
177 // CHECK-NEXT: int arr[5][10], arr1[5];
178 // CHECK-NEXT: #pragma omp parallel masked
179 // CHECK-NEXT: a = 2;
180 // CHECK-NEXT: #pragma omp parallel masked default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(5) copyin(S<int>::TS,thrp) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:5][0:10])
182 // CHECK-NEXT: #pragma omp parallel masked if(5) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:5][:argc]) reduction(task, &&: g)
184 // CHECK: template<> long tmain<long, 1>(long argc, long *argv) {
185 // CHECK-NEXT: long b = argc, c, d, e, f, g;
186 // CHECK-NEXT: static long a;
187 // CHECK-NEXT: S<long> s;
188 // CHECK-NEXT: long arr[1][10], arr1[1];
189 // CHECK-NEXT: #pragma omp parallel masked
190 // CHECK-NEXT: a = 2;
191 // CHECK-NEXT: #pragma omp parallel masked default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(1) copyin(S<long>::TS,thrp) proc_bind(master) reduction(+: c,arr1[argc]) reduction(max: e,arr[:1][0:10])
193 // CHECK-NEXT: #pragma omp parallel masked if(1) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:1][:argc]) reduction(task, &&: g)
198 int main (int argc
, char **argv
) {
200 int b
= argc
, c
, d
, e
, f
, g
;
203 #pragma omp threadprivate(a)
204 int arr
[10][argc
], arr1
[2];
207 #pragma omp parallel masked
208 // CHECK-NEXT: #pragma omp parallel masked
210 // CHECK-NEXT: a = 2;
211 #pragma omp parallel masked default(none), private(argc,b) firstprivate(argv) if (parallel: argc > 0) num_threads(ee) copyin(a) proc_bind(spread) reduction(| : c, d, arr1[argc]) reduction(* : e, arr[:10][0:argc]) allocate(e) filter(tid)
212 // CHECK-NEXT: #pragma omp parallel masked default(none) private(argc,b) firstprivate(argv) if(parallel: argc > 0) num_threads(ee) copyin(a) proc_bind(spread) reduction(|: c,d,arr1[argc]) reduction(*: e,arr[:10][0:argc]) allocate(e) filter(tid)
214 // CHECK-NEXT: foo();
215 // CHECK-NEXT: #pragma omp parallel masked allocate(e) if(b) num_threads(c) proc_bind(close) reduction(^: e,f) reduction(&&: g,arr[0:argc][:10])
217 #pragma omp parallel masked allocate(e) if (b) num_threads(c) proc_bind(close) reduction(^:e, f) reduction(&& : g, arr[0:argc][:10])
219 return tmain
<int, 5>(b
, &b
) + tmain
<long, 1>(x
, &x
);