]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/OpenMP/single_copyprivate_messages.cpp
Vendor import of clang trunk r338150:
[FreeBSD/FreeBSD.git] / test / OpenMP / single_copyprivate_messages.cpp
1 // RUN: %clang_cc1 -verify -fopenmp %s
2
3 // RUN: %clang_cc1 -verify -fopenmp-simd %s
4
5 void foo() {
6 }
7
8 struct S1; // expected-note 2 {{declared here}}
9 class S2 {
10   mutable int a;
11
12 public:
13   S2() : a(0) {}
14   S2 &operator=(S2 &s2) { return *this; }
15 };
16 class S3 {
17   int a;
18
19 public:
20   S3() : a(0) {}
21   S3 &operator=(S3 &s3) { return *this; }
22 };
23 class S4 {
24   int a;
25   S4();
26   S4 &operator=(const S4 &s4); // expected-note 3 {{implicitly declared private here}}
27
28 public:
29   S4(int v) : a(v) {}
30 };
31 class S5 {
32   int a;
33   S5() : a(0) {}
34   S5 &operator=(const S5 &s5) { return *this; } // expected-note 3 {{implicitly declared private here}}
35
36 public:
37   S5(int v) : a(v) {}
38 };
39
40 S2 k;
41 S3 h;
42 S4 l(3);
43 S5 m(4);
44 #pragma omp threadprivate(h, k, l, m)
45
46 template <class T, class C>
47 T tmain(T argc, C **argv) {
48   T i;
49   static T TA;
50 #pragma omp parallel
51 #pragma omp single copyprivate // expected-error {{expected '(' after 'copyprivate'}}
52 #pragma omp parallel
53 #pragma omp single copyprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
54 #pragma omp parallel
55 #pragma omp single copyprivate() // expected-error {{expected expression}}
56 #pragma omp parallel
57 #pragma omp single copyprivate(k // expected-error {{expected ')'}} expected-note {{to match this '('}}
58 #pragma omp parallel
59 #pragma omp single copyprivate(h, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
60 #pragma omp parallel
61 #pragma omp single copyprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
62 #pragma omp parallel
63 #pragma omp single copyprivate(l) // expected-error 2 {{'operator=' is a private member of 'S4'}}
64 #pragma omp parallel
65 #pragma omp single copyprivate(S1) // expected-error {{'S1' does not refer to a value}}
66 #pragma omp parallel
67 #pragma omp single copyprivate(argv[1]) // expected-error {{expected variable name}}
68 #pragma omp parallel // expected-note {{implicitly determined as shared}}
69 #pragma omp single copyprivate(i) // expected-error {{copyprivate variable must be threadprivate or private in the enclosing context}}
70 #pragma omp parallel
71 #pragma omp single copyprivate(m) // expected-error 2 {{'operator=' is a private member of 'S5'}}
72   foo();
73 #pragma omp parallel private(i)
74   {
75 #pragma omp single copyprivate(i)
76     foo();
77   }
78 #pragma omp parallel shared(i) // expected-note {{defined as shared}}
79   {
80 #pragma omp single copyprivate(i) // expected-error {{copyprivate variable must be threadprivate or private in the enclosing context}}
81     foo();
82   }
83 #pragma omp parallel private(i)
84 #pragma omp parallel default(shared) // expected-note {{implicitly determined as shared}}
85   {
86 #pragma omp single copyprivate(i) // expected-error {{copyprivate variable must be threadprivate or private in the enclosing context}}
87     foo();
88   }
89 #pragma omp parallel private(i)
90 #pragma omp parallel // expected-note {{implicitly determined as shared}}
91   {
92 #pragma omp single copyprivate(i) // expected-error {{copyprivate variable must be threadprivate or private in the enclosing context}}
93     foo();
94   }
95 #pragma omp parallel
96 #pragma omp single private(i) copyprivate(i) // expected-error {{private variable cannot be copyprivate}} expected-note {{defined as private}}
97   foo();
98 #pragma omp parallel
99 #pragma omp single firstprivate(i) copyprivate(i) // expected-error {{firstprivate variable cannot be copyprivate}} expected-note {{defined as firstprivate}}
100   foo();
101 #pragma omp parallel private(TA)
102   {
103 #pragma omp single copyprivate(TA)
104     TA = 99;
105   }
106
107   return T();
108 }
109
110 void bar(S4 a[2], int n, int b[n]) {
111 #pragma omp single copyprivate(a, b)
112     foo();
113 }
114
115 namespace A {
116 double x;
117 #pragma omp threadprivate(x)
118 }
119 namespace B {
120 using A::x;
121 }
122
123 int main(int argc, char **argv) {
124   int i;
125   static int intA;
126 #pragma omp parallel
127 #pragma omp single copyprivate // expected-error {{expected '(' after 'copyprivate'}}
128 #pragma omp parallel
129 #pragma omp single copyprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
130 #pragma omp parallel
131 #pragma omp single copyprivate() // expected-error {{expected expression}}
132 #pragma omp parallel
133 #pragma omp single copyprivate(k // expected-error {{expected ')'}} expected-note {{to match this '('}}
134 #pragma omp parallel
135 #pragma omp single copyprivate(h, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
136 #pragma omp parallel
137 #pragma omp single copyprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
138 #pragma omp parallel
139 #pragma omp single copyprivate(l, B::x) // expected-error {{'operator=' is a private member of 'S4'}}
140 #pragma omp parallel
141 #pragma omp single copyprivate(S1) // expected-error {{'S1' does not refer to a value}}
142 #pragma omp parallel
143 #pragma omp single copyprivate(argv[1]) // expected-error {{expected variable name}}
144 #pragma omp parallel // expected-note {{implicitly determined as shared}}
145 #pragma omp single copyprivate(i) // expected-error {{copyprivate variable must be threadprivate or private in the enclosing context}}
146 #pragma omp parallel
147 #pragma omp single copyprivate(m) // expected-error {{'operator=' is a private member of 'S5'}}
148   foo();
149 #pragma omp parallel private(i)
150   {
151 #pragma omp single copyprivate(i)
152     foo();
153   }
154 #pragma omp parallel shared(i) // expected-note {{defined as shared}}
155   {
156 #pragma omp single copyprivate(i) // expected-error {{copyprivate variable must be threadprivate or private in the enclosing context}}
157     foo();
158   }
159 #pragma omp parallel private(i)
160 #pragma omp parallel default(shared) // expected-note {{implicitly determined as shared}}
161   {
162 #pragma omp single copyprivate(i) // expected-error {{copyprivate variable must be threadprivate or private in the enclosing context}}
163     foo();
164   }
165 #pragma omp parallel private(i)
166 #pragma omp parallel // expected-note {{implicitly determined as shared}}
167   {
168 #pragma omp single copyprivate(i) // expected-error {{copyprivate variable must be threadprivate or private in the enclosing context}}
169     foo();
170   }
171 #pragma omp parallel
172 #pragma omp single private(i) copyprivate(i) // expected-error {{private variable cannot be copyprivate}} expected-note {{defined as private}}
173   foo();
174 #pragma omp parallel
175 #pragma omp single firstprivate(i) copyprivate(i) // expected-error {{firstprivate variable cannot be copyprivate}} expected-note {{defined as firstprivate}}
176   foo();
177 #pragma omp single copyprivate(i) nowait // expected-error {{the 'copyprivate' clause must not be used with the 'nowait' clause}} expected-note {{'nowait' clause is here}}
178   foo();
179 #pragma omp parallel private(intA)
180   {
181 #pragma omp single copyprivate(intA)
182     intA = 99;
183   }
184
185   return tmain(argc, argv); // expected-note {{in instantiation of function template specialization 'tmain<int, char>' requested here}}
186 }
187
188 extern void abort(void);
189
190 void
191 single(int a, int b) {
192 #pragma omp single copyprivate(a) copyprivate(b)
193   {
194     a = b = 5;
195   }
196
197   if (a != b)
198     abort();
199 }
200
201 int parallel() {
202 #pragma omp parallel
203   single(1, 2);
204
205   return 0;
206 }