1 // RUN: %clang_cc1 -verify=expected,le45 -fopenmp-version=40 -fopenmp %s -Wuninitialized
2 // RUN: %clang_cc1 -verify=expected,le45 -fopenmp-version=45 -fopenmp %s -Wuninitialized
3 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
5 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
7 typedef void **omp_allocator_handle_t
;
8 extern const omp_allocator_handle_t omp_null_allocator
;
9 extern const omp_allocator_handle_t omp_default_mem_alloc
;
10 extern const omp_allocator_handle_t omp_large_cap_mem_alloc
;
11 extern const omp_allocator_handle_t omp_const_mem_alloc
;
12 extern const omp_allocator_handle_t omp_high_bw_mem_alloc
;
13 extern const omp_allocator_handle_t omp_low_lat_mem_alloc
;
14 extern const omp_allocator_handle_t omp_cgroup_mem_alloc
;
15 extern const omp_allocator_handle_t omp_pteam_mem_alloc
;
16 extern const omp_allocator_handle_t omp_thread_mem_alloc
;
21 bool foobool(int argc
) {
25 struct S1
; // expected-note {{declared here}} expected-note {{forward declaration of 'S1'}}
31 static float S2s
; // expected-note {{predetermined as shared}}
40 const S3 c
; // expected-note {{'c' defined here}}
41 const S3 ca
[5]; // expected-note {{'ca' defined here}}
42 extern const int f
; // expected-note {{'f' declared here}}
45 S4(); // expected-note {{implicitly declared private here}}
51 S5():a(0) {} // expected-note {{implicitly declared private here}}
57 #pragma omp threadprivate(h) // expected-note {{defined as threadprivate or thread local}}
60 int main(int argc
, char **argv
) {
61 const int d
= 5; // expected-note {{'d' defined here}}
62 const int da
[5] = { 0 }; // expected-note {{'da' defined here}}
68 #pragma omp target teams distribute simd private // expected-error {{expected '(' after 'private'}}
69 for (int k
= 0; k
< argc
; ++k
) ++k
;
71 #pragma omp target teams distribute simd private ( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
72 for (int k
= 0; k
< argc
; ++k
) ++k
;
74 #pragma omp target teams distribute simd private () // expected-error {{expected expression}}
75 for (int k
= 0; k
< argc
; ++k
) ++k
;
77 #pragma omp target teams distribute simd private (argc // expected-error {{expected ')'}} expected-note {{to match this '('}}
78 for (int k
= 0; k
< argc
; ++k
) ++k
;
80 #pragma omp target teams distribute simd private (argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
81 for (int k
= 0; k
< argc
; ++k
) ++k
;
83 #pragma omp target teams distribute simd private (argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}}
84 for (int k
= 0; k
< argc
; ++k
) ++k
;
86 #pragma omp target teams distribute simd 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 '('}}
87 for (int k
= 0; k
< argc
; ++k
) ++k
;
89 #pragma omp target teams distribute simd private (S1) // expected-error {{'S1' does not refer to a value}}
90 for (int k
= 0; k
< argc
; ++k
) ++k
;
92 #pragma omp target teams distribute simd private (a, b, c, d, f) // expected-error {{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}}
93 for (int k
= 0; k
< argc
; ++k
) ++k
;
95 #pragma omp target teams distribute simd private (k, argv[1]) // expected-error {{expected variable name}}
96 for (int k
= 0; k
< argc
; ++k
) ++k
;
98 #pragma omp target teams distribute simd private(ba) allocate(omp_thread_mem_alloc: ba) uses_allocators(omp_thread_mem_alloc) // expected-warning {{allocator with the 'thread' trait access has unspecified behavior on 'target teams distribute simd' directive}} le45-error {{unexpected OpenMP clause 'uses_allocators' in directive '#pragma omp target teams distribute simd'}}
99 for (int k
= 0; k
< argc
; ++k
) ++k
;
101 #pragma omp target teams distribute simd private(ca) // expected-error {{const-qualified variable without mutable fields cannot be private}}
102 for (int k
= 0; k
< argc
; ++k
) ++k
;
104 #pragma omp target teams distribute simd private(da) // expected-error {{const-qualified variable cannot be private}}
105 for (int k
= 0; k
< argc
; ++k
) ++k
;
107 #pragma omp target teams distribute simd private(S2::S2s) // expected-error {{shared variable cannot be private}}
108 for (int k
= 0; k
< argc
; ++k
) ++k
;
110 #pragma omp target teams distribute simd private(e, g) // expected-error {{calling a private constructor of class 'S4'}} expected-error {{calling a private constructor of class 'S5'}}
111 for (int k
= 0; k
< argc
; ++k
) ++k
;
113 #pragma omp target teams distribute simd private(h) // expected-error {{threadprivate or thread local variable cannot be private}}
114 for (int k
= 0; k
< argc
; ++k
) ++k
;
116 #pragma omp target teams distribute simd shared(i)
117 for (int k
= 0; k
< argc
; ++k
) ++k
;
119 #pragma omp target teams distribute simd firstprivate(i), private(i) // expected-error {{firstprivate variable cannot be private}} expected-note {{defined as firstprivate}}
120 for (int k
= 0; k
< argc
; ++k
) ++k
;
122 #pragma omp target teams distribute simd private(j)
123 for (int k
= 0; k
< argc
; ++k
) ++k
;
125 #pragma omp target teams distribute simd reduction(+:i)
126 for (int k
= 0; k
< argc
; ++k
) ++k
;
128 #pragma omp distribute private(i)
129 for (int k
= 0; k
< 10; ++k
) {
130 #pragma omp target teams distribute simd private(i)
131 for (int x
= 0; x
< 10; ++x
) foo();
134 #pragma omp target teams distribute simd firstprivate(i)
135 for (int k
= 0; k
< 10; ++k
) {
138 #pragma omp target teams distribute simd private(j) map(j) // le45-error {{private variable cannot be in a map clause in '#pragma omp target teams distribute simd' directive}} le45-note {{defined as private}}
139 for (int k
= 0; k
< argc
; ++k
) ++k
;