Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / OpenMP / teams_distribute_parallel_for_messages.cpp
blobdf75759bcda99b2c98a0df5387e6957ffb1bb4c2
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 -fopenmp-version=51 -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 -fopenmp-version=51 -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
12 #pragma omp teams distribute parallel for
13 for (int i = 0; i < 10; ++i)
14 argc = x; // expected-warning {{variable 'x' is uninitialized when used here}}
17 void foo() {
20 static int pvt;
21 #pragma omp threadprivate(pvt)
23 #pragma omp teams distribute parallel for // expected-error {{unexpected OpenMP directive '#pragma omp teams distribute parallel for'}}
25 int main(int argc, char **argv) {
26 #pragma omp target
27 #pragma omp teams distribute parallel for
28 f; // expected-error {{use of undeclared identifier 'f'}}
29 #pragma omp target
30 #pragma omp teams distribute parallel for { // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
31 for (int i = 0; i < argc; ++i)
32 foo();
33 #pragma omp target
34 #pragma omp teams distribute parallel for ( // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
35 for (int i = 0; i < argc; ++i)
36 foo();
37 #pragma omp target
38 #pragma omp teams distribute parallel for[ // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
39 for (int i = 0; i < argc; ++i)
40 foo();
41 #pragma omp target
42 #pragma omp teams distribute parallel for] // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
43 for (int i = 0; i < argc; ++i)
44 foo();
45 #pragma omp target
46 #pragma omp teams distribute parallel for) // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
47 for (int i = 0; i < argc; ++i)
48 foo();
49 #pragma omp target
50 #pragma omp teams distribute parallel for } // expected-warning {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
51 for (int i = 0; i < argc; ++i)
52 foo();
53 #pragma omp target
54 #pragma omp teams distribute parallel for linear(argc) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp teams distribute parallel for'}}
55 for (int i = 0; i < argc; ++i)
56 foo();
57 // expected-warning@+2 {{extra tokens at the end of '#pragma omp teams distribute parallel for' are ignored}}
58 #pragma omp target
59 #pragma omp teams distribute parallel for unknown()
60 for (int i = 0; i < argc; ++i)
61 foo();
62 L1:
63 for (int i = 0; i < argc; ++i)
64 foo();
65 #pragma omp target
66 #pragma omp teams distribute parallel for
67 for (int i = 0; i < argc; ++i)
68 foo();
69 #pragma omp target
70 #pragma omp teams distribute parallel for
71 for (int i = 0; i < argc; ++i) {
72 goto L1; // expected-error {{use of undeclared label 'L1'}}
73 argc++;
76 for (int i = 0; i < 10; ++i) {
77 switch (argc) {
78 case (0):
79 #pragma omp target
80 #pragma omp teams distribute parallel for
81 for (int i = 0; i < argc; ++i) {
82 foo();
83 break; // expected-error {{'break' statement cannot be used in OpenMP for loop}}
84 continue;
86 default:
87 break;
90 #pragma omp target
91 #pragma omp teams distribute parallel for default(none) // expected-note {{explicit data sharing attribute requested here}}
92 for (int i = 0; i < 10; ++i)
93 ++argc; // expected-error {{ariable 'argc' must have explicitly specified data sharing attributes}}
95 goto L2; // expected-error {{use of undeclared label 'L2'}}
96 #pragma omp target
97 #pragma omp teams distribute parallel for
98 for (int i = 0; i < argc; ++i)
99 L2:
100 foo();
101 #pragma omp target
102 #pragma omp teams distribute parallel for
103 for (int i = 0; i < argc; ++i) {
104 return 1; // expected-error {{cannot return from OpenMP region}}
107 [[]] // expected-error {{an attribute list cannot appear here}}
108 #pragma omp target
109 #pragma omp teams distribute parallel for
110 for (int n = 0; n < 100; ++n) {
113 #pragma omp target
114 #pragma omp teams distribute parallel for copyin(pvt)
115 for (int n = 0; n < 100; ++n) {}
117 return 0;
120 void test_ordered() {
121 #pragma omp target
122 #pragma omp teams distribute parallel for ordered // expected-error {{unexpected OpenMP clause 'ordered' in directive '#pragma omp teams distribute parallel for'}}
123 for (int i = 0; i < 16; ++i)
125 #pragma omp target
126 #pragma omp teams distribute parallel for order // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} expected-error {{expected '(' after 'order'}}
127 for (int i = 0; i < 10; ++i)
129 #pragma omp target
130 #pragma omp teams distribute parallel for order( // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp5-error {{expected 'concurrent' in OpenMP clause 'order'}}
131 for (int i = 0; i < 10; ++i)
133 #pragma omp target
134 #pragma omp teams distribute parallel for order(none // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp5-error {{expected 'concurrent' in OpenMP clause 'order'}}
135 for (int i = 0; i < 10; ++i)
137 #pragma omp target
138 #pragma omp teams distribute parallel for order(concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}}
139 for (int i = 0; i < 10; ++i)
141 #pragma omp target
142 #pragma omp teams distribute parallel for order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}}
143 for (int i = 0; i < 10; ++i)
145 #pragma omp target
146 #pragma omp teams distribute parallel for order(unconstrained:) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} omp5-error {{expected 'concurrent' in OpenMP clause 'order'}}
147 for (int i = 0; i < 10; ++i)
149 #pragma omp target
150 #pragma omp teams distribute parallel for order(reproducible:concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
151 for (int i = 0; i < 10; ++i)
153 #pragma omp target
154 #pragma omp teams distribute parallel for order(reproducible:concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
155 for (int i = 0; i < 10; ++i)
157 #pragma omp target
158 #pragma omp teams distribute parallel for order(unconstrained:concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}}
159 for (int i = 0; i < 10; ++i)
161 #pragma omp target
162 #pragma omp teams distribute parallel for order(concurrent) order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp teams distribute parallel for'}} omp51-error {{directive '#pragma omp teams distribute parallel for' cannot contain more than one 'order' clause}}
163 for (int i = 0; i < 10; ++i)
167 void test_cancel() {
168 #pragma omp target
169 #pragma omp teams distribute parallel for
170 for (int i = 0; i < 16; ++i) {
171 #pragma omp cancel for