[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / OpenMP / distribute_parallel_for_messages.cpp
blob4416a38529af6fd752cf0e2a04d30dc3844e3b88
1 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp -ferror-limit 100 -std=c++11 -o - %s -fopenmp-version=45 -Wuninitialized
2 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp -fopenmp-version=50 -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
3 // RUN: %clang_cc1 -verify=expected,omp51 -fopenmp -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
5 // RUN: %clang_cc1 -verify=expected,omp45 -fopenmp-simd -ferror-limit 100 -std=c++11 -o - %s -fopenmp-version=45 -Wuninitialized
6 // RUN: %clang_cc1 -verify=expected,omp50 -fopenmp-simd -fopenmp-version=50 -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
7 // RUN: %clang_cc1 -verify=expected,omp51 -fopenmp-simd -ferror-limit 100 -std=c++11 -o - %s -Wuninitialized
9 void foo() {
12 void xxx(int argc) {
13 int x; // expected-note {{initialize the variable 'x' to silence this warning}}
14 #pragma omp distribute parallel for
15 for (int i = 0; i < 10; ++i)
16 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
19 #pragma omp distribute parallel for // expected-error {{unexpected OpenMP directive '#pragma omp distribute parallel for'}}
21 int main(int argc, char **argv) {
22 #pragma omp distribute parallel for order // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp distribute parallel for'}} expected-error {{expected '(' after 'order'}}
23 for (int i = 0; i < argc; ++i)
24 foo();
25 #pragma omp distribute parallel for order( // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}} omp51-error {{expected 'concurrent' in OpenMP clause 'order'}}
26 for (int i = 0; i < argc; ++i)
27 foo();
28 #pragma omp distribute parallel for order(none // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}} omp51-error {{expected 'concurrent' in OpenMP clause 'order'}}
29 for (int i = 0; i < argc; ++i)
30 foo();
31 #pragma omp distribute parallel for order(concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
32 for (int i = 0; i < argc; ++i)
33 foo();
34 #pragma omp distribute parallel for order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp distribute parallel for'}}
35 for (int i = 0; i < argc; ++i)
36 foo();
37 #pragma omp distribute parallel for order(unconstrained:) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp distribute parallel for'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}} omp51-error {{expected 'concurrent' in OpenMP clause 'order'}}
38 for (int i = 0; i < argc; ++i)
39 foo();
40 #pragma omp distribute parallel for order(reproducible:concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
41 for (int i = 0; i < argc; ++i)
42 foo();
43 #pragma omp distribute parallel for order(reproducible:concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp distribute parallel for'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
44 for (int i = 0; i < argc; ++i)
45 foo();
46 #pragma omp distribute parallel for order(unconstrained:concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp distribute parallel for'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
47 for (int i = 0; i < argc; ++i)
48 foo();
49 #pragma omp distribute parallel for order(concurrent) order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp distribute parallel for'}} omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp distribute parallel for'}} omp51-error {{directive '#pragma omp distribute parallel for' cannot contain more than one 'order' clause}}
50 for (int i = 0; i < argc; ++i)
51 foo();
52 #pragma omp target
53 #pragma omp teams
54 #pragma omp distribute parallel for { // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}
55 for (int i = 0; i < argc; ++i)
56 foo();
57 #pragma omp target
58 #pragma omp teams
59 #pragma omp distribute parallel for ( // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}
60 for (int i = 0; i < argc; ++i)
61 foo();
62 #pragma omp target
63 #pragma omp teams
64 #pragma omp distribute parallel for[ // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}
65 for (int i = 0; i < argc; ++i)
66 foo();
67 #pragma omp target
68 #pragma omp teams
69 #pragma omp distribute parallel for] // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}
70 for (int i = 0; i < argc; ++i)
71 foo();
72 #pragma omp target
73 #pragma omp teams
74 #pragma omp distribute parallel for) // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}
75 for (int i = 0; i < argc; ++i)
76 foo();
77 #pragma omp target
78 #pragma omp teams
79 #pragma omp distribute parallel for } // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}
80 for (int i = 0; i < argc; ++i)
81 foo();
82 #pragma omp target
83 #pragma omp teams
84 #pragma omp distribute parallel for linear(argc) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp distribute parallel for'}}
85 for (int i = 0; i < argc; ++i)
86 foo();
87 #pragma omp target
88 #pragma omp teams
89 #pragma omp distribute parallel for unknown() // expected-warning {{extra tokens at the end of '#pragma omp distribute parallel for' are ignored}}
90 for (int i = 0; i < argc; ++i)
91 foo();
92 L1:
93 for (int i = 0; i < argc; ++i)
94 foo();
95 #pragma omp target
96 #pragma omp teams
97 #pragma omp distribute parallel for
98 for (int i = 0; i < argc; ++i)
99 foo();
100 #pragma omp target
101 #pragma omp teams
102 #pragma omp distribute parallel for
103 for (int i = 0; i < argc; ++i) {
104 goto L1; // expected-error {{use of undeclared label 'L1'}}
105 argc++;
108 for (int i = 0; i < 10; ++i) {
109 switch (argc) {
110 case (0):
111 #pragma omp target
112 #pragma omp teams
113 #pragma omp distribute parallel for
114 for (int i = 0; i < argc; ++i) {
115 foo();
116 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
117 continue;
119 default:
120 break;
123 #pragma omp target
124 #pragma omp teams
125 #pragma omp distribute parallel for default(none) // expected-note {{explicit data sharing attribute requested here}}
126 for (int i = 0; i < 10; ++i)
127 ++argc; // expected-error {{variable 'argc' must have explicitly specified data sharing attributes}}
129 goto L2; // expected-error {{use of undeclared label 'L2'}}
130 #pragma omp target
131 #pragma omp teams
132 #pragma omp distribute parallel for
133 for (int i = 0; i < argc; ++i)
135 foo();
136 #pragma omp target
137 #pragma omp teams
138 #pragma omp distribute parallel for
139 for (int i = 0; i < argc; ++i) {
140 return 1; // expected-error {{cannot return from OpenMP region}}
143 [[]] // expected-error {{an attribute list cannot appear here}}
144 #pragma omp target
145 #pragma omp teams
146 #pragma omp distribute parallel for
147 for (int n = 0; n < 100; ++n) {
150 return 0;
153 void test_ordered() {
154 #pragma omp target
155 #pragma omp teams
156 #pragma omp distribute parallel for collapse(2) collapse(3) // expected-error {{directive '#pragma omp distribute parallel for' cannot contain more than one 'collapse' clause}}
157 for (int i = 0; i < 16; ++i)
158 for (int j = 0; j < 16; ++j)
162 void test_cancel() {
163 #pragma omp target
164 #pragma omp teams
165 #pragma omp distribute parallel for
166 for (int i = 0; i < 16; ++i)
167 for (int j = 0; j < 16; ++j) {
168 #pragma omp cancel for