1 // RUN: %clang_cc1 -verify -Wno-vla -fopenmp -fopenmp-version=50 -ast-print %s | FileCheck %s
2 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s
3 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -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 -fopenmp-version=50 -ast-print %s | FileCheck %s
6 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -std=c++11 -emit-pch -o %t %s
7 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -std=c++11 -include-pch %t -fsyntax-only -verify -Wno-vla %s -ast-print | FileCheck %s
9 // RUN: %clang_cc1 -DOMP51 -verify -Wno-vla -fopenmp -ast-print %s | FileCheck -check-prefixes=CHECK,OMP51 %s
10 // RUN: %clang_cc1 -DOMP51 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
11 // RUN: %clang_cc1 -DOMP51 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify -Wno-vla %s -ast-print | FileCheck -check-prefixes=CHECK,OMP51 %s
13 // RUN: %clang_cc1 -DOMP51 -verify -Wno-vla -fopenmp-simd -ast-print %s | FileCheck -check-prefixes=CHECK,OMP51 %s
14 // RUN: %clang_cc1 -DOMP51 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
15 // RUN: %clang_cc1 -DOMP51 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify -Wno-vla %s -ast-print | FileCheck -check-prefixes=CHECK,OMP51 %s
16 // expected-no-diagnostics
28 S1
& operator +(const S1
&);
29 S1
& operator *(const S1
&);
30 S1
& operator &&(const S1
&);
31 S1
& operator ^(const S1
&);
42 S7(typename
T::type v
) : a(v
) {
43 #pragma omp parallel private(a) private(this->a) private(T::a)
44 for (int k
= 0; k
< a
.a
; ++k
)
46 #pragma omp parallel firstprivate(a) firstprivate(this->a) firstprivate(T::a)
47 for (int k
= 0; k
< a
.a
; ++k
)
49 #pragma omp parallel shared(a) shared(this->a) shared(T::a)
50 for (int k
= 0; k
< a
.a
; ++k
)
52 #pragma omp parallel reduction(+ : a) reduction(*: b[:])
53 for (int k
= 0; k
< a
.a
; ++k
)
56 S7
&operator=(S7
&s
) {
57 #pragma omp parallel private(a) private(this->a)
58 for (int k
= 0; k
< s
.a
.a
; ++k
)
60 #pragma omp parallel firstprivate(a) firstprivate(this->a)
61 for (int k
= 0; k
< s
.a
.a
; ++k
)
63 #pragma omp parallel shared(a) shared(this->a)
64 for (int k
= 0; k
< s
.a
.a
; ++k
)
66 #pragma omp parallel reduction(&& : this->a) reduction(^: b[s.a.a])
67 for (int k
= 0; k
< s
.a
.a
; ++k
)
73 // CHECK: #pragma omp parallel private(this->a) private(this->a) private(T::a)
74 // CHECK: #pragma omp parallel firstprivate(this->a) firstprivate(this->a) firstprivate(T::a)
75 // CHECK: #pragma omp parallel shared(this->a) shared(this->a) shared(T::a)
76 // CHECK: #pragma omp parallel reduction(+: this->a) reduction(*: this->b[:])
77 // CHECK: #pragma omp parallel private(this->a) private(this->a)
78 // CHECK: #pragma omp parallel firstprivate(this->a) firstprivate(this->a)
79 // CHECK: #pragma omp parallel shared(this->a) shared(this->a)
80 // CHECK: #pragma omp parallel reduction(&&: this->a) reduction(^: this->b[s.a.a])
81 // CHECK: #pragma omp parallel private(this->a) private(this->a) private(this->S1::a)
82 // CHECK: #pragma omp parallel firstprivate(this->a) firstprivate(this->a) firstprivate(this->S1::a)
83 // CHECK: #pragma omp parallel shared(this->a) shared(this->a) shared(this->S1::a)
84 // CHECK: #pragma omp parallel reduction(+: this->a) reduction(*: this->b[:])
86 class S8
: public S7
<S1
> {
90 S8(int v
) : S7
<S1
>(v
){
91 #pragma omp parallel private(a) private(this->a) private(S7 < S1 > ::a)
92 for (int k
= 0; k
< a
.a
; ++k
)
94 #pragma omp parallel firstprivate(a) firstprivate(this->a) firstprivate(S7 < S1 > ::a)
95 for (int k
= 0; k
< a
.a
; ++k
)
97 #pragma omp parallel shared(a) shared(this->a) shared(S7 < S1 > ::a)
98 for (int k
= 0; k
< a
.a
; ++k
)
100 #pragma omp parallel reduction(default, ^ : S7 < S1 > ::a) reduction(+ : S7 < S1 > ::b[ : S7 < S1 > ::a.a])
101 for (int k
= 0; k
< a
.a
; ++k
)
104 S8
&operator=(S8
&s
) {
105 #pragma omp parallel private(a) private(this->a)
106 for (int k
= 0; k
< s
.a
.a
; ++k
)
108 #pragma omp parallel firstprivate(a) firstprivate(this->a)
109 for (int k
= 0; k
< s
.a
.a
; ++k
)
111 #pragma omp parallel shared(a) shared(this->a)
112 for (int k
= 0; k
< s
.a
.a
; ++k
)
114 #pragma omp parallel reduction(* : this->a) reduction(&&:this->b[a.a:])
115 for (int k
= 0; k
< s
.a
.a
; ++k
)
121 // CHECK: #pragma omp parallel private(this->a) private(this->a) private(this->S7<S1>::a)
122 // CHECK: #pragma omp parallel firstprivate(this->a) firstprivate(this->a) firstprivate(this->S7<S1>::a)
123 // CHECK: #pragma omp parallel shared(this->a) shared(this->a) shared(this->S7<S1>::a)
124 // CHECK: #pragma omp parallel reduction(default, ^: this->S7<S1>::a) reduction(+: this->S7<S1>::b[:this->S7<S1>::a.a])
125 // CHECK: #pragma omp parallel private(this->a) private(this->a)
126 // CHECK: #pragma omp parallel firstprivate(this->a) firstprivate(this->a)
127 // CHECK: #pragma omp parallel shared(this->a) shared(this->a)
128 // CHECK: #pragma omp parallel reduction(*: this->a) reduction(&&: this->b[this->a.a:])
132 operator T() {return T();}
134 #pragma omp threadprivate(TS)
137 // CHECK: template <class T> struct S {
138 // CHECK: static T TS;
139 // CHECK-NEXT: #pragma omp threadprivate(S::TS)
141 // CHECK: template<> struct S<int> {
142 // CHECK: static int TS;
143 // CHECK-NEXT: #pragma omp threadprivate(S<int>::TS)
145 // CHECK: template<> struct S<long> {
146 // CHECK: static long TS;
147 // CHECK-NEXT: #pragma omp threadprivate(S<long>::TS)
151 #pragma omp threadprivate(thrp)
153 template <typename T
, int C
>
154 T
tmain(T argc
, T
*argv
) {
155 T b
= argc
, c
, d
, e
, f
, g
;
158 T arr
[C
][10], arr1
[C
];
161 #pragma omp parallel 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])
164 #pragma omp parallel default(none), private(argc,b) firstprivate(argv) shared (d) if (parallel:argc > 0) num_threads(C) copyin(S<T>::TS, thrp) proc_bind(primary) reduction(+:c, arr1[argc]) reduction(max:e, arr[:C][0:10])
167 #pragma omp parallel if (C) num_threads(s) proc_bind(close) reduction(^:e, f, arr[0:C][:argc]) reduction(default, && : g) reduction(task,+:argc)
172 // CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
173 // CHECK-NEXT: T b = argc, c, d, e, f, g;
174 // CHECK-NEXT: static T a;
175 // CHECK-NEXT: S<T> s;
176 // CHECK-NEXT: T arr[C][10], arr1[C];
177 // CHECK-NEXT: #pragma omp parallel{{$}}
178 // CHECK-NEXT: a = 2;
179 // CHECK-NEXT: #pragma omp parallel 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])
181 // OMP51-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(C) copyin(S<T>::TS,thrp) proc_bind(primary) reduction(+: c,arr1[argc]) reduction(max: e,arr[:C][0:10])
183 // CHECK-NEXT: #pragma omp parallel if(C) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:C][:argc]) reduction(default, &&: g) reduction(task, +: argc)
185 // CHECK: template<> int tmain<int, 5>(int argc, int *argv) {
186 // CHECK-NEXT: int b = argc, c, d, e, f, g;
187 // CHECK-NEXT: static int a;
188 // CHECK-NEXT: S<int> s;
189 // CHECK-NEXT: int arr[5][10], arr1[5];
190 // CHECK-NEXT: #pragma omp parallel
191 // CHECK-NEXT: a = 2;
192 // CHECK-NEXT: #pragma omp parallel 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])
194 // OMP51-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(5) copyin(S<int>::TS,thrp) proc_bind(primary) reduction(+: c,arr1[argc]) reduction(max: e,arr[:5][0:10])
196 // CHECK-NEXT: #pragma omp parallel if(5) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:5][:argc]) reduction(default, &&: g) reduction(task, +: argc)
198 // CHECK: template<> long tmain<long, 1>(long argc, long *argv) {
199 // CHECK-NEXT: long b = argc, c, d, e, f, g;
200 // CHECK-NEXT: static long a;
201 // CHECK-NEXT: S<long> s;
202 // CHECK-NEXT: long arr[1][10], arr1[1];
203 // CHECK-NEXT: #pragma omp parallel
204 // CHECK-NEXT: a = 2;
205 // CHECK-NEXT: #pragma omp parallel 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])
207 // OMP51-NEXT: #pragma omp parallel default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(1) copyin(S<long>::TS,thrp) proc_bind(primary) reduction(+: c,arr1[argc]) reduction(max: e,arr[:1][0:10])
209 // CHECK-NEXT: #pragma omp parallel if(1) num_threads(s) proc_bind(close) reduction(^: e,f,arr[0:1][:argc]) reduction(default, &&: g) reduction(task, +: argc)
214 int main (int argc
, char **argv
) {
216 int b
= argc
, c
, d
, e
, f
, g
;
218 #pragma omp threadprivate(a)
219 int arr
[10][argc
], arr1
[2];
223 // CHECK-NEXT: #pragma omp parallel
225 // CHECK-NEXT: a = 2;
226 #pragma omp parallel 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)
227 // CHECK-NEXT: #pragma omp parallel 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)
229 // CHECK-NEXT: foo();
230 // CHECK-NEXT: #pragma omp parallel allocate(e) if(b) num_threads(c) proc_bind(close) reduction(^: e,f) reduction(&&: g,arr[0:argc][:10])
232 #pragma omp parallel allocate(e) if (b) num_threads(c) proc_bind(close) reduction(^:e, f) reduction(&& : g, arr[0:argc][:10])
234 return tmain
<int, 5>(b
, &b
) + tmain
<long, 1>(x
, &x
);
242 void foo(const Foo
<int> &arg
) {
243 // CHECK: #pragma omp parallel
246 // CHECK: #pragma omp for schedule(static)
247 #pragma omp for schedule(static)
248 for (int idx
= 0; idx
< 1234; ++idx
) {