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