[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / target_teams_distribute_parallel_for_messages.cpp
blobb0ec2ba12f234a38a6ac3ed0b3a323b42da2c4f3
1 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -fopenmp-version=45 -std=c++11 %s -Wuninitialized
2 // RUN: %clang_cc1 -verify=expected,omp5,omp50 -fopenmp -fopenmp-version=50 -std=c++11 %s -Wuninitialized
3 // RUN: %clang_cc1 -verify=expected,omp5,omp51 -fopenmp -std=c++11 %s -Wuninitialized
5 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -fopenmp-version=45 -std=c++11 %s -Wuninitialized
6 // RUN: %clang_cc1 -verify=expected,omp5,omp50 -fopenmp-simd -fopenmp-version=50 -std=c++11 %s -Wuninitialized
7 // RUN: %clang_cc1 -verify=expected,omp5,omp51 -fopenmp-simd -std=c++11 %s -Wuninitialized
9 void xxx(int argc) {
10 int x; // expected-note {{initialize the variable 'x' to silence this warning}}
11 #pragma omp target teams distribute parallel for
12 for (int i = 0; i < 10; ++i)
13 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
16 void foo() {
19 static int pvt;
20 #pragma omp threadprivate(pvt)
22 #pragma omp target teams distribute parallel for // expected-error {{unexpected OpenMP directive '#pragma omp target teams distribute parallel for'}}
24 int main(int argc, char **argv) {
25 #pragma omp target teams distribute parallel for { // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute parallel for' are ignored}}
26 for (int i = 0; i < argc; ++i)
27 foo();
28 #pragma omp target teams distribute parallel for ( // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute parallel for' are ignored}}
29 for (int i = 0; i < argc; ++i)
30 foo();
31 #pragma omp target teams distribute parallel for[ // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute parallel for' are ignored}}
32 for (int i = 0; i < argc; ++i)
33 foo();
34 #pragma omp target teams distribute parallel for] // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute parallel for' are ignored}}
35 for (int i = 0; i < argc; ++i)
36 foo();
37 #pragma omp target teams distribute parallel for) // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute parallel for' are ignored}}
38 for (int i = 0; i < argc; ++i)
39 foo();
40 #pragma omp target teams distribute parallel for } // expected-warning {{extra tokens at the end of '#pragma omp target teams distribute parallel for' are ignored}}
41 for (int i = 0; i < argc; ++i)
42 foo();
43 #pragma omp target teams distribute parallel for linear(argc) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp target teams distribute parallel for'}}
44 for (int i = 0; i < argc; ++i)
45 foo();
46 // expected-warning@+1 {{extra tokens at the end of '#pragma omp target teams distribute parallel for' are ignored}}
47 #pragma omp target teams distribute parallel for unknown()
48 for (int i = 0; i < argc; ++i)
49 foo();
50 L1:
51 for (int i = 0; i < argc; ++i)
52 foo();
53 #pragma omp target teams distribute parallel for
54 for (int i = 0; i < argc; ++i)
55 foo();
56 #pragma omp target teams distribute parallel for
57 for (int i = 0; i < argc; ++i) {
58 goto L1; // expected-error {{use of undeclared label 'L1'}}
59 argc++;
62 for (int i = 0; i < 10; ++i) {
63 switch (argc) {
64 case (0):
65 #pragma omp target teams distribute parallel for
66 for (int i = 0; i < argc; ++i) {
67 foo();
68 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
69 continue;
71 default:
72 break;
75 #pragma omp target teams distribute parallel for default(none) // expected-note {{explicit data sharing attribute requested here}}
76 for (int i = 0; i < 10; ++i)
77 ++argc; // expected-error {{ariable 'argc' must have explicitly specified data sharing attributes}}
79 goto L2; // expected-error {{use of undeclared label 'L2'}}
80 #pragma omp target teams distribute parallel for
81 for (int i = 0; i < argc; ++i)
82 L2: foo();
84 #pragma omp target teams distribute parallel for
85 for (int i = 0; i < argc; ++i) {
86 return 1; // expected-error {{cannot return from OpenMP region}}
89 [[]] // expected-error {{an attribute list cannot appear here}}
90 #pragma omp target teams distribute parallel for
91 for (int n = 0; n < 100; ++n) {
94 #pragma omp target teams distribute parallel for copyin(pvt) // expected-error {{unexpected OpenMP clause 'copyin' in directive '#pragma omp target teams distribute parallel for'}}
95 for (int n = 0; n < 100; ++n) {}
97 return 0;
100 void test_ordered() {
101 #pragma omp target teams distribute parallel for ordered // expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp target teams distribute parallel for'}}
102 for (int i = 0; i < 16; ++i)
104 #pragma omp target teams distribute parallel for order // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target teams distribute parallel for'}} expected-error {{expected '(' after 'order'}}
105 for (int i = 0; i < 10; ++i)
107 #pragma omp target teams distribute parallel for order( // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target teams distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp5-error {{expected 'concurrent' in OpenMP clause 'order'}}
108 for (int i = 0; i < 10; ++i)
110 #pragma omp target teams distribute parallel for order(none // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target teams distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp5-error {{expected 'concurrent' in OpenMP clause 'order'}}
111 for (int i = 0; i < 10; ++i)
113 #pragma omp target teams distribute parallel for order(concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target teams distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
114 for (int i = 0; i < 10; ++i)
116 #pragma omp target teams distribute parallel for order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target teams distribute parallel for'}}
117 for (int i = 0; i < 10; ++i)
119 #pragma omp target teams distribute parallel for order(unconstrained:) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target teams distribute parallel for'}} omp5-error {{expected 'concurrent' in OpenMP clause 'order'}}
120 for (int i = 0; i < 10; ++i)
122 #pragma omp target teams distribute parallel for order(reproducible:concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target teams distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
123 for (int i = 0; i < 10; ++i)
125 #pragma omp target teams distribute parallel for order(reproducible:concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target teams distribute parallel for'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
126 for (int i = 0; i < 10; ++i)
128 #pragma omp target teams distribute parallel for order(unconstrained:concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target teams distribute parallel for'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
129 for (int i = 0; i < 10; ++i)
131 #pragma omp target teams distribute parallel for order(concurrent) order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target teams distribute parallel for'}} omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp target teams distribute parallel for'}} omp51-error {{directive '#pragma omp target teams distribute parallel for' cannot contain more than one 'order' clause}}
132 for (int i = 0; i < 10; ++i)