1 // RUN: %clang_cc1 -verify -fopenmp -ferror-limit 100 -o - %s
2
3 int foo();
4
5 template <class T>
foo()6 T foo() {
7 T k;
8 #pragma omp for ordered
9 for (int i = 0; i < 10; ++i) {
10 L1:
11 foo();
12 #pragma omp ordered
13 {
14 foo();
15 goto L1; // expected-error {{use of undeclared label 'L1'}}
16 }
17 }
18 #pragma omp for ordered
19 for (int i = 0; i < 10; ++i) {
20 foo();
21 goto L2; // expected-error {{use of undeclared label 'L2'}}
22 #pragma omp ordered
23 {
24 L2:
25 foo();
26 }
27 }
28 #pragma omp for ordered
29 for (int i = 0; i < 10; ++i) {
30 #pragma omp ordered threads threads // expected-error {{directive '#pragma omp ordered' cannot contain more than one 'threads' clause}}
31 {
32 foo();
33 }
34 }
35 #pragma omp for ordered(1) // expected-note {{'ordered' clause with specified parameter}}
36 for (int i = 0; i < 10; ++i) {
37 #pragma omp ordered // expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}}
38 {
39 foo();
40 }
41 }
42 #pragma omp for ordered(1) // expected-note {{'ordered' clause with specified parameter}}
43 for (int i = 0; i < 10; ++i) {
44 #pragma omp ordered threads // expected-error {{'ordered' directive with 'threads' clause cannot be closely nested inside ordered region with specified parameter}}
45 {
46 foo();
47 }
48 }
49 #pragma omp ordered simd simd // expected-error {{directive '#pragma omp ordered' cannot contain more than one 'simd' clause}}
50 {
51 foo();
52 }
53 #pragma omp simd
54 for (int i = 0; i < 10; ++i) {
55 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
56 {
57 foo();
58 }
59 }
60 #pragma omp simd
61 for (int i = 0; i < 10; ++i) {
62 #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
63 {
64 foo();
65 }
66 }
67 #pragma omp for simd
68 for (int i = 0; i < 10; ++i) {
69 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
70 {
71 foo();
72 }
73 }
74 #pragma omp for simd
75 for (int i = 0; i < 10; ++i) {
76 #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
77 {
78 foo();
79 }
80 }
81 #pragma omp parallel for simd
82 for (int i = 0; i < 10; ++i) {
83 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
84 {
85 foo();
86 }
87 }
88 #pragma omp parallel for simd
89 for (int i = 0; i < 10; ++i) {
90 #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
91 {
92 foo();
93 }
94 #pragma omp ordered depend(source) // expected-error {{OpenMP constructs may not be nested inside a simd region}}
95 }
96 #pragma omp parallel for ordered
97 for (int i = 0; i < 10; ++i) {
98 #pragma omp ordered depend(source) // expected-error {{'ordered' directive with 'depend' clause cannot be closely nested inside ordered region without specified parameter}}
99 #pragma omp ordered depend(sink : i) // expected-error {{'ordered' directive with 'depend' clause cannot be closely nested inside ordered region without specified parameter}}
100 }
101 #pragma omp parallel for ordered(2) // expected-note 5 {{'ordered' clause with specified parameter}}
102 for (int i = 0; i < 10; ++i) {
103 for (int j = 0; j < 10; ++j) {
104 #pragma omp ordered depend // expected-error {{expected '(' after 'depend'}} expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}}
105 #pragma omp ordered depend( // expected-error {{expected ')'}} expected-error {{expected 'source' or 'sink' in OpenMP clause 'depend'}} expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}} expected-warning {{missing ':' or ')' after dependency type - ignoring}} expected-note {{to match this '('}}
106 #pragma omp ordered depend(source // expected-error {{expected ')'}} expected-note {{to match this '('}}
107 #pragma omp ordered depend(sink // expected-error {{expected expression}} expected-warning {{missing ':' or ')' after dependency type - ignoring}} expected-error {{expected ')'}} expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}} expected-note {{to match this '('}}
108 #pragma omp ordered depend(sink : // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}}
109 #pragma omp ordered depend(sink : i // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'j' loop iteration variable}}
110 #pragma omp ordered depend(sink : i) // expected-error {{expected 'j' loop iteration variable}}
111 #pragma omp ordered depend(source)
112 if (i == j)
113 #pragma omp ordered depend(source) // expected-error {{'#pragma omp ordered' with 'depend' clause cannot be an immediate substatement}}
114 ;
115 if (i == j)
116 #pragma omp ordered depend(sink : i, j) // expected-error {{'#pragma omp ordered' with 'depend' clause cannot be an immediate substatement}}
117 ;
118 #pragma omp ordered depend(source) threads // expected-error {{'depend' clauses cannot be mixed with 'threads' clause}}
119 #pragma omp ordered simd depend(source) // expected-error {{'depend' clauses cannot be mixed with 'simd' clause}}
120 #pragma omp ordered depend(source) depend(source) // expected-error {{directive '#pragma omp ordered' cannot contain more than one 'depend' clause with 'source' dependence}}
121 #pragma omp ordered depend(in : i) // expected-error {{expected 'source' or 'sink' in OpenMP clause 'depend'}} expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}}
122 #pragma omp ordered depend(sink : i, j)
123 #pragma omp ordered depend(sink : j, i) // expected-error {{expected 'i' loop iteration variable}} expected-error {{expected 'j' loop iteration variable}}
124 #pragma omp ordered depend(sink : i, j, k) // expected-error {{unexpected expression: number of expressions is larger than the number of associated loops}}
125 #pragma omp ordered depend(sink : i+foo(), j/4) // expected-error {{expression is not an integral constant expression}} expected-error {{expected '+' or '-' operation}}
126 #pragma omp ordered depend(sink : i*0, j-4)// expected-error {{expected '+' or '-' operation}}
127 #pragma omp ordered depend(sink : i-0, j+sizeof(T)) depend(sink : i-0, j+sizeof(T))
128 #pragma omp ordered depend(sink : i-0, j+sizeof(T)) depend(source) // expected-error {{'depend(source)' clause cannot be mixed with 'depend(sink:vec)' clauses}}
129 #pragma omp ordered depend(source) depend(sink : i-0, j+sizeof(T)) // expected-error {{'depend(sink:vec)' clauses cannot be mixed with 'depend(source)' clause}}
130 }
131 }
132 return T();
133 }
134
foo()135 int foo() {
136 int k;
137 #pragma omp for ordered
138 for (int i = 0; i < 10; ++i) {
139 L1:
140 foo();
141 #pragma omp ordered
142 {
143 foo();
144 goto L1; // expected-error {{use of undeclared label 'L1'}}
145 }
146 }
147 #pragma omp for ordered
148 for (int i = 0; i < 10; ++i) {
149 foo();
150 goto L2; // expected-error {{use of undeclared label 'L2'}}
151 #pragma omp ordered
152 {
153 L2:
154 foo();
155 }
156 }
157 #pragma omp for ordered
158 for (int i = 0; i < 10; ++i) {
159 #pragma omp ordered threads threads // expected-error {{directive '#pragma omp ordered' cannot contain more than one 'threads' clause}}
160 {
161 foo();
162 }
163 }
164 #pragma omp for ordered(1) // expected-note {{'ordered' clause with specified parameter}}
165 for (int i = 0; i < 10; ++i) {
166 #pragma omp ordered // expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}}
167 {
168 foo();
169 }
170 }
171 #pragma omp for ordered(1) // expected-note {{'ordered' clause with specified parameter}}
172 for (int i = 0; i < 10; ++i) {
173 #pragma omp ordered threads // expected-error {{'ordered' directive with 'threads' clause cannot be closely nested inside ordered region with specified parameter}}
174 {
175 foo();
176 }
177 }
178 #pragma omp ordered simd simd // expected-error {{directive '#pragma omp ordered' cannot contain more than one 'simd' clause}}
179 {
180 foo();
181 }
182 #pragma omp simd
183 for (int i = 0; i < 10; ++i) {
184 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
185 {
186 foo();
187 }
188 }
189 #pragma omp simd
190 for (int i = 0; i < 10; ++i) {
191 #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
192 {
193 foo();
194 }
195 }
196 #pragma omp for simd
197 for (int i = 0; i < 10; ++i) {
198 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
199 {
200 foo();
201 }
202 }
203 #pragma omp for simd
204 for (int i = 0; i < 10; ++i) {
205 #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
206 {
207 foo();
208 }
209 }
210 #pragma omp parallel for simd
211 for (int i = 0; i < 10; ++i) {
212 #pragma omp ordered // expected-error {{OpenMP constructs may not be nested inside a simd region}}
213 {
214 foo();
215 }
216 }
217 #pragma omp parallel for simd
218 for (int i = 0; i < 10; ++i) {
219 #pragma omp ordered threads // expected-error {{OpenMP constructs may not be nested inside a simd region}}
220 {
221 foo();
222 }
223 #pragma omp ordered depend(source) // expected-error {{OpenMP constructs may not be nested inside a simd region}}
224 }
225 #pragma omp parallel for ordered
226 for (int i = 0; i < 10; ++i) {
227 #pragma omp ordered depend(source) // expected-error {{'ordered' directive with 'depend' clause cannot be closely nested inside ordered region without specified parameter}}
228 #pragma omp ordered depend(sink : i) // expected-error {{'ordered' directive with 'depend' clause cannot be closely nested inside ordered region without specified parameter}}
229 }
230 #pragma omp parallel for ordered(2) // expected-note 5 {{'ordered' clause with specified parameter}}
231 for (int i = 0; i < 10; ++i) {
232 for (int j = 0; j < 10; ++j) {
233 #pragma omp ordered depend // expected-error {{expected '(' after 'depend'}} expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}}
234 #pragma omp ordered depend( // expected-error {{expected ')'}} expected-error {{expected 'source' or 'sink' in OpenMP clause 'depend'}} expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}} expected-warning {{missing ':' or ')' after dependency type - ignoring}} expected-note {{to match this '('}}
235 #pragma omp ordered depend(source // expected-error {{expected ')'}} expected-note {{to match this '('}}
236 #pragma omp ordered depend(sink // expected-error {{expected expression}} expected-warning {{missing ':' or ')' after dependency type - ignoring}} expected-error {{expected ')'}} expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}} expected-note {{to match this '('}}
237 #pragma omp ordered depend(sink : // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}} expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}}
238 #pragma omp ordered depend(sink : i // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected 'j' loop iteration variable}}
239 #pragma omp ordered depend(sink : i) // expected-error {{expected 'j' loop iteration variable}}
240 #pragma omp ordered depend(source)
241 if (i == j)
242 #pragma omp ordered depend(source) // expected-error {{'#pragma omp ordered' with 'depend' clause cannot be an immediate substatement}}
243 ;
244 if (i == j)
245 #pragma omp ordered depend(sink : i, j) // expected-error {{'#pragma omp ordered' with 'depend' clause cannot be an immediate substatement}}
246 ;
247 #pragma omp ordered depend(source) threads // expected-error {{'depend' clauses cannot be mixed with 'threads' clause}}
248 #pragma omp ordered simd depend(source) // expected-error {{'depend' clauses cannot be mixed with 'simd' clause}}
249 #pragma omp ordered depend(source) depend(source) // expected-error {{directive '#pragma omp ordered' cannot contain more than one 'depend' clause with 'source' dependence}}
250 #pragma omp ordered depend(in : i) // expected-error {{expected 'source' or 'sink' in OpenMP clause 'depend'}} expected-error {{'ordered' directive without any clauses cannot be closely nested inside ordered region with specified parameter}}
251 #pragma omp ordered depend(sink : i, j)
252 #pragma omp ordered depend(sink : j, i) // expected-error {{expected 'i' loop iteration variable}} expected-error {{expected 'j' loop iteration variable}}
253 #pragma omp ordered depend(sink : i, j, k) // expected-error {{unexpected expression: number of expressions is larger than the number of associated loops}}
254 #pragma omp ordered depend(sink : i+foo(), j/4) // expected-error {{expression is not an integral constant expression}} expected-error {{expected '+' or '-' operation}}
255 #pragma omp ordered depend(sink : i*0, j-4)// expected-error {{expected '+' or '-' operation}}
256 #pragma omp ordered depend(sink : i-0, j+sizeof(int)) depend(sink : i-0, j+sizeof(int))
257 #pragma omp ordered depend(sink : i-0, j+sizeof(int)) depend(source) // expected-error {{'depend(source)' clause cannot be mixed with 'depend(sink:vec)' clauses}}
258 #pragma omp ordered depend(source) depend(sink : i-0, j+sizeof(int)) // expected-error {{'depend(sink:vec)' clauses cannot be mixed with 'depend(source)' clause}}
259 }
260 }
261
262 return foo<int>(); // expected-note {{in instantiation of function template specialization 'foo<int>' requested here}}
263 }
264