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