[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / masked_messages_attr.cpp
blob52ca2610ce5252d0c054cb98ba74935142f82915
1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
2 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
4 void xxx(int argc) {
5 int x; // expected-note {{initialize the variable 'x' to silence this warning}}
6 [[omp::directive(masked)]]
7 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
10 void yyy(int argc) {
11 int x; // expected-note {{initialize the variable 'x' to silence this warning}}
12 [[omp::directive(masked filter(1))]]
13 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
16 int foo();
18 int main() {
19 [[omp::directive(masked)]]
21 [[omp::directive(masked filter(1) filter(2))]] // expected-error {{directive '#pragma omp masked' cannot contain more than one 'filter' clause}}
23 int x,y,z;
24 [[omp::directive(masked filter(x) filter(y) filter(z))]] // expected-error 2 {{directive '#pragma omp masked' cannot contain more than one 'filter' clause}}
26 [[omp::directive(masked nowait)]] // expected-error {{unexpected OpenMP clause 'nowait' in directive '#pragma omp masked'}}
27 [[omp::directive(masked unknown)]] // expected-warning {{extra tokens at the end of '#pragma omp masked' are ignored}}
28 foo();
30 [[omp::directive(masked)]]
31 } // expected-error {{expected statement}}
33 [[omp::directive(masked filter(2))]]
34 } // expected-error {{expected statement}}
35 [[omp::directive(for)]]
36 for (int i = 0; i < 10; ++i) {
37 foo();
38 [[omp::directive(masked filter(1))]] // expected-error {{region cannot be closely nested inside 'for' region}}
39 foo();
41 [[omp::directive(sections)]]
43 foo();
44 [[omp::directive(masked)]] // expected-error {{region cannot be closely nested inside 'sections' region}}
45 foo();
47 [[omp::directive(single)]]
48 for (int i = 0; i < 10; ++i) {
49 foo();
50 [[omp::directive(masked allocate(i))]] // expected-error {{region cannot be closely nested inside 'single' region}} expected-error {{unexpected OpenMP clause 'allocate' in directive '#pragma omp masked'}}
51 foo();
53 [[omp::directive(masked)]]
54 for (int i = 0; i < 10; ++i) {
55 foo();
56 [[omp::directive(masked)]]
57 foo();
59 [[omp::directive(for ordered)]]
60 for (int i = 0; i < 10; ++i)
61 [[omp::directive(masked)]] // expected-error {{region cannot be closely nested inside 'for' region}}
63 foo();
66 return 0;
69 int foo() {
70 L1: // expected-note {{jump exits scope of OpenMP structured block}}
71 foo();
72 [[omp::directive(masked filter(0))]]
74 foo();
75 goto L1; // expected-error {{cannot jump from this goto statement to its label}}
77 goto L2; // expected-error {{cannot jump from this goto statement to its label}}
78 [[omp::directive(masked filter(-2))]]
79 { // expected-note {{jump bypasses OpenMP structured block}}
80 L2:
81 foo();
84 return 0;