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