1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
5 typedef void **omp_allocator_handle_t
;
6 extern const omp_allocator_handle_t omp_null_allocator
;
7 extern const omp_allocator_handle_t omp_default_mem_alloc
;
8 extern const omp_allocator_handle_t omp_large_cap_mem_alloc
;
9 extern const omp_allocator_handle_t omp_const_mem_alloc
;
10 extern const omp_allocator_handle_t omp_high_bw_mem_alloc
;
11 extern const omp_allocator_handle_t omp_low_lat_mem_alloc
;
12 extern const omp_allocator_handle_t omp_cgroup_mem_alloc
;
13 extern const omp_allocator_handle_t omp_pteam_mem_alloc
;
14 extern const omp_allocator_handle_t omp_thread_mem_alloc
;
19 struct S1
; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}} expected-note 1 {{forward declaration of 'S1'}} expected-note {{forward declaration of 'S1'}}
26 static float S2s
; // expected-note {{static data member is predetermined as shared}} expected-note 1 {{static data member is predetermined as shared}}
36 const S3 c
; // expected-note 2 {{'c' defined here}}
37 const S3 ca
[5]; // expected-note 2 {{'ca' defined here}}
38 extern const int f
; // expected-note 2 {{'f' declared here}}
41 #pragma omp threadprivate(threadvar) // expected-note {{defined as threadprivate or thread local}} expected-note 1 {{defined as threadprivate or thread local}}
45 S4(); // expected-note {{implicitly declared private here}} expected-note 1 {{implicitly declared private here}}
52 S5() : a(0) {} // expected-note {{implicitly declared private here}} expected-note 1 {{implicitly declared private here}}
59 #pragma omp threadprivate(x) // expected-note {{defined as threadprivate or thread local}} expected-note 1 {{defined as threadprivate or thread local}} expected-note 2 {{defined as threadprivate or thread local}}
66 #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}}
68 template <class I
, class C
, class D
, class E
>
69 int foomain(I argc
, C
**argv
) {
70 const I d
= 5; // expected-note {{'d' defined here}}
71 const I da
[5] = { 0 }; // expected-note {{'da' defined here}}
76 #pragma omp target parallel private // expected-error {{expected '(' after 'private'}}
78 #pragma omp target parallel private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
80 #pragma omp target parallel private() // expected-error {{expected expression}}
82 #pragma omp target parallel private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
84 #pragma omp target parallel private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
86 #pragma omp target parallel private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
88 #pragma omp target parallel private(argc argv) // expected-error {{expected ',' or ')' in 'private' clause}}
90 #pragma omp target parallel 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 '('}}
92 #pragma omp target parallel private(S1) // expected-error {{'S1' does not refer to a value}}
94 #pragma omp target parallel private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
96 #pragma omp target parallel private (a, b, c, d, f) // expected-error {{a private variable with incomplete type 'S1'}} expected-error 1 {{const-qualified variable without mutable fields cannot be private}} expected-error 2 {{const-qualified variable cannot be private}}
98 #pragma omp target parallel private(argv[1]) // expected-error {{expected variable name}}
100 #pragma omp target parallel allocate(omp_thread_mem_alloc: ba) private(ba) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'target parallel' directive}} expected-error {{allocator must be specified in the 'uses_allocators' clause}}
102 #pragma omp target parallel private(ca) // expected-error {{const-qualified variable without mutable fields cannot be private}}
104 #pragma omp target parallel private(da) // expected-error {{const-qualified variable cannot be private}}
106 #pragma omp target parallel private(S2::S2s) // expected-error {{shared variable cannot be private}}
108 #pragma omp target parallel private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
110 #pragma omp target parallel private(threadvar, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be private}}
112 #pragma omp target parallel shared(i), private(i) // expected-error {{shared variable cannot be private}} expected-note {{defined as shared}}
114 #pragma omp target parallel firstprivate(i) private(i) // expected-error {{firstprivate variable cannot be private}} expected-note {{defined as firstprivate}}
116 #pragma omp target parallel private(i)
118 #pragma omp target parallel private(j)
120 #pragma omp parallel firstprivate(i)
121 for (int k
= 0; k
< 10; ++k
) {
122 #pragma omp target parallel private(i)
126 #pragma omp target parallel private(m) // OK
128 #pragma omp target parallel private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
130 #pragma omp target parallel private(B::x) // expected-error {{threadprivate or thread local variable cannot be private}}
136 #pragma omp target parallel shared(i)
138 #pragma omp target parallel private(i)
140 #pragma omp target parallel private(j)
142 #pragma omp target parallel private(i)
145 #pragma omp target parallel private(si) // OK
152 #pragma omp target parallel private(a)
156 int main(int argc
, char **argv
) {
157 const int d
= 5; // expected-note {{'d' defined here}}
158 const int da
[5] = { 0 }; // expected-note {{'da' defined here}}
163 #pragma omp target parallel private // expected-error {{expected '(' after 'private'}}
165 #pragma omp target parallel private( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
167 #pragma omp target parallel private() // expected-error {{expected expression}}
169 #pragma omp target parallel private(argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
171 #pragma omp target parallel private(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
173 #pragma omp target parallel private(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
175 #pragma omp target parallel private(argc argv) // expected-error {{expected ',' or ')' in 'private' clause}}
177 #pragma omp target parallel private(argc)
179 #pragma omp target parallel private(S1) // expected-error {{'S1' does not refer to a value}}
181 #pragma omp target parallel private(a, b) // expected-error {{private variable with incomplete type 'S1'}}
183 #pragma omp target parallel private (a, b, c, d, f) // expected-error {{a private variable with incomplete type 'S1'}} expected-error 1 {{const-qualified variable without mutable fields cannot be private}} expected-error 2 {{const-qualified variable cannot be private}}
185 #pragma omp target parallel private(argv[1]) // expected-error {{expected variable name}}
187 #pragma omp target parallel private(ba)
189 #pragma omp target parallel private(ca) // expected-error {{const-qualified variable without mutable fields cannot be private}}
191 #pragma omp target parallel private(da) // expected-error {{const-qualified variable cannot be private}}
193 #pragma omp target parallel private(S2::S2s) // expected-error {{shared variable cannot be private}}
195 #pragma omp target parallel private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
197 #pragma omp target parallel private(threadvar, B::x) // expected-error 2 {{threadprivate or thread local variable cannot be private}}
199 #pragma omp target parallel shared(i), private(i) // expected-error {{shared variable cannot be private}} expected-note {{defined as shared}}
201 #pragma omp target parallel firstprivate(i) private(i) // expected-error {{firstprivate variable cannot be private}} expected-note {{defined as firstprivate}}
203 #pragma omp target parallel private(i)
205 #pragma omp target parallel private(j)
207 #pragma omp parallel firstprivate(i)
208 for (int k
= 0; k
< 10; ++k
) {
209 #pragma omp target parallel private(i)
213 #pragma omp target parallel private(m) // OK
215 #pragma omp target parallel private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
217 #pragma omp target parallel private(B::x) // expected-error {{threadprivate or thread local variable cannot be private}}
222 #pragma omp target parallel shared(i)
224 #pragma omp target parallel private(i)
226 #pragma omp target parallel private(j)
228 #pragma omp target parallel private(i)
231 #pragma omp target parallel private(si) // OK
233 return foomain
<int, char, S4
, S5
>(argc
, argv
); // expected-note {{in instantiation of function template specialization 'foomain<int, char, S4, S5>' requested here}}