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