[OpenACC] Treat 'delete' as a valid clause during parsing in C++ mode
[llvm-project.git] / clang / test / OpenMP / parallel_master_ast_print.cpp
blob150a09cd73e214175ac0688dfe17be4f201dfb82
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
10 #ifndef HEADER
11 #define HEADER
13 void foo() {}
15 struct S1 {
16 S1(): a(0) {}
17 S1(int v) : a(v) {}
18 int a;
19 typedef int type;
20 S1& operator +(const S1&);
21 S1& operator *(const S1&);
22 S1& operator &&(const S1&);
23 S1& operator ^(const S1&);
26 template <typename T>
27 class S7 : public T {
28 protected:
29 T a;
30 T b[100];
31 S7() : a(0) {}
33 public:
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)
37 ++this->a.a;
38 #pragma omp parallel master firstprivate(a) firstprivate(this->a) firstprivate(T::a)
39 for (int k = 0; k < a.a; ++k)
40 ++this->a.a;
41 #pragma omp parallel master shared(a) shared(this->a) shared(T::a)
42 for (int k = 0; k < a.a; ++k)
43 ++this->a.a;
44 #pragma omp parallel master reduction(+ : a) reduction(*: b[:])
45 for (int k = 0; k < a.a; ++k)
46 ++this->a.a;
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)
51 ++s.a.a;
52 #pragma omp parallel master firstprivate(a) firstprivate(this->a)
53 for (int k = 0; k < s.a.a; ++k)
54 ++s.a.a;
55 #pragma omp parallel master shared(a) shared(this->a)
56 for (int k = 0; k < s.a.a; ++k)
57 ++s.a.a;
58 #pragma omp parallel master reduction(&& : this->a) reduction(^: b[s.a.a])
59 for (int k = 0; k < s.a.a; ++k)
60 ++s.a.a;
61 return *this;
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> {
79 S8() {}
81 public:
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)
85 ++this->a.a;
86 #pragma omp parallel master firstprivate(a) firstprivate(this->a) firstprivate(S7 < S1 > ::a)
87 for (int k = 0; k < a.a; ++k)
88 ++this->a.a;
89 #pragma omp parallel master shared(a) shared(this->a) shared(S7 < S1 > ::a)
90 for (int k = 0; k < a.a; ++k)
91 ++this->a.a;
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)
94 ++this->a.a;
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)
99 ++s.a.a;
100 #pragma omp parallel master firstprivate(a) firstprivate(this->a)
101 for (int k = 0; k < s.a.a; ++k)
102 ++s.a.a;
103 #pragma omp parallel master shared(a) shared(this->a)
104 for (int k = 0; k < s.a.a; ++k)
105 ++s.a.a;
106 #pragma omp parallel master reduction(* : this->a) reduction(&&:this->b[a.a:])
107 for (int k = 0; k < s.a.a; ++k)
108 ++s.a.a;
109 return *this;
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:])
122 template <class T>
123 struct S {
124 operator T() {return T();}
125 static T TS;
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)
132 // CHECK: };
133 // CHECK: template<> struct S<int> {
134 // CHECK: static int TS;
135 // CHECK-NEXT: #pragma omp threadprivate(S<int>::TS)
136 // CHECK-NEXT: }
137 // CHECK: template<> struct S<long> {
138 // CHECK: static long TS;
139 // CHECK-NEXT: #pragma omp threadprivate(S<long>::TS)
140 // CHECK-NEXT: }
142 int thrp;
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;
148 static T a;
149 S<T> s;
150 T arr[C][10], arr1[C];
151 #pragma omp parallel master
152 a=2;
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])
154 foo();
155 #pragma omp parallel master if (C) num_threads(s) proc_bind(close) reduction(^:e, f, arr[0:C][:argc]) reduction(task, && : g)
156 foo();
157 return 0;
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])
168 // CHECK-NEXT: foo()
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)
170 // CHECK-NEXT: foo()
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])
179 // CHECK-NEXT: foo()
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)
181 // CHECK-NEXT: foo()
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])
190 // CHECK-NEXT: foo()
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)
192 // CHECK-NEXT: foo()
194 enum Enum { };
196 int main (int argc, char **argv) {
197 long x;
198 int b = argc, c, d, e, f, g;
199 static int a;
200 #pragma omp threadprivate(a)
201 int arr[10][argc], arr1[2];
202 Enum ee;
203 // CHECK: Enum ee;
204 #pragma omp parallel master
205 // CHECK-NEXT: #pragma omp parallel master
206 a=2;
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)
210 foo();
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])
213 // CHECK-NEXT: foo()
214 #pragma omp parallel master allocate(e) if (b) num_threads(c) proc_bind(close) reduction(^:e, f) reduction(&& : g, arr[0:argc][:10])
215 foo();
216 return tmain<int, 5>(b, &b) + tmain<long, 1>(x, &x);
219 template<typename T>
220 T S<T>::TS = 0;
222 #endif