1 // RUN: %clang_cc1 -verify -fopenmp %s -Wuninitialized
2 
3 // RUN: %clang_cc1 -verify -fopenmp-simd %s -Wuninitialized
4 
xxx(int argc)5 void xxx(int argc) {
6   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
7 #pragma omp masked
8   argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
9 }
10 
yyy(int argc)11 void yyy(int argc) {
12   int x; // expected-note {{initialize the variable 'x' to silence this warning}}
13 #pragma omp masked filter(1)
14   argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
15 }
16 
17 int foo();
18 
main()19 int main() {
20   #pragma omp masked
21   ;
22   #pragma omp masked filter(1) filter(2) // expected-error {{directive '#pragma omp masked' cannot contain more than one 'filter' clause}}
23   ;
24   int x,y,z;
25   #pragma omp masked filter(x) filter(y) filter(z) // expected-error 2 {{directive '#pragma omp masked' cannot contain more than one 'filter' clause}}
26   ;
27   #pragma omp masked nowait // expected-error {{unexpected OpenMP clause 'nowait' in directive '#pragma omp masked'}}
28   #pragma omp masked unknown // expected-warning {{extra tokens at the end of '#pragma omp masked' are ignored}}
29   foo();
30   {
31     #pragma omp masked
32   } // expected-error {{expected statement}}
33   {
34     #pragma omp masked filter(2)
35   } // expected-error {{expected statement}}
36   #pragma omp for
37   for (int i = 0; i < 10; ++i) {
38     foo();
39     #pragma omp masked filter(1) // expected-error {{region cannot be closely nested inside 'for' region}}
40     foo();
41   }
42   #pragma omp sections
43   {
44     foo();
45     #pragma omp masked // expected-error {{region cannot be closely nested inside 'sections' region}}
46     foo();
47   }
48   #pragma omp single
49   for (int i = 0; i < 10; ++i) {
50     foo();
51     #pragma omp masked allocate(i) // expected-error {{region cannot be closely nested inside 'single' region}} expected-error {{unexpected OpenMP clause 'allocate' in directive '#pragma omp masked'}}
52     foo();
53   }
54   #pragma omp masked
55   for (int i = 0; i < 10; ++i) {
56     foo();
57     #pragma omp masked
58     foo();
59   }
60   #pragma omp for ordered
61   for (int i = 0; i < 10; ++i)
62   #pragma omp masked // expected-error {{region cannot be closely nested inside 'for' region}}
63   {
64     foo();
65   }
66 
67   return 0;
68 }
69 
foo()70 int foo() {
71   L1: // expected-note {{jump exits scope of OpenMP structured block}}
72     foo();
73   #pragma omp masked filter(0)
74   {
75     foo();
76     goto L1; // expected-error {{cannot jump from this goto statement to its label}}
77   }
78   goto L2; // expected-error {{cannot jump from this goto statement to its label}}
79   #pragma omp masked filter(-2)
80   { // expected-note {{jump bypasses OpenMP structured block}}
81     L2:
82     foo();
83   }
84 
85   return 0;
86 }
87