1 // RUN: %clang_cc1 -verify -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 %s -ast-print | FileCheck %s
5 // RUN: %clang_cc1 -verify -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 %s -ast-print | FileCheck %s
8 // expected-no-diagnostics
17 operator T() { return T(); }
19 #pragma omp threadprivate(TS)
22 // CHECK: template <class T> struct S {
23 // CHECK: static T TS;
24 // CHECK-NEXT: #pragma omp threadprivate(S::TS)
26 // CHECK: template<> struct S<int> {
27 // CHECK: static int TS;
28 // CHECK-NEXT: #pragma omp threadprivate(S<int>::TS)
30 // CHECK: template<> struct S<long> {
31 // CHECK: static long TS;
32 // CHECK-NEXT: #pragma omp threadprivate(S<long>::TS)
35 template <typename T
, int C
>
36 T
tmain(T argc
, T
*argv
) {
37 T b
= argc
, c
, d
, e
, f
, g
;
40 #pragma omp parallel sections
44 #pragma omp parallel sections default(none), private(argc, b) firstprivate(argv) shared(d) if (parallel: argc > 0) num_threads(C) copyin(S < T > ::TS) proc_bind(master) reduction(+ : c) reduction(max : e) allocate(e)
48 #pragma omp parallel sections allocate(b) if (C) num_threads(s) proc_bind(close) reduction(^ : e, f) reduction(&& : g) lastprivate(b, c)
57 // CHECK: template <typename T, int C> T tmain(T argc, T *argv) {
58 // CHECK-NEXT: T b = argc, c, d, e, f, g;
59 // CHECK-NEXT: static T a;
60 // CHECK-NEXT: S<T> s;
61 // CHECK-NEXT: #pragma omp parallel sections{{$}}
65 // CHECK-NEXT: #pragma omp parallel sections default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(C) copyin(S<T>::TS) proc_bind(master) reduction(+: c) reduction(max: e) allocate(e)
69 // CHECK-NEXT: #pragma omp parallel sections allocate(b) if(C) num_threads(s) proc_bind(close) reduction(^: e,f) reduction(&&: g) lastprivate(b,c)
72 // CHECK-NEXT: #pragma omp section
75 // CHECK: template<> int tmain<int, 5>(int argc, int *argv) {
76 // CHECK-NEXT: int b = argc, c, d, e, f, g;
77 // CHECK-NEXT: static int a;
78 // CHECK-NEXT: S<int> s;
79 // CHECK-NEXT: #pragma omp parallel sections
83 // CHECK-NEXT: #pragma omp parallel sections default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(5) copyin(S<int>::TS) proc_bind(master) reduction(+: c) reduction(max: e) allocate(e)
87 // CHECK-NEXT: #pragma omp parallel sections allocate(b) if(5) num_threads(s) proc_bind(close) reduction(^: e,f) reduction(&&: g) lastprivate(b,c)
90 // CHECK-NEXT: #pragma omp section
93 // CHECK: template<> long tmain<long, 1>(long argc, long *argv) {
94 // CHECK-NEXT: long b = argc, c, d, e, f, g;
95 // CHECK-NEXT: static long a;
96 // CHECK-NEXT: S<long> s;
97 // CHECK-NEXT: #pragma omp parallel sections
101 // CHECK-NEXT: #pragma omp parallel sections default(none) private(argc,b) firstprivate(argv) shared(d) if(parallel: argc > 0) num_threads(1) copyin(S<long>::TS) proc_bind(master) reduction(+: c) reduction(max: e) allocate(e)
103 // CHECK-NEXT: foo();
105 // CHECK-NEXT: #pragma omp parallel sections allocate(b) if(1) num_threads(s) proc_bind(close) reduction(^: e,f) reduction(&&: g) lastprivate(b,c)
107 // CHECK-NEXT: foo();
108 // CHECK-NEXT: #pragma omp section
109 // CHECK-NEXT: foo();
114 int main(int argc
, char **argv
) {
116 int b
= argc
, c
, d
, e
, f
, g
;
118 #pragma omp threadprivate(a)
121 #pragma omp parallel sections reduction(task,*:f)
122 // CHECK-NEXT: #pragma omp parallel sections reduction(task, *: f)
127 // CHECK-NEXT: a = 2;
129 #pragma omp parallel sections default(none), private(argc, b) firstprivate(argv) if (argc > 0) num_threads(ee) copyin(a) proc_bind(spread) reduction(| : c, d) reduction(* : e) lastprivate(argv)
130 // CHECK-NEXT: #pragma omp parallel sections default(none) private(argc,b) firstprivate(argv) if(argc > 0) num_threads(ee) copyin(a) proc_bind(spread) reduction(|: c,d) reduction(*: e) lastprivate(argv)
139 // CHECK-NEXT: foo();
140 // CHECK-NEXT: #pragma omp section
141 // CHECK-NEXT: foo();
142 // CHECK-NEXT: #pragma omp section
143 // CHECK-NEXT: foo();
145 return tmain
<int, 5>(b
, &b
) + tmain
<long, 1>(x
, &x
);