xref: /llvm-project/clang/test/OpenMP/teams_default_messages.cpp (revision d211ad311e4b6449c73e1617c0bdf927857e9279)
1 // RUN: %clang_cc1 -verify -fopenmp-version=51 -fopenmp -DOMP51 -o - %s -Wuninitialized
2 
3 // RUN: %clang_cc1 -verify -fopenmp-version=51 -fopenmp-simd -DOMP51 -o - %s -Wuninitialized
4 
5 // RUN: %clang_cc1 -verify -fopenmp-version=50 -fopenmp -o - %s -Wuninitialized
6 
7 // RUN: %clang_cc1 -verify -fopenmp-version=50 -fopenmp-simd -o - %s -Wuninitialized
8 
9 void foo();
10 
11 namespace {
12 static int y = 0;
13 }
14 static int x = 0;
15 
main(int argc,char ** argv)16 int main(int argc, char **argv) {
17   #pragma omp target
18   #pragma omp teams default // expected-error {{expected '(' after 'default'}}
19   foo();
20   #pragma omp target
21 #pragma omp teams default( // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
22   foo();
23   #pragma omp target
24 #pragma omp teams default() // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
25   foo();
26   #pragma omp target
27   #pragma omp teams default (none // expected-error {{expected ')'}} expected-note {{to match this '('}}
28   foo();
29   #pragma omp target
30   #pragma omp teams default (shared), default(shared) // expected-error {{directive '#pragma omp teams' cannot contain more than one 'default' clause}}
31   foo();
32   #pragma omp target
33 #pragma omp teams default(x) // expected-error {{expected 'none', 'shared', 'private' or 'firstprivate' in OpenMP clause 'default'}}
34   foo();
35 
36   #pragma omp target
37   #pragma omp teams default(none) // expected-note {{explicit data sharing attribute requested here}}
38   ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
39 
40   #pragma omp target
41   #pragma omp teams default(none) // expected-note {{explicit data sharing attribute requested here}}
42   #pragma omp parallel default(shared)
43   ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
44 
45   #pragma omp teams if(x) // expected-error {{unexpected OpenMP clause 'if' in directive '#pragma omp teams'}}
46   foo();
47 
48 #ifdef OMP51
49 #pragma omp target
50 #pragma omp teams default(firstprivate) // expected-note 2 {{explicit data sharing attribute requested here}}
51   {
52     ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
53     ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
54   }
55 #pragma omp target
56 #pragma omp teams default(private) // expected-note 2 {{explicit data sharing attribute requested here}}
57   {
58     ++x; // expected-error {{variable 'x' must have explicitly specified data sharing attributes}}
59     ++y; // expected-error {{variable 'y' must have explicitly specified data sharing attributes}}
60   }
61 #pragma omp teams if(x) // expected-error {{unexpected OpenMP clause 'if' in directive '#pragma omp teams'}}
62   foo();
63 
64 #endif
65   return 0;
66 }
67