xref: /minix3/external/bsd/llvm/dist/clang/test/OpenMP/master_messages.cpp (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc // RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s
2*0a6a1f1dSLionel Sambuc 
3*0a6a1f1dSLionel Sambuc int foo();
4*0a6a1f1dSLionel Sambuc 
main()5*0a6a1f1dSLionel Sambuc int main() {
6*0a6a1f1dSLionel Sambuc   #pragma omp master
7*0a6a1f1dSLionel Sambuc   ;
8*0a6a1f1dSLionel Sambuc   #pragma omp master nowait // expected-error {{unexpected OpenMP clause 'nowait' in directive '#pragma omp master'}}
9*0a6a1f1dSLionel Sambuc   #pragma omp master unknown // expected-warning {{extra tokens at the end of '#pragma omp master' are ignored}}
10*0a6a1f1dSLionel Sambuc   foo();
11*0a6a1f1dSLionel Sambuc   {
12*0a6a1f1dSLionel Sambuc     #pragma omp master
13*0a6a1f1dSLionel Sambuc   } // expected-error {{expected statement}}
14*0a6a1f1dSLionel Sambuc   #pragma omp for
15*0a6a1f1dSLionel Sambuc   for (int i = 0; i < 10; ++i) {
16*0a6a1f1dSLionel Sambuc     foo();
17*0a6a1f1dSLionel Sambuc     #pragma omp master // expected-error {{region cannot be closely nested inside 'for' region}}
18*0a6a1f1dSLionel Sambuc     foo();
19*0a6a1f1dSLionel Sambuc   }
20*0a6a1f1dSLionel Sambuc   #pragma omp sections
21*0a6a1f1dSLionel Sambuc   {
22*0a6a1f1dSLionel Sambuc     foo();
23*0a6a1f1dSLionel Sambuc     #pragma omp master // expected-error {{region cannot be closely nested inside 'sections' region}}
24*0a6a1f1dSLionel Sambuc     foo();
25*0a6a1f1dSLionel Sambuc   }
26*0a6a1f1dSLionel Sambuc   #pragma omp single
27*0a6a1f1dSLionel Sambuc   for (int i = 0; i < 10; ++i) {
28*0a6a1f1dSLionel Sambuc     foo();
29*0a6a1f1dSLionel Sambuc     #pragma omp master // expected-error {{region cannot be closely nested inside 'single' region}}
30*0a6a1f1dSLionel Sambuc     foo();
31*0a6a1f1dSLionel Sambuc   }
32*0a6a1f1dSLionel Sambuc   #pragma omp master
33*0a6a1f1dSLionel Sambuc   for (int i = 0; i < 10; ++i) {
34*0a6a1f1dSLionel Sambuc     foo();
35*0a6a1f1dSLionel Sambuc     #pragma omp master
36*0a6a1f1dSLionel Sambuc     foo();
37*0a6a1f1dSLionel Sambuc   }
38*0a6a1f1dSLionel Sambuc   #pragma omp for ordered
39*0a6a1f1dSLionel Sambuc   for (int i = 0; i < 10; ++i)
40*0a6a1f1dSLionel Sambuc   #pragma omp master // expected-error {{region cannot be closely nested inside 'for' region}}
41*0a6a1f1dSLionel Sambuc   {
42*0a6a1f1dSLionel Sambuc     foo();
43*0a6a1f1dSLionel Sambuc   }
44*0a6a1f1dSLionel Sambuc 
45*0a6a1f1dSLionel Sambuc   return 0;
46*0a6a1f1dSLionel Sambuc }
47*0a6a1f1dSLionel Sambuc 
foo()48*0a6a1f1dSLionel Sambuc int foo() {
49*0a6a1f1dSLionel Sambuc   L1:
50*0a6a1f1dSLionel Sambuc     foo();
51*0a6a1f1dSLionel Sambuc   #pragma omp master
52*0a6a1f1dSLionel Sambuc   {
53*0a6a1f1dSLionel Sambuc     foo();
54*0a6a1f1dSLionel Sambuc     goto L1; // expected-error {{use of undeclared label 'L1'}}
55*0a6a1f1dSLionel Sambuc   }
56*0a6a1f1dSLionel Sambuc   goto L2; // expected-error {{use of undeclared label 'L2'}}
57*0a6a1f1dSLionel Sambuc   #pragma omp master
58*0a6a1f1dSLionel Sambuc   {
59*0a6a1f1dSLionel Sambuc     L2:
60*0a6a1f1dSLionel Sambuc     foo();
61*0a6a1f1dSLionel Sambuc   }
62*0a6a1f1dSLionel Sambuc 
63*0a6a1f1dSLionel Sambuc   return 0;
64*0a6a1f1dSLionel Sambuc }
65