[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / single_ast_print.cpp
blob4c77da8d137a2151153681e0059d1cd6e09c7ecc
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
10 #ifndef HEADER
11 #define HEADER
13 void foo() {}
15 struct SS {
16 int a;
17 int b : 4;
18 int &c;
19 SS(int &d) : a(0), b(0), c(d) {
20 #pragma omp parallel firstprivate(a, b, c)
21 #pragma omp single copyprivate(a, this->b, (this)->c)
22 // CHECK: #pragma omp parallel firstprivate(this->a,this->b,this->c)
23 // CHECK-NEXT: #pragma omp single copyprivate(this->a,this->b,this->c){{$}}
24 ++this->a, --b, (this)->c /= 1;
28 template<typename T>
29 struct SST {
30 T a;
31 SST() : a(T()) {
32 // CHECK: #pragma omp parallel firstprivate(this->a)
33 // CHECK-NEXT: #pragma omp single copyprivate(this->a)
34 // CHECK: #pragma omp parallel firstprivate(this->a)
35 // CHECK-NEXT: #pragma omp single copyprivate(this->a)
36 #pragma omp parallel firstprivate(a)
37 #pragma omp single copyprivate(this->a)
38 ++this->a;
42 template <class T, int N>
43 T tmain(T argc) {
44 T b = argc, c, d, e, f, g;
45 static T a;
46 SST<T> sst;
47 // CHECK: static T a;
48 #pragma omp parallel private(g)
49 #pragma omp single private(argc, b), firstprivate(c, d), nowait allocate(d)
50 foo();
51 // CHECK: #pragma omp parallel private(g)
52 // CHECK-NEXT: #pragma omp single private(argc,b) firstprivate(c,d) nowait allocate(d)
53 // CHECK-NEXT: foo();
54 #pragma omp parallel private(g)
55 #pragma omp single allocate(argc) private(argc, b), firstprivate(c, d), copyprivate(g)
56 foo();
57 // CHECK-NEXT: #pragma omp parallel private(g)
58 // CHECK-NEXT: #pragma omp single allocate(argc) private(argc,b) firstprivate(c,d) copyprivate(g)
59 // CHECK-NEXT: foo();
60 return T();
63 int main(int argc, char **argv) {
64 // CHECK: int main(int argc, char **argv) {
65 int b = argc, c, d, e, f, g;
66 static int a;
67 SS ss(a);
68 // CHECK: static int a;
69 #pragma omp parallel private(g)
70 #pragma omp single private(argc, b), firstprivate(argv, c), nowait
71 foo();
72 // CHECK: #pragma omp parallel private(g)
73 // CHECK-NEXT: #pragma omp single private(argc,b) firstprivate(argv,c) nowait
74 // CHECK-NEXT: foo();
75 #pragma omp parallel private(g)
76 #pragma omp single private(argc, b), firstprivate(c, d), copyprivate(g)
77 foo();
78 // CHECK-NEXT: #pragma omp parallel private(g)
79 // CHECK-NEXT: #pragma omp single private(argc,b) firstprivate(c,d) copyprivate(g)
80 // CHECK-NEXT: foo();
81 return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0]));
84 #endif