[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / teams_distribute_parallel_for_simd_messages.cpp
bloba94f64b38df8e366d5d7253990dd97f96081f36d
1 // RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -verify=expected,omp45 -std=c++11 %s -Wuninitialized
2 // RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -verify=expected,omp5,omp50 -std=c++11 %s -Wuninitialized
3 // RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -verify=expected,omp5,omp51 -std=c++11 %s -Wuninitialized
5 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -verify=expected,omp45 -std=c++11 %s -Wuninitialized
6 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -verify=expected,omp5,omp50 -std=c++11 %s -Wuninitialized
7 // RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=51 -verify=expected,omp5,omp51 -std=c++11 %s -Wuninitialized
9 void xxx(int argc) {
10 int x; // expected-note {{initialize the variable 'x' to silence this warning}}
11 #pragma omp target
12 #pragma omp teams distribute parallel for simd
13 for (int i = 0; i < 10; ++i)
14 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
17 void foo() {
20 static int pvt;
21 #pragma omp threadprivate(pvt)
23 #pragma omp teams distribute parallel for simd // expected-error {{unexpected OpenMP directive '#pragma omp teams distribute parallel for simd'}}
25 int main(int argc, char **argv) {
26 #pragma omp target
27 #pragma omp teams distribute parallel for simd
28 f; // expected-error {{use of undeclared identifier 'f'}}
29 #pragma omp target
30 #pragma omp teams distribute parallel for simd { // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for simd' are ignored}}
31 for (int i = 0; i < argc; ++i)
32 foo();
33 #pragma omp target
34 #pragma omp teams distribute parallel for simd ( // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for simd' are ignored}}
35 for (int i = 0; i < argc; ++i)
36 foo();
37 #pragma omp target
38 #pragma omp teams distribute parallel for simd[ // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for simd' are ignored}}
39 for (int i = 0; i < argc; ++i)
40 foo();
41 #pragma omp target
42 #pragma omp teams distribute parallel for simd] // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for simd' are ignored}}
43 for (int i = 0; i < argc; ++i)
44 foo();
45 #pragma omp target
46 #pragma omp teams distribute parallel for simd) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for simd' are ignored}}
47 for (int i = 0; i < argc; ++i)
48 foo();
49 #pragma omp target
50 #pragma omp teams distribute parallel for simd } // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for simd' are ignored}}
51 for (int i = 0; i < argc; ++i)
52 foo();
53 #pragma omp target
54 #pragma omp teams distribute parallel for simd
55 for (int i = 0; i < argc; ++i)
56 foo();
57 // expected-warning@+2 {{extra tokens at the end of '#pragma omp teams distribute parallel for simd' are ignored}}
58 #pragma omp target
59 #pragma omp teams distribute parallel for simd unknown()
60 for (int i = 0; i < argc; ++i)
61 foo();
62 L1:
63 for (int i = 0; i < argc; ++i)
64 foo();
65 #pragma omp target
66 #pragma omp teams distribute parallel for simd
67 for (int i = 0; i < argc; ++i)
68 foo();
69 #pragma omp target
70 #pragma omp teams distribute parallel for simd
71 for (int i = 0; i < argc; ++i) {
72 goto L1; // expected-error {{use of undeclared label 'L1'}}
73 argc++;
76 for (int i = 0; i < 10; ++i) {
77 switch (argc) {
78 case (0):
79 #pragma omp target
80 #pragma omp teams distribute parallel for simd
81 for (int i = 0; i < argc; ++i) {
82 foo();
83 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
84 continue;
86 default:
87 break;
90 #pragma omp target
91 #pragma omp teams distribute parallel for simd default(none) // expected-note {{explicit data sharing attribute requested here}}
92 for (int i = 0; i < 10; ++i)
93 ++argc; // expected-error {{ariable 'argc' must have explicitly specified data sharing attributes}}
95 goto L2; // expected-error {{use of undeclared label 'L2'}}
96 #pragma omp target
97 #pragma omp teams distribute parallel for simd
98 for (int i = 0; i < argc; ++i)
99 L2:
100 foo();
101 #pragma omp target
102 #pragma omp teams distribute parallel for simd
103 for (int i = 0; i < argc; ++i) {
104 return 1; // expected-error {{cannot return from OpenMP region}}
107 [[]] // expected-error {{an attribute list cannot appear here}}
108 #pragma omp target
109 #pragma omp teams distribute parallel for simd
110 for (int n = 0; n < 100; ++n) {
113 #pragma omp target
114 #pragma omp teams distribute parallel for simd copyin(pvt) // expected-error {{unexpected OpenMP clause 'copyin' in directive '#pragma omp teams distribute parallel for simd'}}
115 for (int n = 0; n < 100; ++n) {}
117 return 0;
120 void test_ordered() {
121 #pragma omp target
122 #pragma omp teams distribute parallel for simd ordered // expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp teams distribute parallel for simd'}}
123 for (int i = 0; i < 16; ++i)
127 void test_nontemporal() {
128 int i;
129 #pragma omp target
130 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute parallel for simd'}} expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
131 #pragma omp teams distribute parallel for simd nontemporal(
132 for (i = 0; i < 16; ++i)
134 #pragma omp target
135 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute parallel for simd'}} expected-error@+1 2 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
136 #pragma omp teams distribute parallel for simd nontemporal(,
137 for (i = 0; i < 16; ++i)
139 #pragma omp target
140 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute parallel for simd'}} expected-error@+1 2 {{expected expression}}
141 #pragma omp teams distribute parallel for simd nontemporal(, )
142 for (i = 0; i < 16; ++i)
144 #pragma omp target
145 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute parallel for simd'}} expected-error@+1 {{expected expression}}
146 #pragma omp teams distribute parallel for simd nontemporal()
147 for (i = 0; i < 16; ++i)
149 #pragma omp target
150 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute parallel for simd'}} expected-error@+1 {{expected '(' for function-style cast or type construction}}
151 #pragma omp teams distribute parallel for simd nontemporal(int)
152 for (i = 0; i < 16; ++i)
154 #pragma omp target
155 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute parallel for simd'}} omp5-error@+1 {{expected variable name}}
156 #pragma omp teams distribute parallel for simd nontemporal(0)
157 for (i = 0; i < 16; ++i)
159 #pragma omp target
160 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute parallel for simd'}} expected-error@+1 {{use of undeclared identifier 'x'}}
161 #pragma omp teams distribute parallel for simd nontemporal(x)
162 for (i = 0; i < 16; ++i)
164 #pragma omp target
165 // expected-error@+2 {{use of undeclared identifier 'x'}}
166 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute parallel for simd'}} expected-error@+1 {{use of undeclared identifier 'y'}}
167 #pragma omp teams distribute parallel for simd nontemporal(x, y)
168 for (i = 0; i < 16; ++i)
170 #pragma omp target
171 // expected-error@+3 {{use of undeclared identifier 'x'}}
172 // expected-error@+2 {{use of undeclared identifier 'y'}}
173 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute parallel for simd'}} expected-error@+1 {{use of undeclared identifier 'z'}}
174 #pragma omp teams distribute parallel for simd nontemporal(x, y, z)
175 for (i = 0; i < 16; ++i)
178 int x, y;
179 #pragma omp target
180 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute parallel for simd'}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}}
181 #pragma omp teams distribute parallel for simd nontemporal(x :)
182 for (i = 0; i < 16; ++i)
184 #pragma omp target
185 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute parallel for simd'}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}}
186 #pragma omp teams distribute parallel for simd nontemporal(x :, )
187 for (i = 0; i < 16; ++i)
190 #pragma omp target
191 // omp5-note@+2 {{defined as nontemporal}}
192 // omp45-error@+1 2 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute parallel for simd'}} omp5-error@+1 {{a variable cannot appear in more than one nontemporal clause}}
193 #pragma omp teams distribute parallel for simd nontemporal(x) nontemporal(x)
194 for (i = 0; i < 16; ++i)
197 #pragma omp target
198 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute parallel for simd'}}
199 #pragma omp teams distribute parallel for simd private(x) nontemporal(x)
200 for (i = 0; i < 16; ++i)
203 #pragma omp target
204 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute parallel for simd'}}
205 #pragma omp teams distribute parallel for simd nontemporal(x) private(x)
206 for (i = 0; i < 16; ++i)
209 #pragma omp target
210 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute parallel for simd'}} expected-note@+1 {{to match this '('}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}} expected-error@+1 {{expected ')'}}
211 #pragma omp teams distribute parallel for simd nontemporal(x, y : 0)
212 for (i = 0; i < 16; ++i)
215 #pragma omp target
216 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute parallel for simd'}}
217 #pragma omp teams distribute parallel for simd nontemporal(x) lastprivate(x)
218 for (i = 0; i < 16; ++i)
221 #pragma omp target
222 // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp teams distribute parallel for simd'}}
223 #pragma omp teams distribute parallel for simd lastprivate(x) nontemporal(x)
224 for (i = 0; i < 16; ++i)
226 #pragma omp target
227 #pragma omp teams distribute parallel for simd order // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for simd'}} expected-error {{expected '(' after 'order'}}
228 for (int i = 0; i < 10; ++i)
230 #pragma omp target
231 #pragma omp teams distribute parallel for simd order( // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp5-error {{expected 'concurrent' in OpenMP clause 'order'}}
232 for (int i = 0; i < 10; ++i)
234 #pragma omp target
235 #pragma omp teams distribute parallel for simd order(none // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp5-error {{expected 'concurrent' in OpenMP clause 'order'}}
236 for (int i = 0; i < 10; ++i)
238 #pragma omp target
239 #pragma omp teams distribute parallel for simd order(concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
240 for (int i = 0; i < 10; ++i)
242 #pragma omp target
243 #pragma omp teams distribute parallel for simd order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for simd'}}
244 for (int i = 0; i < 10; ++i)
246 #pragma omp target
247 #pragma omp teams distribute parallel for simd order(unconstrained:) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for simd'}} omp5-error {{expected 'concurrent' in OpenMP clause 'order'}}
248 for (int i = 0; i < 10; ++i)
250 #pragma omp target
251 #pragma omp teams distribute parallel for simd order(reproducible:concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
252 for (int i = 0; i < 10; ++i)
254 #pragma omp target
255 #pragma omp teams distribute parallel for simd order(reproducible:concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for simd'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
256 for (int i = 0; i < 10; ++i)
258 #pragma omp target
259 #pragma omp teams distribute parallel for simd order(unconstrained:concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for simd'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
260 for (int i = 0; i < 10; ++i)
262 #pragma omp target
263 #pragma omp teams distribute parallel for simd order(concurrent) order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for simd'}} omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for simd'}} omp51-error {{directive '#pragma omp teams distribute parallel for simd' cannot contain more than one 'order' clause}}
264 for (int i = 0; i < 10; ++i)