1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
5 extern int omp_default_mem_alloc
;
9 bool foobool(int argc
) {
13 struct S1
; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}}
20 S2(const S2
&s2
) : a(s2
.a
) {}
22 static const float S2sc
;
24 const float S2::S2sc
= 0;
29 S3
&operator=(const S3
&s3
);
33 S3(const S3
&s3
) : a(s3
.a
) {}
41 S4(const S4
&s4
); // expected-note 2 {{implicitly declared private here}}
48 S5(const S5
&s5
) : a(s5
.a
) {} // expected-note 4 {{implicitly declared private here}}
59 S6(const S6
&s6
) : a(s6
.a
) {}
64 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
66 template <class I
, class C
>
67 int foomain(int argc
, char **argv
) {
73 #pragma omp for simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}
74 for (int k
= 0; k
< argc
; ++k
)
77 #pragma omp for simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
78 for (int k
= 0; k
< argc
; ++k
)
81 #pragma omp for simd firstprivate() // expected-error {{expected expression}}
82 for (int k
= 0; k
< argc
; ++k
)
85 #pragma omp for simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
86 for (int k
= 0; k
< argc
; ++k
)
89 #pragma omp for simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
90 for (int k
= 0; k
< argc
; ++k
)
93 #pragma omp for simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
94 for (int k
= 0; k
< argc
; ++k
)
97 #pragma omp for simd firstprivate(argc) allocate , allocate(, allocate(omp_default , allocate(omp_default_mem_alloc, allocate(omp_default_mem_alloc:, allocate(omp_default_mem_alloc: argc, allocate(omp_default_mem_alloc: argv), allocate(argv) // expected-error {{expected '(' after 'allocate'}} expected-error 2 {{expected expression}} expected-error 2 {{expected ')'}} expected-error {{use of undeclared identifier 'omp_default'}} expected-note 2 {{to match this '('}}
98 for (int k
= 0; k
< argc
; ++k
)
101 #pragma omp for simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
102 for (int k
= 0; k
< argc
; ++k
)
105 #pragma omp for simd firstprivate(a, b) // expected-error {{a firstprivate variable with incomplete type 'S1'}}
106 for (int k
= 0; k
< argc
; ++k
)
109 #pragma omp for simd firstprivate(argv[1]) // expected-error {{expected variable name}}
110 for (int k
= 0; k
< argc
; ++k
)
113 #pragma omp for simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
114 for (int k
= 0; k
< argc
; ++k
)
117 #pragma omp for simd firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
118 for (int k
= 0; k
< argc
; ++k
)
121 #pragma omp for simd linear(i)
122 for (int k
= 0; k
< argc
; ++k
)
127 int i
; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for simd' directive into a parallel or another task region?}}
128 #pragma omp for simd firstprivate(i) // expected-error {{firstprivate variable must be shared}}
129 for (int k
= 0; k
< argc
; ++k
) {
134 #pragma omp parallel shared(i)
135 #pragma omp parallel private(i)
136 #pragma omp for simd firstprivate(j)
137 for (int k
= 0; k
< argc
; ++k
)
140 #pragma omp for simd firstprivate(i)
141 for (int k
= 0; k
< argc
; ++k
)
144 #pragma omp for simd lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
145 for (i
= 0; i
< argc
; ++i
)
147 #pragma omp parallel private(i) // expected-note {{defined as private}}
148 #pragma omp for simd firstprivate(i) // expected-error {{firstprivate variable must be shared}}
149 for (i
= 0; i
< argc
; ++i
)
151 #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
152 #pragma omp for simd firstprivate(i) // expected-error {{firstprivate variable must be shared}}
153 for (int k
= 0; k
< argc
; ++k
)
160 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
166 int main(int argc
, char **argv
) {
168 const int da
[5] = {0};
176 #pragma omp for simd firstprivate // expected-error {{expected '(' after 'firstprivate'}}
177 for (i
= 0; i
< argc
; ++i
)
180 #pragma omp for simd firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
181 for (i
= 0; i
< argc
; ++i
)
184 #pragma omp for simd firstprivate() // expected-error {{expected expression}}
185 for (i
= 0; i
< argc
; ++i
)
188 #pragma omp for simd firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
189 for (i
= 0; i
< argc
; ++i
)
192 #pragma omp for simd firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
193 for (i
= 0; i
< argc
; ++i
)
196 #pragma omp for simd firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
197 for (i
= 0; i
< argc
; ++i
)
200 #pragma omp for simd firstprivate(argc)
201 for (i
= 0; i
< argc
; ++i
)
204 #pragma omp for simd firstprivate(S1) // expected-error {{'S1' does not refer to a value}}
205 for (i
= 0; i
< argc
; ++i
)
208 #pragma omp for simd firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}}
209 for (i
= 0; i
< argc
; ++i
)
212 #pragma omp for simd firstprivate(argv[1]) // expected-error {{expected variable name}}
213 for (i
= 0; i
< argc
; ++i
)
216 #pragma omp for simd firstprivate(2 * 2) // expected-error {{expected variable name}}
217 for (i
= 0; i
< argc
; ++i
)
220 #pragma omp for simd firstprivate(ba) // OK
221 for (i
= 0; i
< argc
; ++i
)
224 #pragma omp for simd firstprivate(ca) // OK
225 for (i
= 0; i
< argc
; ++i
)
228 #pragma omp for simd firstprivate(da) // OK
229 for (i
= 0; i
< argc
; ++i
)
233 #pragma omp for simd firstprivate(xa) // OK
234 for (i
= 0; i
< argc
; ++i
)
237 #pragma omp for simd firstprivate(S2::S2s) // OK
238 for (i
= 0; i
< argc
; ++i
)
241 #pragma omp for simd firstprivate(S2::S2sc) // OK
242 for (i
= 0; i
< argc
; ++i
)
245 #pragma omp for simd safelen(5)
246 for (i
= 0; i
< argc
; ++i
)
249 #pragma omp for simd firstprivate(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
250 for (i
= 0; i
< argc
; ++i
)
253 #pragma omp for simd firstprivate(m) // OK
254 for (i
= 0; i
< argc
; ++i
)
257 #pragma omp for simd firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
258 for (i
= 0; i
< argc
; ++i
)
261 #pragma omp for simd firstprivate(B::x) // expected-error {{threadprivate or thread local variable cannot be firstprivate}}
262 for (i
= 0; i
< argc
; ++i
)
265 #pragma omp for simd private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}}
266 for (i
= 0; i
< argc
; ++i
)
269 #pragma omp for simd firstprivate(i) // expected-note {{defined as firstprivate}}
270 for (i
= 0; i
< argc
; ++i
) // expected-error {{loop iteration variable in the associated loop of 'omp for simd' directive may not be firstprivate, predetermined as linear}}
272 #pragma omp parallel shared(xa)
273 #pragma omp for simd firstprivate(xa) // OK: may be firstprivate
274 for (i
= 0; i
< argc
; ++i
)
277 #pragma omp for simd firstprivate(j)
278 for (i
= 0; i
< argc
; ++i
)
281 #pragma omp for simd lastprivate(g) firstprivate(g) // expected-error {{calling a private constructor of class 'S5'}}
282 for (i
= 0; i
< argc
; ++i
)
285 #pragma omp for simd lastprivate(n) firstprivate(n) // OK
286 for (i
= 0; i
< argc
; ++i
)
291 int i
; // expected-note {{variable with automatic storage duration is predetermined as private; perhaps you forget to enclose 'omp for simd' directive into a parallel or another task region?}}
292 #pragma omp for simd firstprivate(i) // expected-error {{firstprivate variable must be shared}}
293 for (int k
= 0; k
< argc
; ++k
) {
298 #pragma omp parallel private(i) // expected-note {{defined as private}}
299 #pragma omp for simd firstprivate(i) // expected-error {{firstprivate variable must be shared}}
300 for (i
= 0; i
< argc
; ++i
)
302 #pragma omp parallel reduction(+ : i) // expected-note {{defined as reduction}}
303 #pragma omp for simd firstprivate(i) // expected-error {{firstprivate variable must be shared}}
304 for (i
= 0; i
< argc
; ++i
)
307 #pragma omp for simd firstprivate(si)
308 for (i
= 0; i
< argc
; ++i
)
311 return foomain
<S4
, S5
>(argc
, argv
); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}}