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 -fsyntax-only -verify %s -ast-print | FileCheck %s
4 // expected-no-diagnostics
5
6 #ifndef HEADER
7 #define HEADER
8
foo()9 void foo() {}
10
11 struct SS {
12 int a;
13 int b : 4;
14 int &c;
SSSS15 SS(int &d) : a(0), b(0), c(d) {
16 #pragma omp parallel firstprivate(a, b, c)
17 #pragma omp single copyprivate(a, this->b, (this)->c)
18 // CHECK: #pragma omp parallel firstprivate(this->a,this->b,this->c)
19 // CHECK-NEXT: #pragma omp single copyprivate(this->a,this->b,this->c)
20 ++this->a, --b, (this)->c /= 1;
21 }
22 };
23
24 template<typename T>
25 struct SST {
26 T a;
SSTSST27 SST() : a(T()) {
28 // CHECK: #pragma omp parallel firstprivate(this->a)
29 // CHECK-NEXT: #pragma omp single copyprivate(this->a)
30 // CHECK: #pragma omp parallel firstprivate(this->a)
31 // CHECK-NEXT: #pragma omp single copyprivate(this->a)
32 #pragma omp parallel firstprivate(a)
33 #pragma omp single copyprivate(this->a)
34 ++this->a;
35 }
36 };
37
38 template <class T, int N>
tmain(T argc)39 T tmain(T argc) {
40 T b = argc, c, d, e, f, g;
41 static T a;
42 SST<T> sst;
43 // CHECK: static T a;
44 #pragma omp parallel private(g)
45 #pragma omp single private(argc, b), firstprivate(c, d), nowait
46 foo();
47 // CHECK: #pragma omp parallel private(g)
48 // CHECK-NEXT: #pragma omp single private(argc,b) firstprivate(c,d) nowait
49 // CHECK-NEXT: foo();
50 #pragma omp parallel private(g)
51 #pragma omp single private(argc, b), firstprivate(c, d), copyprivate(g)
52 foo();
53 // CHECK-NEXT: #pragma omp parallel private(g)
54 // CHECK-NEXT: #pragma omp single private(argc,b) firstprivate(c,d) copyprivate(g)
55 // CHECK-NEXT: foo();
56 return T();
57 }
58
main(int argc,char ** argv)59 int main(int argc, char **argv) {
60 int b = argc, c, d, e, f, g;
61 static int a;
62 SS ss(a);
63 // CHECK: static int a;
64 #pragma omp parallel private(g)
65 #pragma omp single private(argc, b), firstprivate(argv, c), nowait
66 foo();
67 // CHECK: #pragma omp parallel private(g)
68 // CHECK-NEXT: #pragma omp single private(argc,b) firstprivate(argv,c) nowait
69 // CHECK-NEXT: foo();
70 #pragma omp parallel private(g)
71 #pragma omp single private(argc, b), firstprivate(c, d), copyprivate(g)
72 foo();
73 // CHECK-NEXT: #pragma omp parallel private(g)
74 // CHECK-NEXT: #pragma omp single private(argc,b) firstprivate(c,d) copyprivate(g)
75 // CHECK-NEXT: foo();
76 return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0]));
77 }
78
79 #endif
80