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'}}
32 S4(); // expected-note {{implicitly declared private here}}
36 #pragma omp for private(a) private(this->a)
37 for (int k
= 0; k
< v
; ++k
)
43 S5() : a(0) {} // expected-note {{implicitly declared private here}}
47 S5
&operator=(S5
&s
) {
48 #pragma omp for private(a) private(this->a) private(s.a) // expected-error {{expected variable name or data member of current class}}
49 for (int k
= 0; k
< s
.a
; ++k
)
62 #pragma omp for private(a) private(this->a)
63 for (int k
= 0; k
< v
; ++k
)
66 S6
&operator=(S6
&s
) {
67 #pragma omp for private(a) private(this->a) private(s.a) // expected-error {{expected variable name or data member of current class}}
68 for (int k
= 0; k
< s
.a
; ++k
)
81 #pragma omp for private(a) private(this->a) private(T::a)
82 for (int k
= 0; k
< a
.a
; ++k
)
85 S7
&operator=(S7
&s
) {
86 #pragma omp for private(a) private(this->a) private(s.a) private(s.T::a) // expected-error 2 {{expected variable name or data member of current class}}
87 for (int k
= 0; k
< s
.a
.a
; ++k
)
94 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
96 template <class I
, class C
>
97 int foomain(I argc
, C
**argv
) {
102 #pragma omp for private // expected-error {{expected '(' after 'private'}}
103 for (int k
= 0; k
< argc
; ++k
)
105 #pragma omp for private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
106 for (int k
= 0; k
< argc
; ++k
)
108 #pragma omp for private() // expected-error {{expected expression}}
109 for (int k
= 0; k
< argc
; ++k
)
111 #pragma omp for private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
112 for (int k
= 0; k
< argc
; ++k
)
114 #pragma omp for private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
115 for (int k
= 0; k
< argc
; ++k
)
117 #pragma omp for private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
118 for (int k
= 0; k
< argc
; ++k
)
120 #pragma omp for private(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 '('}}
121 for (int k
= 0; k
< argc
; ++k
)
123 #pragma omp for private(S1) // expected-error {{'S1' does not refer to a value}}
124 for (int k
= 0; k
< argc
; ++k
)
126 #pragma omp for private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
127 for (int k
= 0; k
< argc
; ++k
)
129 #pragma omp for private(argv[1]) // expected-error {{expected variable name}}
130 for (int k
= 0; k
< argc
; ++k
)
132 #pragma omp for private(e, g)
133 for (int k
= 0; k
< argc
; ++k
)
135 #pragma omp for private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
136 for (int k
= 0; k
< argc
; ++k
)
138 #pragma omp for shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp for'}}
139 for (int k
= 0; k
< argc
; ++k
)
145 #pragma omp for private(i)
146 for (int k
= 0; k
< argc
; ++k
) {
151 #pragma omp parallel shared(i)
152 #pragma omp parallel private(i)
153 #pragma omp for private(j)
154 for (int k
= 0; k
< argc
; ++k
)
156 #pragma omp for private(i)
157 for (int k
= 0; k
< argc
; ++k
)
164 #pragma omp for private(a)
165 for (int i
= 0; i
< 2; ++i
)
171 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}}
177 int main(int argc
, char **argv
) {
180 S6
<float> s6(0.0) , s6_0(1.0);
181 S7
<S6
<float> > s7(0.0) , s7_0(1.0);
184 #pragma omp for private // expected-error {{expected '(' after 'private'}}
185 for (int k
= 0; k
< argc
; ++k
)
187 #pragma omp for private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
188 for (int k
= 0; k
< argc
; ++k
)
190 #pragma omp for private() // expected-error {{expected expression}}
191 for (int k
= 0; k
< argc
; ++k
)
193 #pragma omp for private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
194 for (int k
= 0; k
< argc
; ++k
)
196 #pragma omp for private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
197 for (int k
= 0; k
< argc
; ++k
)
199 #pragma omp for private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
200 for (int k
= 0; k
< argc
; ++k
)
202 #pragma omp for private(argc)
203 for (int k
= 0; k
< argc
; ++k
)
205 #pragma omp for private(S1) // expected-error {{'S1' does not refer to a value}}
206 for (int k
= 0; k
< argc
; ++k
)
208 #pragma omp for private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
209 for (int k
= 0; k
< argc
; ++k
)
211 #pragma omp for private(argv[1]) // expected-error {{expected variable name}}
212 for (int k
= 0; k
< argc
; ++k
)
214 #pragma omp for private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
215 for (int k
= 0; k
< argc
; ++k
)
217 #pragma omp for private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
218 for (int k
= 0; k
< argc
; ++k
)
220 #pragma omp for private(B::x) // expected-error {{threadprivate or thread local variable cannot be private}}
221 for (int k
= 0; k
< argc
; ++k
)
223 #pragma omp for shared(i) // expected-error {{unexpected OpenMP clause 'shared' in directive '#pragma omp for'}}
224 for (int k
= 0; k
< argc
; ++k
)
229 #pragma omp for private(i)
230 for (int k
= 0; k
< argc
; ++k
)
233 #pragma omp parallel shared(i)
234 #pragma omp parallel private(i)
235 #pragma omp for private(j)
236 for (int k
= 0; k
< argc
; ++k
)
238 #pragma omp for private(i)
239 for (int k
= 0; k
< argc
; ++k
)
242 #pragma omp for private(si) // OK
243 for(int k
= 0; k
< argc
; ++k
)
246 s6
= s6_0
; // expected-note {{in instantiation of member function 'S6<float>::operator=' requested here}}
247 s7
= s7_0
; // expected-note {{in instantiation of member function 'S7<S6<float>>::operator=' requested here}}
248 return foomain(argc
, argv
); // expected-note {{in instantiation of function template specialization 'foomain<int, char>' requested here}}