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