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 -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 -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
) {
35 #pragma omp parallel master private(a) private(this->a) private(T::a)
36 for (int k
= 0; k
< a
.a
; ++k
)
38 #pragma omp parallel master firstprivate(a) firstprivate(this->a) firstprivate(T::a)
39 for (int k
= 0; k
< a
.a
; ++k
)
41 #pragma omp parallel master shared(a) shared(this->a) shared(T::a)
42 for (int k
= 0; k
< a
.a
; ++k
)
44 #pragma omp parallel master reduction(+ : a) reduction(*: b[:])
45 for (int k
= 0; k
< a
.a
; ++k
)
48 S7
&operator=(S7
&s
) {
49 #pragma omp parallel master private(a) private(this->a)
50 for (int k
= 0; k
< s
.a
.a
; ++k
)
52 #pragma omp parallel master firstprivate(a) firstprivate(this->a)
53 for (int k
= 0; k
< s
.a
.a
; ++k
)
55 #pragma omp parallel master shared(a) shared(this->a)
56 for (int k
= 0; k
< s
.a
.a
; ++k
)
58 #pragma omp parallel master reduction(&& : this->a) reduction(^: b[s.a.a])
59 for (int k
= 0; k
< s
.a
.a
; ++k
)
65 // CHECK: #pragma omp parallel master private(this->a) private(this->a) private(T::a)
66 // CHECK: #pragma omp parallel master firstprivate(this->a) firstprivate(this->a) firstprivate(T::a)
67 // CHECK: #pragma omp parallel master shared(this->a) shared(this->a) shared(T::a)
68 // CHECK: #pragma omp parallel master reduction(+: this->a) reduction(*: this->b[:])
69 // CHECK: #pragma omp parallel master private(this->a) private(this->a)
70 // CHECK: #pragma omp parallel master firstprivate(this->a) firstprivate(this->a)
71 // CHECK: #pragma omp parallel master shared(this->a) shared(this->a)
72 // CHECK: #pragma omp parallel master reduction(&&: this->a) reduction(^: this->b[s.a.a])
73 // CHECK: #pragma omp parallel master private(this->a) private(this->a) private(this->S1::a)
74 // CHECK: #pragma omp parallel master firstprivate(this->a) firstprivate(this->a) firstprivate(this->S1::a)
75 // CHECK: #pragma omp parallel master shared(this->a) shared(this->a) shared(this->S1::a)
76 // CHECK: #pragma omp parallel master reduction(+: this->a) reduction(*: this->b[:])
78 class S8
: public S7
<S1
> {
82 S8(int v
) : S7
<S1
>(v
){
83 #pragma omp parallel master private(a) private(this->a) private(S7 < S1 > ::a)
84 for (int k
= 0; k
< a
.a
; ++k
)
86 #pragma omp parallel master firstprivate(a) firstprivate(this->a) firstprivate(S7 < S1 > ::a)
87 for (int k
= 0; k
< a
.a
; ++k
)
89 #pragma omp parallel master shared(a) shared(this->a) shared(S7 < S1 > ::a)
90 for (int k
= 0; k
< a
.a
; ++k
)
92 #pragma omp parallel master reduction(^ : S7 < S1 > ::a) reduction(+ : S7 < S1 > ::b[ : S7 < S1 > ::a.a])
93 for (int k
= 0; k
< a
.a
; ++k
)
96 S8
&operator=(S8
&s
) {
97 #pragma omp parallel master private(a) private(this->a)
98 for (int k
= 0; k
< s
.a
.a
; ++k
)
100 #pragma omp parallel master firstprivate(a) firstprivate(this->a)
101 for (int k
= 0; k
< s
.a
.a
; ++k
)
103 #pragma omp parallel master shared(a) shared(this->a)
104 for (int k
= 0; k
< s
.a
.a
; ++k
)
106 #pragma omp parallel master reduction(* : this->a) reduction(&&:this->b[a.a:])
107 for (int k
= 0; k
< s
.a
.a
; ++k
)
113 // CHECK: #pragma omp parallel master private(this->a) private(this->a) private(this->S7<S1>::a)
114 // CHECK: #pragma omp parallel master firstprivate(this->a) firstprivate(this->a) firstprivate(this->S7<S1>::a)
115 // CHECK: #pragma omp parallel master shared(this->a) shared(this->a) shared(this->S7<S1>::a)
116 // CHECK: #pragma omp parallel master reduction(^: this->S7<S1>::a) reduction(+: this->S7<S1>::b[:this->S7<S1>::a.a])
117 // CHECK: #pragma omp parallel master private(this->a) private(this->a)
118 // CHECK: #pragma omp parallel master firstprivate(this->a) firstprivate(this->a)
119 // CHECK: #pragma omp parallel master shared(this->a) shared(this->a)
120 // CHECK: #pragma omp parallel master reduction(*: this->a) reduction(&&: this->b[this->a.a:])
124 operator T() {return T();}
126 #pragma omp threadprivate(TS)
129 // CHECK: template <class T> struct S {
130 // CHECK: static T TS;
131 // CHECK-NEXT: #pragma omp threadprivate(S::TS)
133 // CHECK: template<> struct S<int> {
134 // CHECK: static int TS;
135 // CHECK-NEXT: #pragma omp threadprivate(S<int>::TS)
137 // CHECK: template<> struct S<long> {
138 // CHECK: static long TS;
139 // CHECK-NEXT: #pragma omp threadprivate(S<long>::TS)
143 #pragma omp threadprivate(thrp)
145 template <typename T
, int C
>
146 T
tmain(T argc
, T
*argv
) {
147 T b
= argc
, c
, d
, e
, f
, g
;
150 T arr
[C
][10], arr1
[C
];
151 #pragma omp parallel master
153 #pragma omp parallel master 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])
155 #pragma omp parallel master if (C) num_threads(s) proc_bind(close) reduction(^:e, f, arr[0:C][:argc]) reduction(task, && : g)
160 // CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
161 // CHECK-NEXT: T b = argc, c, d, e, f, g;
162 // CHECK-NEXT: static T a;
163 // CHECK-NEXT: S<T> s;
164 // CHECK-NEXT: T arr[C][10], arr1[C];
165 // CHECK-NEXT: #pragma omp parallel master{{$}}
166 // CHECK-NEXT: a = 2;
167 // CHECK-NEXT: #pragma omp parallel master 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])
169 // CHECK-NEXT: #pragma omp parallel master if(C) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:C][:argc]) reduction(task, &&: g)
171 // CHECK: template<> int tmain<int, 5>(int argc, int *argv) {
172 // CHECK-NEXT: int b = argc, c, d, e, f, g;
173 // CHECK-NEXT: static int a;
174 // CHECK-NEXT: S<int> s;
175 // CHECK-NEXT: int arr[5][10], arr1[5];
176 // CHECK-NEXT: #pragma omp parallel master
177 // CHECK-NEXT: a = 2;
178 // CHECK-NEXT: #pragma omp parallel master 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])
180 // CHECK-NEXT: #pragma omp parallel master if(5) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:5][:argc]) reduction(task, &&: g)
182 // CHECK: template<> long tmain<long, 1>(long argc, long *argv) {
183 // CHECK-NEXT: long b = argc, c, d, e, f, g;
184 // CHECK-NEXT: static long a;
185 // CHECK-NEXT: S<long> s;
186 // CHECK-NEXT: long arr[1][10], arr1[1];
187 // CHECK-NEXT: #pragma omp parallel master
188 // CHECK-NEXT: a = 2;
189 // CHECK-NEXT: #pragma omp parallel master 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])
191 // CHECK-NEXT: #pragma omp parallel master if(1) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:1][:argc]) reduction(task, &&: g)
196 int main (int argc
, char **argv
) {
198 int b
= argc
, c
, d
, e
, f
, g
;
200 #pragma omp threadprivate(a)
201 int arr
[10][argc
], arr1
[2];
204 #pragma omp parallel master
205 // CHECK-NEXT: #pragma omp parallel master
207 // CHECK-NEXT: a = 2;
208 #pragma omp parallel master 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)
209 // CHECK-NEXT: #pragma omp parallel master 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)
211 // CHECK-NEXT: foo();
212 // CHECK-NEXT: #pragma omp parallel master allocate(e) if(b) num_threads(c) proc_bind(close) reduction(^: e,f) reduction(&&: g,arr[0:argc][:10])
214 #pragma omp parallel master allocate(e) if (b) num_threads(c) proc_bind(close) reduction(^:e, f) reduction(&& : g, arr[0:argc][:10])
216 return tmain
<int, 5>(b
, &b
) + tmain
<long, 1>(x
, &x
);