1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
2 
3 // RUN: %clang_cc1 -verify -fopenmp-simd -ferror-limit 100 -std=c++11 -o - %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 parallel sections
8 {
9   argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
10 }
11 }
12 
foo()13 void foo() {
14 }
15 
16 #pragma omp parallel sections // expected-error {{unexpected OpenMP directive '#pragma omp parallel sections'}}
17 
main(int argc,char ** argv)18 int main(int argc, char **argv) {
19 #pragma omp parallel sections {// expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
20   {
21     foo();
22   }
23 #pragma omp parallel sections( // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
24   {
25     foo();
26   }
27 #pragma omp parallel sections[ // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
28   {
29     foo();
30   }
31 #pragma omp parallel sections] // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
32   {
33     foo();
34   }
35 #pragma omp parallel sections) // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
36   {
37     foo();
38   }
39 #pragma omp parallel sections } // expected-warning {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
40   {
41     foo();
42   }
43 // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel sections' are ignored}}
44 #pragma omp parallel sections unknown()
45   {
46     foo();
47 #pragma omp section
48   L1:
49     foo();
50   }
51 #pragma omp parallel sections
52   {
53     ;
54   }
55 #pragma omp parallel sections
56   {
57     goto L1; // expected-error {{use of undeclared label 'L1'}}
58   }
59 
60   for (int i = 0; i < 10; ++i) {
61     switch (argc) {
62     case (0):
63 #pragma omp parallel sections
64     {
65       foo();
66       break;    // expected-error {{'break' statement not in loop or switch statement}}
67       continue; // expected-error {{'continue' statement not in loop statement}}
68     }
69     default:
70       break;
71     }
72   }
73 #pragma omp parallel sections default(none) // expected-note {{explicit data sharing attribute requested here}}
74   {
75     ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
76   }
77 
78   goto L2; // expected-error {{use of undeclared label 'L2'}}
79 #pragma omp parallel sections
80   {
81   L2:
82     foo();
83   }
84 #pragma omp parallel sections
85   {
86     return 1; // expected-error {{cannot return from OpenMP region}}
87   }
88 
89   [[]] // expected-error {{an attribute list cannot appear here}}
90 #pragma omp parallel sections
91   {
92   }
93 
94   return 0;
95 }
96