blob: 99dd68f3cbfab25ea810b7dbf68b3ba65027ed03 [file] [log] [blame]
Stephen Hinesef822542014-07-21 00:47:37 -07001// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
2
3void foo() {
4}
5
6bool foobool(int argc) {
7 return argc;
8}
9
10struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
11extern S1 a;
12class S2 {
13 mutable int a;
14
15public:
16 S2() : a(0) {}
17 S2(S2 &s2) : a(s2.a) {}
18 static float S2s;
19 static const float S2sc;
20};
21const float S2::S2sc = 0;
22const S2 b;
23const S2 ba[5];
24class S3 {
25 int a;
26 S3 &operator=(const S3 &s3);
27
28public:
29 S3() : a(0) {}
30 S3(S3 &s3) : a(s3.a) {}
31};
32const S3 c;
33const S3 ca[5];
34extern const int f;
35class S4 { // expected-note 2 {{'S4' declared here}}
36 int a;
37 S4();
38 S4(const S4 &s4);
39
40public:
41 S4(int v) : a(v) {}
42};
43class S5 { // expected-note 4 {{'S5' declared here}}
44 int a;
45 S5(const S5 &s5) : a(s5.a) {}
46
47public:
48 S5() : a(0) {}
49 S5(int v) : a(v) {}
50};
51class S6 {
52 int a;
53 S6() : a(0) {}
54
55public:
56 S6(const S6 &s6) : a(s6.a) {}
57 S6(int v) : a(v) {}
58};
59
60S3 h;
61#pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
62
63template <class I, class C>
64int foomain(int argc, char **argv) {
65 I e(4); // expected-note {{'e' defined here}}
66 C g(5); // expected-note 2 {{'g' defined here}}
67 int i;
68 int &j = i; // expected-note {{'j' defined here}}
69#pragma omp parallel for firstprivate // expected-error {{expected '(' after 'firstprivate'}}
70 for (int k = 0; k < argc; ++k)
71 ++k;
72#pragma omp parallel for firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
73 for (int k = 0; k < argc; ++k)
74 ++k;
75#pragma omp parallel for firstprivate() // expected-error {{expected expression}}
76 for (int k = 0; k < argc; ++k)
77 ++k;
78#pragma omp parallel for firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
79 for (int k = 0; k < argc; ++k)
80 ++k;
81#pragma omp parallel for firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
82 for (int k = 0; k < argc; ++k)
83 ++k;
84#pragma omp parallel for firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
85 for (int k = 0; k < argc; ++k)
86 ++k;
87#pragma omp parallel for firstprivate(argc)
88 for (int k = 0; k < argc; ++k)
89 ++k;
90#pragma omp parallel for firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
91 for (int k = 0; k < argc; ++k)
92 ++k;
93#pragma omp parallel for firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}}
94 for (int k = 0; k < argc; ++k)
95 ++k;
96#pragma omp parallel for firstprivate(argv[1]) // expected-error {{expected variable name}}
97 for (int k = 0; k < argc; ++k)
98 ++k;
99#pragma omp parallel for firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}}
100 for (int k = 0; k < argc; ++k)
101 ++k;
102#pragma omp parallel for firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
103 for (int k = 0; k < argc; ++k)
104 ++k;
105#pragma omp parallel for linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp parallel for'}}
106 for (int k = 0; k < argc; ++k)
107 ++k;
108#pragma omp parallel
109 {
110 int v = 0;
111 int i;
112#pragma omp parallel for firstprivate(i)
113 for (int k = 0; k < argc; ++k) {
114 i = k;
115 v += i;
116 }
117 }
118#pragma omp parallel shared(i)
119#pragma omp parallel private(i)
120#pragma omp parallel for firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}}
121 for (int k = 0; k < argc; ++k)
122 ++k;
123#pragma omp parallel for firstprivate(i)
124 for (int k = 0; k < argc; ++k)
125 ++k;
126#pragma omp parallel for lastprivate(g) firstprivate(g) // expected-error {{firstprivate variable must have an accessible, unambiguous copy constructor}}
127 for (i = 0; i < argc; ++i)
128 foo();
129#pragma omp parallel private(i)
130#pragma omp parallel for firstprivate(i) // expected-note {{defined as firstprivate}}
131 for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be firstprivate, predetermined as private}}
132 foo();
133#pragma omp parallel reduction(+ : i)
134#pragma omp parallel for firstprivate(i) // expected-note {{defined as firstprivate}}
135 for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be firstprivate, predetermined as private}}
136 foo();
137 return 0;
138}
139
140int main(int argc, char **argv) {
141 const int d = 5;
142 const int da[5] = {0};
143 S4 e(4); // expected-note {{'e' defined here}}
144 S5 g(5); // expected-note 2 {{'g' defined here}}
145 S3 m;
146 S6 n(2);
147 int i;
148 int &j = i; // expected-note {{'j' defined here}}
149#pragma omp parallel for firstprivate // expected-error {{expected '(' after 'firstprivate'}}
150 for (i = 0; i < argc; ++i)
151 foo();
152#pragma omp parallel for firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
153 for (i = 0; i < argc; ++i)
154 foo();
155#pragma omp parallel for firstprivate() // expected-error {{expected expression}}
156 for (i = 0; i < argc; ++i)
157 foo();
158#pragma omp parallel for firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
159 for (i = 0; i < argc; ++i)
160 foo();
161#pragma omp parallel for firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
162 for (i = 0; i < argc; ++i)
163 foo();
164#pragma omp parallel for firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
165 for (i = 0; i < argc; ++i)
166 foo();
167#pragma omp parallel for firstprivate(argc)
168 for (i = 0; i < argc; ++i)
169 foo();
170#pragma omp parallel for firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
171 for (i = 0; i < argc; ++i)
172 foo();
173#pragma omp parallel for firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
174 for (i = 0; i < argc; ++i)
175 foo();
176#pragma omp parallel for firstprivate(argv[1]) // expected-error {{expected variable name}}
177 for (i = 0; i < argc; ++i)
178 foo();
179#pragma omp parallel for firstprivate(2 * 2) // expected-error {{expected variable name}}
180 for (i = 0; i < argc; ++i)
181 foo();
182#pragma omp parallel for firstprivate(ba) // OK
183 for (i = 0; i < argc; ++i)
184 foo();
185#pragma omp parallel for firstprivate(ca) // OK
186 for (i = 0; i < argc; ++i)
187 foo();
188#pragma omp parallel for firstprivate(da) // OK
189 for (i = 0; i < argc; ++i)
190 foo();
191 int xa;
192#pragma omp parallel for firstprivate(xa) // OK
193 for (i = 0; i < argc; ++i)
194 foo();
195#pragma omp parallel for firstprivate(S2::S2s) // OK
196 for (i = 0; i < argc; ++i)
197 foo();
198#pragma omp parallel for firstprivate(S2::S2sc) // OK
199 for (i = 0; i < argc; ++i)
200 foo();
201#pragma omp parallel for safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp parallel for'}}
202 for (i = 0; i < argc; ++i)
203 foo();
204#pragma omp parallel for firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}}
205 for (i = 0; i < argc; ++i)
206 foo();
207#pragma omp parallel for firstprivate(m) // OK
208 for (i = 0; i < argc; ++i)
209 foo();
210#pragma omp parallel for firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
211 for (i = 0; i < argc; ++i)
212 foo();
213#pragma omp parallel for private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
214 for (i = 0; i < argc; ++i)
215 foo();
216#pragma omp parallel for firstprivate(i) // expected-note {{defined as firstprivate}}
217 for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be firstprivate, predetermined as private}}
218 foo();
219#pragma omp parallel shared(xa)
220#pragma omp parallel for firstprivate(xa) // OK: may be firstprivate
221 for (i = 0; i < argc; ++i)
222 foo();
223#pragma omp parallel for firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}}
224 for (i = 0; i < argc; ++i)
225 foo();
226#pragma omp parallel for lastprivate(g) firstprivate(g) // expected-error {{firstprivate variable must have an accessible, unambiguous copy constructor}}
227 for (i = 0; i < argc; ++i)
228 foo();
229#pragma omp parallel for lastprivate(n) firstprivate(n) // OK
230 for (i = 0; i < argc; ++i)
231 foo();
232#pragma omp parallel
233 {
234 int v = 0;
235 int i;
236#pragma omp parallel for firstprivate(i)
237 for (int k = 0; k < argc; ++k) {
238 i = k;
239 v += i;
240 }
241 }
242#pragma omp parallel private(i)
243#pragma omp parallel for firstprivate(i) // expected-note {{defined as firstprivate}}
244 for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be firstprivate, predetermined as private}}
245 foo();
246#pragma omp parallel reduction(+ : i)
247#pragma omp parallel for firstprivate(i) // expected-note {{defined as firstprivate}}
248 for (i = 0; i < argc; ++i) // expected-error {{loop iteration variable in the associated loop of 'omp parallel for' directive may not be firstprivate, predetermined as private}}
249 foo();
250
251 return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}
252}