[LLVM] Fix Maintainers.md formatting (NFC)
[llvm-project.git] / flang / test / HLFIR / invalid.fir
blobc390dddcf3f3873c3197cfd3a65d3dd1dc2f6f1e
1 // HLFIR ops diagnotic tests
3 // RUN: fir-opt -strict-intrinsic-verifier -split-input-file -verify-diagnostics %s
5 func.func @bad_declare(%arg0: !fir.ref<f32>) {
6   // expected-error@+1 {{'hlfir.declare' op first result type is inconsistent with variable properties: expected '!fir.ref<f32>'}}
7   %0:2 = hlfir.declare %arg0 {uniq_name = "x"} : (!fir.ref<f32>) -> (!fir.box<f32>, !fir.ref<f32>)
8   return
11 // -----
12 func.func @bad_declare_lower_bounds(%arg0: !fir.ref<!fir.array<2x4xf32>>) {
13   %c1 = arith.constant 1 : index
14   %c2 = arith.constant 2 : index
15   %c3 = arith.constant 3 : index
16   %c4 = arith.constant 4 : index
17   %shape = fir.shape_shift %c1, %c2, %c3, %c4 : (index, index, index, index) -> !fir.shapeshift<2>
18   // expected-error@+1 {{'hlfir.declare' op first result type is inconsistent with variable properties: expected '!fir.box<!fir.array<2x4xf32>>'}}
19   %0:2 = hlfir.declare %arg0(%shape) {uniq_name = "x"} : (!fir.ref<!fir.array<2x4xf32>>, !fir.shapeshift<2>) -> (!fir.ref<!fir.array<2x4xf32>>, !fir.ref<!fir.array<2x4xf32>>)
20   return
23 // -----
24 func.func @bad_declare(%arg0: !fir.ref<f32>) {
25   // expected-error@+1 {{'hlfir.declare' op second result type must match input memref type}}
26   %0:2 = hlfir.declare %arg0 {uniq_name = "x"} : (!fir.ref<f32>) -> (!fir.ref<i32>, !fir.ref<i32>)
27   return
30 // -----
32 // Test that FortranVariableInterface verifier is kicking in. This verifier itself is already tested with fir.declare.
33 func.func @bad_array_declare(%arg0: !fir.ref<!fir.array<?x?xf32>>) {
34   // expected-error@+1 {{'hlfir.declare' op of array entity with a raw address base must have a shape operand that is a shape or shapeshift}}
35   %0:2 = hlfir.declare %arg0 {uniq_name = "x"} : (!fir.ref<!fir.array<?x?xf32>>) -> (!fir.box<!fir.array<?x?xf32>>, !fir.ref<!fir.array<?x?xf32>>)
36   return
39 // -----
40 func.func @bad_assign_scalar_character(%arg0: !fir.boxchar<1>, %arg1: !fir.char<1,?>) {
41   // expected-error@+1 {{'hlfir.assign' op operand #0 must be any Fortran value or variable type, but got '!fir.char<1,?>'}}
42   hlfir.assign %arg1 to %arg0 : !fir.char<1,?>, !fir.boxchar<1>
43   return
46 // -----
47 func.func @bad_assign_scalar_character_1(%arg0: !fir.boxchar<1>, %arg1: !hlfir.expr<!fir.char<1,?>>) {
48   // expected-error@+1 {{'hlfir.assign' op operand #1 must be any HLFIR variable type, but got '!hlfir.expr<!fir.char<1,?>>'}}
49   hlfir.assign %arg0 to %arg1 : !fir.boxchar<1>, !hlfir.expr<!fir.char<1,?>>
50   return
53 // -----
54 func.func @bad_assign_scalar_integer(%arg0: !fir.ref<i32>, %arg1: i32) {
55   // expected-error@+1 {{'hlfir.assign' op operand #1 must be any HLFIR variable type, but got 'i32'}}
56   hlfir.assign %arg0 to %arg1 : !fir.ref<i32>, i32
57   return
60 // -----
61 func.func @bad_assign_array(%arg0: !fir.ref<!fir.array<?xi32>>, %arg1: !hlfir.expr<?xi32>) {
62   // expected-error@+1 {{'hlfir.assign' op operand #1 must be any HLFIR variable type, but got '!fir.ref<!fir.array<?xi32>>'}}
63   hlfir.assign %arg1 to %arg0 : !hlfir.expr<?xi32>, !fir.ref<!fir.array<?xi32>>
64   return
67 // -----
68 func.func @bad_assign_array_2(%arg0: !fir.ref<!fir.array<10xi32>>, %arg1: !hlfir.expr<?xi32>) {
69   // expected-error@+1 {{'hlfir.assign' op operand #1 must be any HLFIR variable type, but got '!hlfir.expr<?xi32>'}}
70   hlfir.assign %arg0 to %arg1 : !fir.ref<!fir.array<10xi32>>, !hlfir.expr<?xi32>
71   return
74 // -----
75 func.func @bad_designate_component(%arg0 : !fir.ref<i32>) {
76   // expected-error@+1 {{'hlfir.designate' op component must be provided only when the memref is a derived type}}
77   %0 = hlfir.designate %arg0 {"some_component"} :  (!fir.ref<i32>) -> !fir.ref<i32>
78   return
81 // -----
82 func.func @bad_designate_component_2(%arg0 : !fir.ref<!fir.type<t{i:i32}>>) {
83   // expected-error@+1 {{'hlfir.designate' op component "bad_comp" is not a component of memref element type '!fir.type<t{i:i32}>'}}
84   %0 = hlfir.designate %arg0 {"bad_comp"} :  (!fir.ref<!fir.type<t{i:i32}>>) -> !fir.ref<i32>
85   return
88 // -----
89 func.func @bad_designate_component_3(%arg0 : !fir.ref<!fir.array<20x!fir.type<t{i:!fir.array<100xi32>}>>>) {
90   // expected-error@+1 {{'hlfir.designate' op indices must be provided and must not contain triplets when both memref and component are arrays}}
91   %0 = hlfir.designate %arg0 {"i"} :  (!fir.ref<!fir.array<20x!fir.type<t{i:!fir.array<100xi32>}>>>) -> !fir.ref<i32>
92   return
95 // -----
96 func.func @bad_designate_component_4(%arg0 : !fir.ref<!fir.array<20x!fir.type<t{i:!fir.array<100xi32>}>>>) {
97   %component_shape = fir.undefined !fir.shape<1>
98   %c1 = arith.constant 1 : index
99   // expected-error@+1 {{'hlfir.designate' op indices must be provided and must not contain triplets when both memref and component are arrays}}
100   %0 = hlfir.designate %arg0 {"i"}<%component_shape>(%c1:%c1:%c1):  (!fir.ref<!fir.array<20x!fir.type<t{i:!fir.array<100xi32>}>>>, !fir.shape<1>, index, index, index) -> !fir.ref<!fir.array<20xi32>>
101   return
104 // -----
105 func.func @bad_designate_component_5(%arg0 : !fir.ref<!fir.array<20x!fir.type<t{i:!fir.array<100xi32>}>>>) {
106   %component_shape = fir.undefined !fir.shape<2>
107   %c1 = arith.constant 1 : index
108   // expected-error@+1 {{'hlfir.designate' op component_shape must be a fir.shape or fir.shapeshift with the rank of the component}}
109   %0 = hlfir.designate %arg0 {"i"}<%component_shape>(%c1):  (!fir.ref<!fir.array<20x!fir.type<t{i:!fir.array<100xi32>}>>>, !fir.shape<2>, index) -> !fir.ref<!fir.array<20xi32>>
110   return
113 // -----
114 func.func @bad_designate_component_6(%arg0 : !fir.ref<!fir.array<20x!fir.type<t{i:!fir.array<100xi32>}>>>) {
115   %component_shape = fir.undefined !fir.shift<1>
116   %c1 = arith.constant 1 : index
117   // expected-error@+1 {{'hlfir.designate' op component_shape must be a fir.shape or fir.shapeshift with the rank of the component}}
118   %0 = hlfir.designate %arg0 {"i"}<%component_shape>(%c1):  (!fir.ref<!fir.array<20x!fir.type<t{i:!fir.array<100xi32>}>>>, !fir.shift<1>, index) -> !fir.ref<!fir.array<20xi32>>
119   return
122 // -----
123 func.func @bad_designate_component_7(%arg0 : !fir.ref<!fir.array<20x!fir.type<t{i:!fir.array<100xi32>}>>>) {
124   %component_shape = fir.undefined !fir.shapeshift<2>
125   %c1 = arith.constant 1 : index
126   // expected-error@+1 {{'hlfir.designate' op component_shape must be a fir.shape or fir.shapeshift with the rank of the component}}
127   %0 = hlfir.designate %arg0 {"i"}<%component_shape>(%c1):  (!fir.ref<!fir.array<20x!fir.type<t{i:!fir.array<100xi32>}>>>, !fir.shapeshift<2>, index) -> !fir.ref<!fir.array<20xi32>>
128   return
131 // -----
132 func.func @bad_designate_component_8(%arg0 : !fir.ref<!fir.type<t{i:!fir.array<100xi32>}>>) {
133   %c1 = arith.constant 1 : index
134   // expected-error@+1 {{'hlfir.designate' op component_shape must be provided when indexing a component}}
135   %0 = hlfir.designate %arg0 {"i"}(%c1):  (!fir.ref<!fir.type<t{i:!fir.array<100xi32>}>>, index) -> !fir.ref<i32>
136   return
139 // -----
140 func.func @bad_designate_component_9(%arg0 : !fir.ref<!fir.array<20x!fir.type<t{i:i32}>>>) {
141   %c1 = arith.constant 1 : index
142   // expected-error@+1 {{'hlfir.designate' op indices must not be provided if component appears and is not an array component}}
143   %0 = hlfir.designate %arg0 {"i"}(%c1):  (!fir.ref<!fir.array<20x!fir.type<t{i:i32}>>>, index) -> !fir.ref<i32>
144   return
147 // -----
148 func.func @bad_designate_component_10(%arg0 : !fir.ref<!fir.type<t{i:!fir.array<100xi32>}>>) {
149   %component_shape = fir.undefined !fir.shapeshift<1>
150   %c1 = arith.constant 1 : index
151   // expected-error@+1 {{'hlfir.designate' op indices number must match array component rank}}
152   %0 = hlfir.designate %arg0 {"i"}<%component_shape>(%c1, %c1):  (!fir.ref<!fir.type<t{i:!fir.array<100xi32>}>>, !fir.shapeshift<1>, index, index) -> !fir.ref<i32>
153   return
156 // -----
157 func.func @bad_designate_substring_1(%arg0 : !fir.ref<!fir.char<1,20>>) {
158   %c1 = arith.constant 1 : index
159   // expected-error@+1 {{'hlfir.designate' op substring must contain 2 indices when provided}}
160   %0 = hlfir.designate %arg0 substr %c1, %c1, %c1:  (!fir.ref<!fir.char<1,20>>, index, index, index) -> !fir.boxchar<1>
161   return
164 // -----
165 func.func @bad_designate_indices_1(%arg0 : !fir.ref<i32>) {
166   %c1 = arith.constant 1 : index
167   // expected-error@+1 {{'hlfir.designate' op indices number must match memref rank}}
168   %0 = hlfir.designate %arg0 (%c1, %c1):  (!fir.ref<i32>, index, index) -> !fir.ref<i32>
169   return
172 // -----
173 func.func @bad_designate_indices_2(%arg0 : !fir.ref<!fir.array<10xi32>>) {
174   %c1 = arith.constant 1 : index
175   // expected-error@+1 {{'hlfir.designate' op indices number must match memref rank}}
176   %0 = hlfir.designate %arg0 (%c1, %c1):  (!fir.ref<!fir.array<10xi32>>, index, index) -> !fir.ref<i32>
177   return
180 // -----
181 func.func @bad_designate_substring_2(%arg0 : !fir.ref<i32>) {
182   %c1 = arith.constant 1 : index
183   // expected-error@+1 {{'hlfir.designate' op memref or component must have character type if substring indices are provided}}
184   %0 = hlfir.designate %arg0 substr %c1, %c1:  (!fir.ref<i32>, index, index) -> !fir.boxchar<1>
185   return
188 // -----
189 func.func @bad_designate_cmplx_part(%arg0 : !fir.ref<!fir.array<10xi32>>) {
190   %c1 = arith.constant 1 : index
191   // expected-error@+1 {{'hlfir.designate' op memref or component must have complex type if complex_part is provided}}
192   %0 = hlfir.designate %arg0 (%c1) imag:  (!fir.ref<!fir.array<10xi32>>, index) -> !fir.ref<i32>
193   return
196 // -----
197 func.func @bad_designate_out_rank(%arg0 : !fir.ref<!fir.array<10xi32>>) {
198   %c1 = arith.constant 1 : index
199   // expected-error@+1 {{'hlfir.designate' op result type rank is not consistent with operands, expected rank 1}}
200   %0 = hlfir.designate %arg0 (%c1:%c1:%c1):  (!fir.ref<!fir.array<10xi32>>, index, index, index) -> !fir.ref<i32>
201   return
204 // -----
205 func.func @bad_designate_out_type(%arg0 : !fir.ref<complex<f32>>) {
206   // expected-error@+1 {{'hlfir.designate' op result element type is not consistent with operands, expected 'f32'}}
207   %0 = hlfir.designate %arg0 imag:  (!fir.ref<complex<f32>>) -> !fir.ref<complex<f64>>
208   return
211 // -----
212 func.func @bad_designate_out_type(%arg0 : !fir.ref<!fir.box<complex<f32>>>) {
213   // expected-error@+1 {{'hlfir.designate' op result type must only be a box address type if it designates a component that is a fir.box or fir.class and if there are no indices, substrings, and complex part}}
214   %0 = hlfir.designate %arg0 imag:  (!fir.ref<!fir.box<complex<f32>>>) -> !fir.ref<!fir.box<f32>>
215   return
218 // -----
219 func.func @bad_designate_shape(%arg0 : !fir.ref<!fir.array<10xi32>>) {
220   %c1 = arith.constant 1 : index
221   // expected-error@+1 {{'hlfir.designate' op shape must be provided if and only if the result is an array that is not a box address}}
222   %0 = hlfir.designate %arg0 (%c1:%c1:%c1):  (!fir.ref<!fir.array<10xi32>>, index, index, index) -> !fir.box<!fir.array<?xi32>>
223   return
226 // -----
227 func.func @bad_designate_shape_2(%arg0 : !fir.ref<!fir.array<10xi32>>) {
228   %c1 = arith.constant 1 : index
229   %shape = fir.undefined !fir.shape<1>
230   // expected-error@+1 {{'hlfir.designate' op shape must be provided if and only if the result is an array that is not a box address}}
231   %0 = hlfir.designate %arg0 (%c1) shape %shape:  (!fir.ref<!fir.array<10xi32>>, index, !fir.shape<1>) -> !fir.ref<i32>
232   return
235 // -----
236 func.func @bad_designate_len_params(%arg0 : !fir.ref<!fir.char<1,10>>) {
237   %c1 = arith.constant 1 : index
238   // expected-error@+1 {{'hlfir.designate' op must be provided one length parameter when the result is a character}}
239   %0 = hlfir.designate %arg0 substr %c1, %c1:  (!fir.ref<!fir.char<1,10>>, index, index) -> !fir.boxchar<1>
240   return
243 // -----
244 func.func @bad_designate_len_params_2(%arg0 : !fir.box<!fir.array<?x!fir.type<pdt(param:i32){field:i32}>>>) {
245   %c1 = arith.constant 1 : index
246   // expected-error@+1 {{'hlfir.designate' op must be provided the same number of length parameters as in the result derived type}}
247   %0 = hlfir.designate %arg0(%c1) typeparams %c1, %c1 :  (!fir.box<!fir.array<?x!fir.type<pdt(param:i32){field:i32}>>>, index, index, index) -> !fir.box<!fir.type<pdt(param:i32){field:i32}>>
248   return
251 // -----
252 func.func @bad_designate_len_params_3(%arg0 : !fir.box<!fir.array<?xi32>>) {
253   %c1 = arith.constant 1 : index
254   // expected-error@+1 {{'hlfir.designate' op must not be provided length parameters if the result type does not have length parameters}}
255   %0 = hlfir.designate %arg0(%c1) typeparams %c1 :  (!fir.box<!fir.array<?xi32>>, index, index) -> !fir.ref<i32>
256   return
259 // -----
260 func.func @bad_concat(%arg0: !fir.ref<!fir.char<1,10>>, %arg1: !fir.ref<!fir.char<1,20>>) {
261   %c30 = arith.constant 30 : index
262   // expected-error@+1 {{'hlfir.concat' op result #0 must be any character scalar expression type, but got '!fir.ref<!fir.char<1,30>>'}}
263   %0 = hlfir.concat %arg0, %arg1 len %c30 : (!fir.ref<!fir.char<1,10>>, !fir.ref<!fir.char<1,20>>, index) -> (!fir.ref<!fir.char<1,30>>)
264   return
267 // -----
268 func.func @bad_concat_2(%arg0: !fir.ref<!fir.array<100x!fir.char<1,10>>>, %arg1: !fir.ref<!fir.array<100x!fir.char<1,20>>>) {
269   %c30 = arith.constant 30 : index
270   // expected-error@+1 {{'hlfir.concat' op operand #0 must be variadic of any character scalar type, but got '!fir.ref<!fir.array<100x!fir.char<1,10>>>'}}
271   %0 = hlfir.concat %arg0, %arg1 len %c30 : (!fir.ref<!fir.array<100x!fir.char<1,10>>>, !fir.ref<!fir.array<100x!fir.char<1,20>>>, index) -> (!hlfir.expr<100x!fir.char<1,30>>)
272   return
275 // -----
276 func.func @bad_concat_3(%arg0: !fir.ref<!fir.char<1,10>>, %arg1: !fir.ref<i32>) {
277   %c30 = arith.constant 30 : index
278   // expected-error@+1 {{'hlfir.concat' op operand #1 must be variadic of any character scalar type, but got '!fir.ref<i32>'}}
279   %0 = hlfir.concat %arg0, %arg1 len %c30 : (!fir.ref<!fir.char<1,10>>, !fir.ref<i32>, index) -> (!hlfir.expr<!fir.char<1,30>>)
280   return
283 // -----
284 func.func @bad_concat_4(%arg0: !fir.ref<!fir.char<1,10>>, %arg1: !fir.ref<!fir.char<2,20>>) {
285   %c30 = arith.constant 30 : index
286   // expected-error@+1 {{'hlfir.concat' op strings must have the same KIND as the result type}}
287   %0 = hlfir.concat %arg0, %arg1 len %c30 : (!fir.ref<!fir.char<1,10>>, !fir.ref<!fir.char<2,20>>, index) -> (!hlfir.expr<!fir.char<1,30>>)
288   return
291 // -----
292 func.func @bad_concat_4(%arg0: !fir.ref<!fir.char<1,30>>) {
293   %c30 = arith.constant 30 : index
294   // expected-error@+1 {{'hlfir.concat' op must be provided at least two string operands}}
295   %0 = hlfir.concat %arg0 len %c30 : (!fir.ref<!fir.char<1,30>>, index) -> (!hlfir.expr<!fir.char<1,30>>)
296   return
299 // -----
300 func.func @bad_any1(%arg0: !hlfir.expr<?x!fir.logical<4>>) {
301   // expected-error@+1 {{'hlfir.any' op result must have the same element type as MASK argument}}
302   %0 = hlfir.any %arg0 : (!hlfir.expr<?x!fir.logical<4>>) -> !fir.logical<8>
305 // -----
306 func.func @bad_any2(%arg0: !hlfir.expr<?x?x!fir.logical<4>>, %arg1: i32) {
307   // expected-error@+1 {{'hlfir.any' op result must have the same element type as MASK argument}}
308   %0 = hlfir.any %arg0 dim %arg1 : (!hlfir.expr<?x?x!fir.logical<4>>, i32) -> !hlfir.expr<?x!fir.logical<8>>
311 // -----
312 func.func @bad_any3(%arg0: !hlfir.expr<?x?x!fir.logical<4>>, %arg1: i32){
313   // expected-error@+1 {{'hlfir.any' op result rank must be one less than MASK}}
314   %0 = hlfir.any %arg0 dim %arg1 : (!hlfir.expr<?x?x!fir.logical<4>>, i32) -> !hlfir.expr<?x?x!fir.logical<4>>
317 // -----
318 func.func @bad_any4(%arg0: !hlfir.expr<?x?x!fir.logical<4>>, %arg1: i32) {
319   // expected-error@+1 {{'hlfir.any' op result must be an array}}
320   %0 = hlfir.any %arg0 dim %arg1 : (!hlfir.expr<?x?x!fir.logical<4>>, i32) -> !hlfir.expr<!fir.logical<4>>
323 // -----
324 func.func @bad_any5(%arg0: !hlfir.expr<?x!fir.logical<4>>) {
325   // expected-error@+1 {{'hlfir.any' op result must be of logical type}}
326   %0 = hlfir.any %arg0 : (!hlfir.expr<?x!fir.logical<4>>) -> i32
329 // -----
330 func.func @bad_any6(%arg0: !hlfir.expr<?x!fir.logical<4>>) {
331   // expected-error@+1 {{'hlfir.any' op result must be of logical type}}
332   %0 = hlfir.any %arg0 : (!hlfir.expr<?x!fir.logical<4>>) -> !hlfir.expr<!fir.logical<4>>
335 // -----
336 func.func @bad_all1(%arg0: !hlfir.expr<?x!fir.logical<4>>) {
337   // expected-error@+1 {{'hlfir.all' op result must have the same element type as MASK argument}}
338   %0 = hlfir.all %arg0 : (!hlfir.expr<?x!fir.logical<4>>) -> !fir.logical<8>
341 // -----
342 func.func @bad_all2(%arg0: !hlfir.expr<?x?x!fir.logical<4>>, %arg1: i32) {
343   // expected-error@+1 {{'hlfir.all' op result must have the same element type as MASK argument}}
344   %0 = hlfir.all %arg0 dim %arg1 : (!hlfir.expr<?x?x!fir.logical<4>>, i32) -> !hlfir.expr<?x!fir.logical<8>>
347 // -----
348 func.func @bad_all3(%arg0: !hlfir.expr<?x?x!fir.logical<4>>, %arg1: i32){
349   // expected-error@+1 {{'hlfir.all' op result rank must be one less than MASK}}
350   %0 = hlfir.all %arg0 dim %arg1 : (!hlfir.expr<?x?x!fir.logical<4>>, i32) -> !hlfir.expr<?x?x!fir.logical<4>>
353 // -----
354 func.func @bad_all4(%arg0: !hlfir.expr<?x?x!fir.logical<4>>, %arg1: i32) {
355   // expected-error@+1 {{'hlfir.all' op result must be an array}}
356   %0 = hlfir.all %arg0 dim %arg1 : (!hlfir.expr<?x?x!fir.logical<4>>, i32) -> !hlfir.expr<!fir.logical<4>>
359 // -----
360 func.func @bad_all5(%arg0: !hlfir.expr<?x!fir.logical<4>>) {
361   // expected-error@+1 {{'hlfir.all' op result must be of logical type}}
362   %0 = hlfir.all %arg0 : (!hlfir.expr<?x!fir.logical<4>>) -> i32
365 // -----
366 func.func @bad_all6(%arg0: !hlfir.expr<?x!fir.logical<4>>) {
367   // expected-error@+1 {{'hlfir.all' op result must be of logical type}}
368   %0 = hlfir.all %arg0 : (!hlfir.expr<?x!fir.logical<4>>) -> !hlfir.expr<!fir.logical<4>>
371 // -----
372 func.func @bad_count1(%arg0: !hlfir.expr<?x?x!fir.logical<4>>, %arg1: i32) {
373   // expected-error@+1 {{'hlfir.count' op result must be an array}}
374   %0 = hlfir.count %arg0 dim %arg1 : (!hlfir.expr<?x?x!fir.logical<4>>, i32) -> !hlfir.expr<i32>
377 // -----
378 func.func @bad_count2(%arg0: !hlfir.expr<?x?x!fir.logical<4>>, %arg1: i32){
379   // expected-error@+1 {{'hlfir.count' op result rank must be one less than MASK}}
380   %0 = hlfir.count %arg0 dim %arg1 : (!hlfir.expr<?x?x!fir.logical<4>>, i32) -> !hlfir.expr<?x?x!fir.logical<4>>
383 // -----
384 func.func @bad_count3(%arg0: !hlfir.expr<?x!fir.logical<4>>, %arg1: i32) {
385   // expected-error@+1 {{'hlfir.count' op result must be of numerical array type}}
386   %0 = hlfir.count %arg0 dim %arg1 : (!hlfir.expr<?x!fir.logical<4>>, i32) -> !hlfir.expr<i32>
389 // -----
390 func.func @bad_count4(%arg0: !hlfir.expr<?x!fir.logical<4>>, %arg1: i32) {
391   // expected-error@+1 {{'hlfir.count' op result must be of numerical scalar type}}
392   %0 = hlfir.count %arg0 dim %arg1 : (!hlfir.expr<?x!fir.logical<4>>, i32) -> !fir.logical<4>
395 // -----
396 func.func @bad_maxval1(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
397   // expected-error@+1 {{'hlfir.maxval' op result must have the same element type as ARRAY argument}}
398   %0 = hlfir.maxval %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.logical<4>>) -> f32
401 // -----
402 func.func @bad_maxval2(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.array<?x?x?x?x?x!fir.logical<4>>>) {
403   // expected-warning@+1 {{MASK must be conformable to ARRAY}}
404   %0 = hlfir.maxval %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.array<?x?x?x?x?x!fir.logical<4>>>) -> !hlfir.expr<i32>
407 // -----
408 func.func @bad_maxval3(%arg0: !hlfir.expr<?x5x?xi32>, %arg1: i32, %arg2: !fir.box<!fir.array<2x6x?x!fir.logical<4>>>) {
409   // expected-warning@+1 {{MASK must be conformable to ARRAY}}
410   %0 = hlfir.maxval %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x5x?xi32>, i32, !fir.box<!fir.array<2x6x?x!fir.logical<4>>>) -> !hlfir.expr<i32>
413 // -----
414 func.func @bad_maxval4(%arg0: !hlfir.expr<?x?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
415   // expected-error@+1 {{'hlfir.maxval' op result rank must be one less than ARRAY}}
416   %0 = hlfir.maxval %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x?xi32>, i32, !fir.box<!fir.logical<4>>) -> !hlfir.expr<?x?xi32>
419 // -----
420 func.func @bad_maxval5(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
421   // expected-error@+1 {{'hlfir.maxval' op result must be of numerical scalar type}}
422   %0 = hlfir.maxval %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.logical<4>>) -> !fir.logical<4>
425 // -----
426 func.func @bad_maxval6(%arg0: !hlfir.expr<?x?xi32>, %arg1: i32){
427   // expected-error@+1 {{'hlfir.maxval' op result must be an array}}
428   %0 = hlfir.maxval %arg0 dim %arg1 : (!hlfir.expr<?x?xi32>, i32) -> !hlfir.expr<i32>
431 // -----
432 func.func @bad_maxval7(%arg0: !hlfir.expr<?xi32>){
433   // expected-error@+1 {{'hlfir.maxval' op result must be of numerical scalar type}}
434   %0 = hlfir.maxval %arg0 : (!hlfir.expr<?xi32>) -> !hlfir.expr<i32>
437 // -----
438 func.func @bad_maxval8(%arg0: !hlfir.expr<?x!fir.char<1,?>>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
439   // expected-error@+1 {{'hlfir.maxval' op result must have the same element type as ARRAY argument}}
440   %0 = hlfir.maxval %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x!fir.char<1,?>>, i32, !fir.box<!fir.logical<4>>) -> i32
443 // -----
444 func.func @bad_maxval9(%arg0: !hlfir.expr<?x!fir.char<1,?>>, %arg1: i32, %arg2: !fir.box<!fir.array<?x?x?x?x?x!fir.logical<4>>>) {
445   // expected-warning@+1 {{MASK must be conformable to ARRAY}}
446   %0 = hlfir.maxval %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x!fir.char<1,?>>, i32, !fir.box<!fir.array<?x?x?x?x?x!fir.logical<4>>>) -> !hlfir.expr<!fir.char<1,?>>
449 // -----
450 func.func @bad_maxval10(%arg0: !hlfir.expr<?x5x?x!fir.char<1,?>>, %arg1: i32, %arg2: !fir.box<!fir.array<2x6x?x!fir.logical<4>>>) {
451   // expected-warning@+1 {{MASK must be conformable to ARRAY}}
452   %0 = hlfir.maxval %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x5x?x!fir.char<1,?>>, i32, !fir.box<!fir.array<2x6x?x!fir.logical<4>>>) -> !hlfir.expr<!fir.char<1,?>>
455 // -----
456 func.func @bad_maxval11(%arg0: !hlfir.expr<?x?x!fir.char<1,?>>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
457   // expected-error@+1 {{'hlfir.maxval' op result rank must be one less than ARRAY}}
458   %0 = hlfir.maxval %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x?x!fir.char<1,?>>, i32, !fir.box<!fir.logical<4>>) -> !hlfir.expr<?x?x!fir.char<1,?>>
461 // -----
462 func.func @bad_maxval12(%arg0: !hlfir.expr<?x!fir.char<1,?>>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
463   // expected-error@+1 {{'hlfir.maxval' op result must be scalar character}}
464   %0 = hlfir.maxval %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x!fir.char<1,?>>, i32, !fir.box<!fir.logical<4>>) -> !hlfir.expr<?x!fir.char<1,?>>
467 // -----
468 func.func @bad_maxval13(%arg0: !hlfir.expr<?x?x!fir.char<1,?>>, %arg1: i32){
469   // expected-error@+1 {{'hlfir.maxval' op result must be an array}}
470   %0 = hlfir.maxval %arg0 dim %arg1 : (!hlfir.expr<?x?x!fir.char<1,?>>, i32) -> !hlfir.expr<!fir.char<1,?>>
473 // -----
474 func.func @bad_minval1(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
475   // expected-error@+1 {{'hlfir.minval' op result must have the same element type as ARRAY argument}}
476   %0 = hlfir.minval %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.logical<4>>) -> f32
479 // -----
480 func.func @bad_minval2(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.array<?x?x?x?x?x!fir.logical<4>>>) {
481   // expected-warning@+1 {{MASK must be conformable to ARRAY}}
482   %0 = hlfir.minval %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.array<?x?x?x?x?x!fir.logical<4>>>) -> !hlfir.expr<i32>
485 // -----
486 func.func @bad_minval3(%arg0: !hlfir.expr<?x5x?xi32>, %arg1: i32, %arg2: !fir.box<!fir.array<2x6x?x!fir.logical<4>>>) {
487   // expected-warning@+1 {{MASK must be conformable to ARRAY}}
488   %0 = hlfir.minval %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x5x?xi32>, i32, !fir.box<!fir.array<2x6x?x!fir.logical<4>>>) -> !hlfir.expr<i32>
491 // -----
492 func.func @bad_minval4(%arg0: !hlfir.expr<?x?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
493   // expected-error@+1 {{'hlfir.minval' op result rank must be one less than ARRAY}}
494   %0 = hlfir.minval %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x?xi32>, i32, !fir.box<!fir.logical<4>>) -> !hlfir.expr<?x?xi32>
497 // -----
498 func.func @bad_minval5(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
499   // expected-error@+1 {{'hlfir.minval' op result must be of numerical scalar type}}
500   %0 = hlfir.minval %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.logical<4>>) -> !fir.logical<4>
503 // -----
504 func.func @bad_minval6(%arg0: !hlfir.expr<?x?xi32>, %arg1: i32){
505   // expected-error@+1 {{'hlfir.minval' op result must be an array}}
506   %0 = hlfir.minval %arg0 dim %arg1 : (!hlfir.expr<?x?xi32>, i32) -> !hlfir.expr<i32>
509 // -----
510 func.func @bad_minval7(%arg0: !hlfir.expr<?xi32>){
511   // expected-error@+1 {{'hlfir.minval' op result must be of numerical scalar type}}
512   %0 = hlfir.minval %arg0 : (!hlfir.expr<?xi32>) -> !hlfir.expr<i32>
515 // -----
516 func.func @bad_minval8(%arg0: !hlfir.expr<?x!fir.char<1,?>>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
517   // expected-error@+1 {{'hlfir.minval' op result must have the same element type as ARRAY argument}}
518   %0 = hlfir.minval %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x!fir.char<1,?>>, i32, !fir.box<!fir.logical<4>>) -> i32
521 // -----
522 func.func @bad_minval9(%arg0: !hlfir.expr<?x!fir.char<1,?>>, %arg1: i32, %arg2: !fir.box<!fir.array<?x?x?x?x?x!fir.logical<4>>>) {
523   // expected-warning@+1 {{MASK must be conformable to ARRAY}}
524   %0 = hlfir.minval %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x!fir.char<1,?>>, i32, !fir.box<!fir.array<?x?x?x?x?x!fir.logical<4>>>) -> !hlfir.expr<!fir.char<1,?>>
527 // -----
528 func.func @bad_minval10(%arg0: !hlfir.expr<?x5x?x!fir.char<1,?>>, %arg1: i32, %arg2: !fir.box<!fir.array<2x6x?x!fir.logical<4>>>) {
529   // expected-warning@+1 {{MASK must be conformable to ARRAY}}
530   %0 = hlfir.minval %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x5x?x!fir.char<1,?>>, i32, !fir.box<!fir.array<2x6x?x!fir.logical<4>>>) -> !hlfir.expr<!fir.char<1,?>>
533 // -----
534 func.func @bad_minval11(%arg0: !hlfir.expr<?x?x!fir.char<1,?>>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
535   // expected-error@+1 {{'hlfir.minval' op result rank must be one less than ARRAY}}
536   %0 = hlfir.minval %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x?x!fir.char<1,?>>, i32, !fir.box<!fir.logical<4>>) -> !hlfir.expr<?x?x!fir.char<1,?>>
539 // -----
540 func.func @bad_minval12(%arg0: !hlfir.expr<?x!fir.char<1,?>>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
541   // expected-error@+1 {{'hlfir.minval' op result must be scalar character}}
542   %0 = hlfir.minval %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x!fir.char<1,?>>, i32, !fir.box<!fir.logical<4>>) -> !hlfir.expr<?x!fir.char<1,?>>
545 // -----
546 func.func @bad_minval13(%arg0: !hlfir.expr<?x?x!fir.char<1,?>>, %arg1: i32){
547   // expected-error@+1 {{'hlfir.minval' op result must be an array}}
548   %0 = hlfir.minval %arg0 dim %arg1 : (!hlfir.expr<?x?x!fir.char<1,?>>, i32) -> !hlfir.expr<!fir.char<1,?>>
551 // -----
552 func.func @bad_minloc1(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
553   // expected-error@+1 {{'hlfir.minloc' op result must be scalar integer}}
554   %0 = hlfir.minloc %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.logical<4>>) -> f32
557 // -----
558 func.func @bad_minloc2(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.array<?x?x?x?x?x!fir.logical<4>>>) {
559   // expected-warning@+1 {{MASK must be conformable to ARRAY}}
560   %0 = hlfir.minloc %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.array<?x?x?x?x?x!fir.logical<4>>>) -> !hlfir.expr<i32>
563 // -----
564 func.func @bad_minloc3(%arg0: !hlfir.expr<?x5x?xi32>, %arg1: i32, %arg2: !fir.box<!fir.array<2x6x?x!fir.logical<4>>>) {
565   // expected-warning@+1 {{MASK must be conformable to ARRAY}}
566   %0 = hlfir.minloc %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x5x?xi32>, i32, !fir.box<!fir.array<2x6x?x!fir.logical<4>>>) -> !hlfir.expr<i32>
569 // -----
570 func.func @bad_minloc4(%arg0: !hlfir.expr<?x?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
571   // expected-error@+1 {{'hlfir.minloc' op result rank must be one less than ARRAY}}
572   %0 = hlfir.minloc %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x?xi32>, i32, !fir.box<!fir.logical<4>>) -> !hlfir.expr<?x?xi32>
575 // -----
576 func.func @bad_minloc5(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
577   // expected-error@+1 {{'hlfir.minloc' op result must be scalar integer}}
578   %0 = hlfir.minloc %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.logical<4>>) -> !fir.logical<4>
581 // -----
582 func.func @bad_minloc6(%arg0: !hlfir.expr<?x?xi32>, %arg1: i32){
583   // expected-error@+1 {{'hlfir.minloc' op result must be an array}}
584   %0 = hlfir.minloc %arg0 dim %arg1 : (!hlfir.expr<?x?xi32>, i32) -> !hlfir.expr<i32>
587 // -----
588 func.func @bad_minloc7(%arg0: !hlfir.expr<?xi32>){
589   // expected-error@+1 {{'hlfir.minloc' op result must be of numerical expr type}}
590   %0 = hlfir.minloc %arg0 : (!hlfir.expr<?xi32>) -> i32
593 // -----
594 func.func @bad_minloc8(%arg0: !hlfir.expr<?xi32>){
595   // expected-error@+1 {{'hlfir.minloc' op result must have integer elements}}
596   %0 = hlfir.minloc %arg0 : (!hlfir.expr<?xi32>) -> !hlfir.expr<?xf32>
599 // -----
600 func.func @bad_minloc9(%arg0: !hlfir.expr<?x!fir.char<1,?>>, %arg1: i32, %arg2: !fir.box<!fir.array<?x?x?x?x?x!fir.logical<4>>>) {
601   // expected-warning@+1 {{MASK must be conformable to ARRAY}}
602   %0 = hlfir.minloc %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x!fir.char<1,?>>, i32, !fir.box<!fir.array<?x?x?x?x?x!fir.logical<4>>>) -> !hlfir.expr<!fir.char<1,?>>
605 // -----
606 func.func @bad_minloc10(%arg0: !hlfir.expr<?x5x?x!fir.char<1,?>>, %arg1: i32, %arg2: !fir.box<!fir.array<2x6x?x!fir.logical<4>>>) {
607   // expected-warning@+1 {{MASK must be conformable to ARRAY}}
608   %0 = hlfir.minloc %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x5x?x!fir.char<1,?>>, i32, !fir.box<!fir.array<2x6x?x!fir.logical<4>>>) -> !hlfir.expr<!fir.char<1,?>>
611 // -----
612 func.func @bad_minloc11(%arg0: !hlfir.expr<?x?x!fir.char<1,?>>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
613   // expected-error@+1 {{'hlfir.minloc' op result rank must be one less than ARRAY}}
614   %0 = hlfir.minloc %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x?x!fir.char<1,?>>, i32, !fir.box<!fir.logical<4>>) -> !hlfir.expr<?x?xi32>
617 // -----
618 func.func @bad_maxloc1(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
619   // expected-error@+1 {{'hlfir.maxloc' op result must be scalar integer}}
620   %0 = hlfir.maxloc %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.logical<4>>) -> f32
623 // -----
624 func.func @bad_maxloc2(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.array<?x?x?x?x?x!fir.logical<4>>>) {
625   // expected-warning@+1 {{MASK must be conformable to ARRAY}}
626   %0 = hlfir.maxloc %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.array<?x?x?x?x?x!fir.logical<4>>>) -> !hlfir.expr<i32>
629 // -----
630 func.func @bad_maxloc3(%arg0: !hlfir.expr<?x5x?xi32>, %arg1: i32, %arg2: !fir.box<!fir.array<2x6x?x!fir.logical<4>>>) {
631   // expected-warning@+1 {{MASK must be conformable to ARRAY}}
632   %0 = hlfir.maxloc %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x5x?xi32>, i32, !fir.box<!fir.array<2x6x?x!fir.logical<4>>>) -> !hlfir.expr<i32>
635 // -----
636 func.func @bad_maxloc4(%arg0: !hlfir.expr<?x?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
637   // expected-error@+1 {{'hlfir.maxloc' op result rank must be one less than ARRAY}}
638   %0 = hlfir.maxloc %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x?xi32>, i32, !fir.box<!fir.logical<4>>) -> !hlfir.expr<?x?xi32>
641 // -----
642 func.func @bad_maxloc5(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
643   // expected-error@+1 {{'hlfir.maxloc' op result must be scalar integer}}
644   %0 = hlfir.maxloc %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.logical<4>>) -> !fir.logical<4>
647 // -----
648 func.func @bad_maxloc6(%arg0: !hlfir.expr<?x?xi32>, %arg1: i32){
649   // expected-error@+1 {{'hlfir.maxloc' op result must be an array}}
650   %0 = hlfir.maxloc %arg0 dim %arg1 : (!hlfir.expr<?x?xi32>, i32) -> !hlfir.expr<i32>
653 // -----
654 func.func @bad_maxloc7(%arg0: !hlfir.expr<?xi32>){
655   // expected-error@+1 {{'hlfir.maxloc' op result must be of numerical expr type}}
656   %0 = hlfir.maxloc %arg0 : (!hlfir.expr<?xi32>) -> i32
659 // -----
660 func.func @bad_maxloc8(%arg0: !hlfir.expr<?xi32>){
661   // expected-error@+1 {{'hlfir.maxloc' op result must have integer elements}}
662   %0 = hlfir.maxloc %arg0 : (!hlfir.expr<?xi32>) -> !hlfir.expr<?xf32>
665 // -----
666 func.func @bad_maxloc9(%arg0: !hlfir.expr<?x!fir.char<1,?>>, %arg1: i32, %arg2: !fir.box<!fir.array<?x?x?x?x?x!fir.logical<4>>>) {
667   // expected-warning@+1 {{MASK must be conformable to ARRAY}}
668   %0 = hlfir.maxloc %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x!fir.char<1,?>>, i32, !fir.box<!fir.array<?x?x?x?x?x!fir.logical<4>>>) -> !hlfir.expr<!fir.char<1,?>>
671 // -----
672 func.func @bad_maxloc10(%arg0: !hlfir.expr<?x5x?x!fir.char<1,?>>, %arg1: i32, %arg2: !fir.box<!fir.array<2x6x?x!fir.logical<4>>>) {
673   // expected-warning@+1 {{MASK must be conformable to ARRAY}}
674   %0 = hlfir.maxloc %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x5x?x!fir.char<1,?>>, i32, !fir.box<!fir.array<2x6x?x!fir.logical<4>>>) -> !hlfir.expr<!fir.char<1,?>>
677 // -----
678 func.func @bad_maxloc11(%arg0: !hlfir.expr<?x?x!fir.char<1,?>>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
679   // expected-error@+1 {{'hlfir.maxloc' op result rank must be one less than ARRAY}}
680   %0 = hlfir.maxloc %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x?x!fir.char<1,?>>, i32, !fir.box<!fir.logical<4>>) -> !hlfir.expr<?x?xi32>
684 // -----
685 func.func @bad_product1(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
686   // expected-error@+1 {{'hlfir.product' op result must have the same element type as ARRAY argument}}
687   %0 = hlfir.product %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.logical<4>>) -> f32
690 // -----
691 func.func @bad_product2(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.array<?x?x?x?x?x!fir.logical<4>>>) {
692   // expected-warning@+1 {{MASK must be conformable to ARRAY}}
693   %0 = hlfir.product %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.array<?x?x?x?x?x!fir.logical<4>>>) -> !hlfir.expr<i32>
696 // -----
697 func.func @bad_product3(%arg0: !hlfir.expr<?x5x?xi32>, %arg1: i32, %arg2: !fir.box<!fir.array<2x6x?x!fir.logical<4>>>) {
698   // expected-warning@+1 {{MASK must be conformable to ARRAY}}
699   %0 = hlfir.product %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x5x?xi32>, i32, !fir.box<!fir.array<2x6x?x!fir.logical<4>>>) -> !hlfir.expr<i32>
702 // -----
703 func.func @bad_product4(%arg0: !hlfir.expr<?x?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
704   // expected-error@+1 {{'hlfir.product' op result rank must be one less than ARRAY}}
705   %0 = hlfir.product %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x?xi32>, i32, !fir.box<!fir.logical<4>>) -> !hlfir.expr<?x?xi32>
708 // -----
709 func.func @bad_product5(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
710   // expected-error@+1 {{'hlfir.product' op result must be of numerical scalar type}}
711   %0 = hlfir.product %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.logical<4>>) -> !fir.logical<4>
714 // -----
715 func.func @bad_product6(%arg0: !hlfir.expr<?x?xi32>, %arg1: i32){
716   // expected-error@+1 {{'hlfir.product' op result must be an array}}
717   %0 = hlfir.product %arg0 dim %arg1 : (!hlfir.expr<?x?xi32>, i32) -> !hlfir.expr<i32>
720 // -----
721 func.func @bad_product7(%arg0: !hlfir.expr<?xi32>){
722   // expected-error@+1 {{'hlfir.product' op result must be of numerical scalar type}}
723   %0 = hlfir.product %arg0 : (!hlfir.expr<?xi32>) -> !hlfir.expr<i32>
726 // -----
727 func.func @bad_sum1(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
728   // expected-error@+1 {{'hlfir.sum' op result must have the same element type as ARRAY argument}}
729   %0 = hlfir.sum %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.logical<4>>) -> f32
732 // -----
733 func.func @bad_sum2(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.array<?x?x?x?x?x!fir.logical<4>>>) {
734   // expected-warning@+1 {{MASK must be conformable to ARRAY}}
735   %0 = hlfir.sum %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.array<?x?x?x?x?x!fir.logical<4>>>) -> !hlfir.expr<i32>
738 // -----
739 func.func @bad_sum3(%arg0: !hlfir.expr<?x5x?xi32>, %arg1: i32, %arg2: !fir.box<!fir.array<2x6x?x!fir.logical<4>>>) {
740   // expected-warning@+1 {{MASK must be conformable to ARRAY}}
741   %0 = hlfir.sum %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x5x?xi32>, i32, !fir.box<!fir.array<2x6x?x!fir.logical<4>>>) -> !hlfir.expr<i32>
744 // -----
745 func.func @bad_sum4(%arg0: !hlfir.expr<?x?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
746   // expected-error@+1 {{'hlfir.sum' op result rank must be one less than ARRAY}}
747   %0 = hlfir.sum %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?x?xi32>, i32, !fir.box<!fir.logical<4>>) -> !hlfir.expr<?x?xi32>
750 // -----
751 func.func @bad_sum5(%arg0: !hlfir.expr<?xi32>, %arg1: i32, %arg2: !fir.box<!fir.logical<4>>) {
752   // expected-error@+1 {{'hlfir.sum' op result must be of numerical scalar type}}
753   %0 = hlfir.sum %arg0 dim %arg1 mask %arg2 : (!hlfir.expr<?xi32>, i32, !fir.box<!fir.logical<4>>) -> !fir.logical<4>
756 // -----
757 func.func @bad_sum6(%arg0: !hlfir.expr<?x?xi32>, %arg1: i32){
758   // expected-error@+1 {{'hlfir.sum' op result must be an array}}
759   %0 = hlfir.sum %arg0 dim %arg1 : (!hlfir.expr<?x?xi32>, i32) -> !hlfir.expr<i32>
762 // -----
763 func.func @bad_sum7(%arg0: !hlfir.expr<?xi32>){
764   // expected-error@+1 {{'hlfir.sum' op result must be of numerical scalar type}}
765   %0 = hlfir.sum %arg0 : (!hlfir.expr<?xi32>) -> !hlfir.expr<i32>
768 // -----
769 func.func @bad_matmul1(%arg0: !hlfir.expr<?x?x?xi32>, %arg1: !hlfir.expr<?x?xi32>) {
770   // expected-error@+1 {{'hlfir.matmul' op array must have either rank 1 or rank 2}}
771   %0 = hlfir.matmul %arg0 %arg1 : (!hlfir.expr<?x?x?xi32>, !hlfir.expr<?x?xi32>) -> !hlfir.expr<?x?xi32>
772   return
775 // -----
776 func.func @bad_matmul2(%arg0: !hlfir.expr<?xi32>, %arg1: !hlfir.expr<?xi32>) {
777   // expected-error@+1 {{'hlfir.matmul' op at least one array must have rank 2}}
778   %0 = hlfir.matmul %arg0 %arg1 : (!hlfir.expr<?xi32>, !hlfir.expr<?xi32>) -> !hlfir.expr<?x?xi32>
779   return
782 // -----
783 func.func @bad_matmul3(%arg0: !hlfir.expr<?x?x!fir.logical<4>>, %arg1: !hlfir.expr<?x?xi32>) {
784   // expected-error@+1 {{'hlfir.matmul' op if one array is logical, so should the other be}}
785   %0 = hlfir.matmul %arg0 %arg1 : (!hlfir.expr<?x?x!fir.logical<4>>, !hlfir.expr<?x?xi32>) -> !hlfir.expr<?x?xi32>
786   return
789 // -----
790 func.func @bad_matmul4(%arg0: !hlfir.expr<?x2xi32>, %arg1: !hlfir.expr<200x?xi32>) {
791   // expected-error@+1 {{'hlfir.matmul' op the last dimension of LHS should match the first dimension of RHS}}
792   %0 = hlfir.matmul %arg0 %arg1 : (!hlfir.expr<?x2xi32>, !hlfir.expr<200x?xi32>) -> !hlfir.expr<?x?xi32>
793   return
796 // -----
797 func.func @bad_matmul5(%arg0: !hlfir.expr<?x?xi32>, %arg1: !hlfir.expr<?x?xi32>) {
798   // expected-error@+1 {{'hlfir.matmul' op the result type should be a logical only if the argument types are logical}}
799   %0 = hlfir.matmul %arg0 %arg1 : (!hlfir.expr<?x?xi32>, !hlfir.expr<?x?xi32>) -> !hlfir.expr<?x?x!fir.logical<4>>
800   return
803 // -----
804 func.func @bad_matmul6(%arg0: !hlfir.expr<1x2xi32>, %arg1: !hlfir.expr<2x3xi32>) {
805   // expected-error@+1 {{'hlfir.matmul' op incorrect result shape}}
806   %0 = hlfir.matmul %arg0 %arg1 : (!hlfir.expr<1x2xi32>, !hlfir.expr<2x3xi32>) -> !hlfir.expr<10x30xi32>
807   return
810 // -----
811 func.func @bad_matmul7(%arg0: !hlfir.expr<1x2xi32>, %arg1: !hlfir.expr<2xi32>) {
812   // expected-error@+1 {{'hlfir.matmul' op incorrect result shape}}
813   %0 = hlfir.matmul %arg0 %arg1 : (!hlfir.expr<1x2xi32>, !hlfir.expr<2xi32>) -> !hlfir.expr<1x3xi32>
814   return
817 // -----
818 func.func @bad_matmul8(%arg0: !hlfir.expr<2xi32>, %arg1: !hlfir.expr<2x3xi32>) {
819   // expected-error@+1 {{'hlfir.matmul' op incorrect result shape}}
820   %0 = hlfir.matmul %arg0 %arg1 : (!hlfir.expr<2xi32>, !hlfir.expr<2x3xi32>) -> !hlfir.expr<1x3xi32>
821   return
824 // -----
825 func.func @bad_dot_product1(%arg0: !hlfir.expr<2xi32>, %arg1: !hlfir.expr<2x3xi32>) {
826   // expected-error@+1 {{'hlfir.dot_product' op both arrays must have rank 1}}
827   %0 = hlfir.dot_product %arg0 %arg1 : (!hlfir.expr<2xi32>, !hlfir.expr<2x3xi32>) -> i32
828   return
831 // -----
832 func.func @bad_dot_product2(%arg0: !hlfir.expr<2xi32>, %arg1: !hlfir.expr<3xi32>) {
833   // expected-error@+1 {{'hlfir.dot_product' op both arrays must have the same size}}
834   %0 = hlfir.dot_product %arg0 %arg1 : (!hlfir.expr<2xi32>, !hlfir.expr<3xi32>) -> i32
835   return
838 // -----
839 func.func @bad_dot_product3(%arg0: !hlfir.expr<2xi32>, %arg1: !hlfir.expr<2x!fir.logical<4>>) {
840   // expected-error@+1 {{'hlfir.dot_product' op if one array is logical, so should the other be}}
841   %0 = hlfir.dot_product %arg0 %arg1 : (!hlfir.expr<2xi32>, !hlfir.expr<2x!fir.logical<4>>) -> i32
842   return
845 // -----
846 func.func @bad_dot_product4(%arg0: !hlfir.expr<2xi32>, %arg1: !hlfir.expr<2xi32>) {
847   // expected-error@+1 {{'hlfir.dot_product' op the result type should be a logical only if the argument types are logical}}
848   %0 = hlfir.dot_product %arg0 %arg1 : (!hlfir.expr<2xi32>, !hlfir.expr<2xi32>) -> !fir.logical<4>
849   return
852 // -----
853 func.func @bad_dot_product5(%arg0: !hlfir.expr<2xi32>, %arg1: !hlfir.expr<2xi32>) {
854   // expected-error@+1 {{'hlfir.dot_product' op the result must be of scalar numerical or logical type}}
855   %0 = hlfir.dot_product %arg0 %arg1 : (!hlfir.expr<2xi32>, !hlfir.expr<2xi32>) -> !hlfir.expr<i32>
856   return
859 // -----
860 func.func @bad_transpose1(%arg0: !hlfir.expr<2xi32>) {
861   // expected-error@+1 {{'hlfir.transpose' op input and output arrays should have rank 2}}
862   %0 = hlfir.transpose %arg0 : (!hlfir.expr<2xi32>) -> !hlfir.expr<2xi32>
863   return
866 // -----
867 func.func @bad_transpose2(%arg0: !hlfir.expr<2x3xi32>) {
868   // expected-error@+1 {{'hlfir.transpose' op output shape does not match input array}}
869   %0 = hlfir.transpose %arg0 : (!hlfir.expr<2x3xi32>) -> !hlfir.expr<2x2xi32>
870   return
873 // -----
874 func.func @bad_transpose3(%arg0: !hlfir.expr<2x3xi32>) {
875   // expected-error@+1 {{'hlfir.transpose' op input and output arrays should have the same element type}}
876   %0 = hlfir.transpose %arg0 : (!hlfir.expr<2x3xi32>) -> !hlfir.expr<3x2xf64>
877   return
880 // -----
881 func.func @bad_matmultranspose1(%arg0: !hlfir.expr<?x?x?xi32>, %arg1: !hlfir.expr<?x?xi32>) {
882   // expected-error@+1 {{'hlfir.matmul_transpose' op array must have either rank 1 or rank 2}}
883   %0 = hlfir.matmul_transpose %arg0 %arg1 : (!hlfir.expr<?x?x?xi32>, !hlfir.expr<?x?xi32>) -> !hlfir.expr<?x?xi32>
884   return
887 // -----
888 func.func @bad_matmultranspose2(%arg0: !hlfir.expr<?xi32>, %arg1: !hlfir.expr<?xi32>) {
889   // expected-error@+1 {{'hlfir.matmul_transpose' op array must have either rank 1 or rank 2}}
890   %0 = hlfir.matmul_transpose %arg0 %arg1 : (!hlfir.expr<?xi32>, !hlfir.expr<?xi32>) -> !hlfir.expr<?x?xi32>
891   return
894 // -----
895 func.func @bad_matmultranspose3(%arg0: !hlfir.expr<?x?x!fir.logical<4>>, %arg1: !hlfir.expr<?x?xi32>) {
896   // expected-error@+1 {{'hlfir.matmul_transpose' op if one array is logical, so should the other be}}
897   %0 = hlfir.matmul_transpose %arg0 %arg1 : (!hlfir.expr<?x?x!fir.logical<4>>, !hlfir.expr<?x?xi32>) -> !hlfir.expr<?x?xi32>
898   return
901 // -----
902 func.func @bad_matmultranspose5(%arg0: !hlfir.expr<?x?xi32>, %arg1: !hlfir.expr<?x?xi32>) {
903   // expected-error@+1 {{'hlfir.matmul_transpose' op the result type should be a logical only if the argument types are logical}}
904   %0 = hlfir.matmul_transpose %arg0 %arg1 : (!hlfir.expr<?x?xi32>, !hlfir.expr<?x?xi32>) -> !hlfir.expr<?x?x!fir.logical<4>>
905   return
908 // -----
909 func.func @bad_matmultranspose6(%arg0: !hlfir.expr<2x1xi32>, %arg1: !hlfir.expr<2x3xi32>) {
910   // expected-error@+1 {{'hlfir.matmul_transpose' op incorrect result shape}}
911   %0 = hlfir.matmul_transpose %arg0 %arg1 : (!hlfir.expr<2x1xi32>, !hlfir.expr<2x3xi32>) -> !hlfir.expr<10x30xi32>
912   return
915 // -----
916 func.func @bad_matmultranspose7(%arg0: !hlfir.expr<2x1xi32>, %arg1: !hlfir.expr<2xi32>) {
917   // expected-error@+1 {{'hlfir.matmul_transpose' op incorrect result shape}}
918   %0 = hlfir.matmul_transpose %arg0 %arg1 : (!hlfir.expr<2x1xi32>, !hlfir.expr<2xi32>) -> !hlfir.expr<1x3xi32>
919   return
922 // -----
923 func.func @bad_assign_1(%arg0: !fir.box<!fir.array<?xi32>>, %arg1: !fir.box<!fir.array<?xi32>>) {
924   // expected-error@+1 {{'hlfir.assign' op lhs must be an allocatable when `realloc` is set}}
925   hlfir.assign %arg1 to %arg0 realloc : !fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?xi32>>
926   return
929 // -----
930 func.func @bad_assign_2(%arg0: !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, %arg1: !fir.box<!fir.array<?xi32>>) {
931   // expected-error@+1 {{'hlfir.assign' op `realloc` must be set and lhs must be a character allocatable when `keep_lhs_length_if_realloc` is set}}
932   hlfir.assign %arg1 to %arg0 realloc keep_lhs_len : !fir.box<!fir.array<?xi32>>, !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
933   return
936 // -----
937 func.func @bad_parent_comp1(%arg0: !fir.box<!fir.array<10x!fir.type<t2{i:i32,j:i32}>>>) {
938   // expected-error@+1 {{'hlfir.parent_comp' op must be provided a shape if and only if the base is an array}}
939   %2 = hlfir.parent_comp %arg0 : (!fir.box<!fir.array<10x!fir.type<t2{i:i32,j:i32}>>>) -> !fir.box<!fir.array<10x!fir.type<t1{i:i32}>>>
940   return
943 // -----
944 func.func @bad_parent_comp2(%arg0: !fir.box<!fir.array<10x!fir.type<t2{i:i32,j:i32}>>>) {
945   %c10 = arith.constant 10 : index
946   %1 = fir.shape %c10 : (index) -> !fir.shape<1>
947   // expected-error@+1 {{'hlfir.parent_comp' op result type rank must match input type rank}}
948   %2 = hlfir.parent_comp %arg0 shape %1 : (!fir.box<!fir.array<10x!fir.type<t2{i:i32,j:i32}>>>, !fir.shape<1>) -> !fir.box<!fir.array<2x5x!fir.type<t1{i:i32}>>>
949   return
952 // -----
953 func.func @bad_parent_comp3(%arg0: !fir.box<!fir.array<10x!fir.type<t2{i:i32,j:i32}>>>) {
954   %c10 = arith.constant 10 : index
955   %1 = fir.shape %c10 : (index) -> !fir.shape<1>
956   // expected-error@+1 {{'hlfir.parent_comp' op result type extents are inconsistent with memref type}}
957   %2 = hlfir.parent_comp %arg0 shape %1 : (!fir.box<!fir.array<10x!fir.type<t2{i:i32,j:i32}>>>, !fir.shape<1>) -> !fir.box<!fir.array<20x!fir.type<t1{i:i32}>>>
958   return
961 // -----
962 func.func @bad_parent_comp4(%arg0: !fir.ref<!fir.type<t2{i:i32,j:i32}>>) {
963   // expected-error@+1 {{'hlfir.parent_comp' op result type and input type must be derived types}}
964   %1 = hlfir.parent_comp %arg0 : (!fir.ref<!fir.type<t2{i:i32,j:i32}>>) -> !fir.ref<i32>
965   return
968 // -----
969 func.func @bad_parent_comp5(%arg0: !fir.class<!fir.type<t2{i:i32,j:i32}>>) {
970   // expected-error@+1 {{'hlfir.parent_comp' op result type must not be polymorphic}}
971   %2 = hlfir.parent_comp %arg0 : (!fir.class<!fir.type<t2{i:i32,j:i32}>>) -> !fir.class<!fir.type<t1{i:i32}>>
972   return
975 // -----
976 func.func @bad_parent_comp6(%arg0: !fir.box<!fir.array<10x!fir.type<t2{i:i32,j:i32}>>>) {
977   %c10 = arith.constant 10 : index
978   %1 = fir.shape %c10 : (index) -> !fir.shape<1>
979   // expected-error@+1 {{'hlfir.parent_comp' op result type must be a fir.box if the result is an array or has length parameters}}
980   %2 = hlfir.parent_comp %arg0 shape %1 : (!fir.box<!fir.array<10x!fir.type<t2{i:i32,j:i32}>>>, !fir.shape<1>) -> !fir.ref<!fir.array<10x!fir.type<t1{i:i32}>>>
981   return
984 // -----
985 func.func @bad_shapeof(%arg0: !hlfir.expr<!fir.char<1,10>>) {
986   // expected-error@+1 {{'hlfir.shape_of' op cannot get the shape of a shape-less expression}}
987   %0 = hlfir.shape_of %arg0 : (!hlfir.expr<!fir.char<1,10>>) -> !fir.shape<1>
990 // -----
991 func.func @bad_shapeof2(%arg0: !hlfir.expr<10xi32>) {
992   // expected-error@+1 {{'hlfir.shape_of' op result rank and expr rank do not match}}
993   %0 = hlfir.shape_of %arg0 : (!hlfir.expr<10xi32>) -> !fir.shape<42>
996 // -----
997 func.func @bad_getextent(%arg0: !fir.shape<1>) {
998   // expected-error@+1 {{'hlfir.get_extent' op dimension index out of bounds}}
999   %0 = hlfir.get_extent %arg0 {dim = 1 : index} : (!fir.shape<1>) -> index
1002 // -----
1003 func.func @bad_region_assign_1(%x: !fir.box<!fir.array<?xf32>>) {
1004 // expected-error@+1 {{'hlfir.region_assign' op right-hand side region must be terminated by an hlfir.yield}}
1005   hlfir.region_assign {
1006     %c100 = arith.constant 100 : index
1007   } to {
1008     hlfir.yield %x : !fir.box<!fir.array<?xf32>>
1009   }
1010   return
1013 // -----
1014 func.func @bad_region_assign_2(%x: !fir.box<!fir.array<?xf32>>) {
1015 // expected-error@+1 {{'hlfir.region_assign' op left-hand side region must be terminated by an hlfir.yield or hlfir.elemental_addr}}
1016   hlfir.region_assign {
1017     hlfir.yield %x : !fir.box<!fir.array<?xf32>>
1018   } to {
1019     %c100 = arith.constant 100 : index
1020   } user_defined_assign  (%rhs: !fir.ref<i64>) to (%lhs: !fir.ref<f32>) {
1021   }
1022   return
1025 // -----
1026 func.func @bad_element_addr_1(%x: !fir.ref<!fir.array<20xf32>>) {
1027   %c20 = arith.constant 20 : index
1028   %vector_shape = fir.shape %c20 : (index) -> !fir.shape<1>
1029   hlfir.region_assign {
1030     hlfir.yield %x : !fir.ref<!fir.array<20xf32>>
1031   } to {
1032     // expected-error@+1 {{'hlfir.elemental_addr' op body must compute the address of a scalar entity}}
1033     hlfir.elemental_addr %vector_shape  : !fir.shape<1> {
1034       ^bb0(%i: index):
1035       %c42 = arith.constant 42.0 : f32
1036       hlfir.yield %c42 : f32
1037     }
1038   }
1039   return
1042 // -----
1043 func.func @bad_element_addr_2(%x: !fir.ref<!fir.array<20xf32>>) {
1044   %c20 = arith.constant 20 : index
1045   %vector_shape = fir.shape %c20 : (index) -> !fir.shape<1>
1046   hlfir.region_assign {
1047     hlfir.yield %x : !fir.ref<!fir.array<20xf32>>
1048   } to {
1049     // expected-error@+1 {{'hlfir.elemental_addr' op body must compute the address of a scalar entity}}
1050     hlfir.elemental_addr %vector_shape  : !fir.shape<1> {
1051       ^bb0(%i: index):
1052       hlfir.yield %x : !fir.ref<!fir.array<20xf32>>
1053     }
1054   }
1055   return
1058 // -----
1059 func.func @bad_element_addr_3(%x: !fir.ref<!fir.array<20xf32>>) {
1060   %c20 = arith.constant 20 : index
1061   %vector_shape = fir.shape %c20 : (index) -> !fir.shape<1>
1062   hlfir.region_assign {
1063     hlfir.yield %x : !fir.ref<!fir.array<20xf32>>
1064   } to {
1065     // expected-error@+1 {{'hlfir.elemental_addr' op body region must be terminated by an hlfir.yield}}
1066     hlfir.elemental_addr %vector_shape  : !fir.shape<1> {
1067       ^bb0(%i: index):
1068       %c42 = arith.constant 42.0 : f32
1069     }
1070   }
1071   return
1074 // -----
1075 func.func @bad_element_addr_4(%x: !fir.ref<!fir.array<20xf32>>, %y: !fir.ref<!fir.array<20x20xf32>>) {
1076   %c20 = arith.constant 20 : index
1077   %vector_shape = fir.shape %c20 : (index) -> !fir.shape<1>
1078   hlfir.region_assign {
1079     hlfir.yield %x : !fir.ref<!fir.array<20xf32>>
1080   } to {
1081     // expected-error@+1 {{'hlfir.elemental_addr' op body number of indices must match shape rank}}
1082     hlfir.elemental_addr %vector_shape  : !fir.shape<1> {
1083       ^bb0(%i: index, %j: index):
1084        %elt = hlfir.designate %y(%i, %j) : (!fir.ref<!fir.array<20x20xf32>>, index, index) -> !fir.ref<f32>
1085        hlfir.yield %elt : !fir.ref<f32>
1086     }
1087   }
1088   return
1091 // -----
1092 func.func @bad_forall(%x : !fir.box<!fir.array<10xf32>>, %y: f32, %bad : !fir.ref<!fir.array<10xindex>>) {
1093   // expected-error@+1 {{'hlfir.forall' op region #0 ('lb_region') failed to verify constraint: single block region that yields an integer scalar value}}
1094   hlfir.forall lb {
1095     hlfir.yield %bad : !fir.ref<!fir.array<10xindex>>
1096   } ub {
1097     %c10 = arith.constant 10 : index
1098     hlfir.yield %c10 : index
1099   } (%i : index) {
1100     hlfir.region_assign {
1101       hlfir.yield %y : f32
1102     } to {
1103       %xi = hlfir.designate %x(%i) : (!fir.box<!fir.array<10xf32>>, index) -> !fir.ref<f32>
1104       hlfir.yield %xi : !fir.ref<f32>
1105     }
1106   }
1107   return
1110 // -----
1111 func.func @bad_forall_2(%x : !fir.box<!fir.array<10xf32>>, %y: f32) {
1112   // expected-error@+1 {{'hlfir.forall' op body region must only contain OrderedAssignmentTreeOpInterface operations or fir.end}}
1113   hlfir.forall lb {
1114     %c1 = arith.constant 1 : index
1115     hlfir.yield %c1 : index
1116   } ub {
1117     %c10 = arith.constant 10 : index
1118     hlfir.yield %c10 : index
1119   } (%i : index) {
1120     %xi = hlfir.designate %x(%i) : (!fir.box<!fir.array<10xf32>>, index) -> !fir.ref<f32>
1121     hlfir.assign %y to %xi : f32, !fir.ref<f32>
1122   }
1123   return
1126 // -----
1127 func.func @bad_forall_mask(%i: index) {
1128   // expected-error@+1 {{'hlfir.forall_mask' op must be inside the body region of an hlfir.forall}}
1129   hlfir.forall_mask {
1130     %mask = fir.call @some_condition(%i) : (index) -> i1
1131     hlfir.yield %mask : i1
1132   } do {
1133   }
1134   return
1137 // -----
1138 func.func @bad_forall_mask_2(%mask: !fir.ref<!fir.array<10x!fir.logical<4>>>) {
1139   %c1 = arith.constant 1 : index
1140   hlfir.forall lb {
1141     hlfir.yield %c1 : index
1142   } ub {
1143     hlfir.yield %c1 : index
1144   } (%i: index) {
1145     // expected-error@+1 {{'hlfir.forall_mask' op mask region must yield a scalar i1}}
1146     hlfir.forall_mask {
1147       hlfir.yield %mask : !fir.ref<!fir.array<10x!fir.logical<4>>>
1148     } do {
1149     }
1150   }
1151   return
1154 // -----
1155 func.func @bad_where_1(%bad_mask: !fir.ref<!fir.array<10xf32>>) {
1156   // expected-error@+1 {{'hlfir.where' op mask region must yield a logical array}}
1157   hlfir.where {
1158     hlfir.yield %bad_mask : !fir.ref<!fir.array<10xf32>>
1159   } do {
1160   }
1161   return
1164 // -----
1165 func.func @bad_where_2(%bad_mask: i1) {
1166   // expected-error@+1 {{'hlfir.where' op mask region must yield a logical array}}
1167   hlfir.where {
1168     hlfir.yield %bad_mask : i1
1169   } do {
1170   }
1171   return
1174 // -----
1175 func.func @bad_where_3(%mask: !fir.ref<!fir.array<10x!fir.logical<4>>>, %n: index) {
1176   // expected-error@+1 {{'hlfir.where' op body region must not contain hlfir.forall}}
1177   hlfir.where {
1178     hlfir.yield %mask : !fir.ref<!fir.array<10x!fir.logical<4>>>
1179   } do {
1180     hlfir.forall lb {
1181       hlfir.yield %n : index
1182     } ub {
1183       hlfir.yield %n : index
1184     } (%i: index) {
1185     }
1186   }
1187   return
1190 // -----
1191 func.func @bad_elsewhere_1(%mask: !fir.ref<!fir.array<10x!fir.logical<4>>>, %bad_mask: i1) {
1192   hlfir.where {
1193     hlfir.yield %mask : !fir.ref<!fir.array<10x!fir.logical<4>>>
1194   } do {
1195     // expected-error@+1 {{'hlfir.elsewhere' op mask region must yield a logical array when provided}}
1196     hlfir.elsewhere mask {
1197       hlfir.yield %bad_mask : i1
1198     } do {
1199     }
1200   }
1201   return
1204 // -----
1205 func.func @bad_elsewhere_2(%mask: !fir.ref<!fir.array<10x!fir.logical<4>>>) {
1206   // expected-error@+1 {{'hlfir.elsewhere' op expects parent op to be one of 'hlfir.where, hlfir.elsewhere'}}
1207   hlfir.elsewhere mask {
1208     hlfir.yield %mask : !fir.ref<!fir.array<10x!fir.logical<4>>>
1209   } do {
1210   }
1211   return
1214 // -----
1215 func.func @bad_elsewhere_3(%mask: !fir.ref<!fir.array<10x!fir.logical<4>>>, %x: !fir.ref<!fir.array<10xf32>>, %y: !fir.box<!fir.array<?xf32>>) {
1216   hlfir.where {
1217     hlfir.yield %mask : !fir.ref<!fir.array<10x!fir.logical<4>>>
1218   } do {
1219     // expected-error@+1 {{'hlfir.elsewhere' op must be the last operation in the parent block}}
1220     hlfir.elsewhere mask {
1221       hlfir.yield %mask : !fir.ref<!fir.array<10x!fir.logical<4>>>
1222     } do {
1223     }
1224     hlfir.region_assign {
1225       hlfir.yield %y : !fir.box<!fir.array<?xf32>>
1226     } to {
1227       hlfir.yield %x : !fir.ref<!fir.array<10xf32>>
1228     }
1229   }
1230   return
1233 // -----
1234 func.func @bad_get_length_1(%arg0: !hlfir.expr<i32>) {
1235   // expected-error@+1 {{'hlfir.get_length' op operand #0 must be any character scalar or array expression type, but got '!hlfir.expr<i32>'}}
1236   %1 = hlfir.get_length %arg0 : (!hlfir.expr<i32>) -> index
1237   return
1240 // -----
1241 func.func @bad_get_length_2(%arg0: !hlfir.expr<?xi32>) {
1242   // expected-error@+1 {{'hlfir.get_length' op operand #0 must be any character scalar or array expression type, but got '!hlfir.expr<?xi32>'}}
1243   %1 = hlfir.get_length %arg0 : (!hlfir.expr<?xi32>) -> index
1244   return
1247 // -----
1248 func.func @bad_get_length_3(%arg0: !hlfir.expr<!fir.boxchar<1>>) {
1249   // expected-error@+1 {{'hlfir.get_length' op operand #0 must be any character scalar or array expression type, but got '!hlfir.expr<!fir.boxchar<1>>'}}
1250   %1 = hlfir.get_length %arg0 : (!hlfir.expr<!fir.boxchar<1>>) -> index
1251   return
1254 // -----
1255 func.func @elemental_poly_1(%arg0: !fir.box<!fir.array<?x!fir.type<_QMtypesTt>>>, %shape : index) {
1256   %3 = fir.shape %shape : (index) -> !fir.shape<1>
1257   // expected-error@+1 {{'hlfir.elemental' op operand #1 must be any polymorphic object, but got '!fir.box<!fir.array<?x!fir.type<_QMtypesTt>>>'}}
1258   %4 = hlfir.elemental %3 mold %arg0 unordered : (!fir.shape<1>, !fir.box<!fir.array<?x!fir.type<_QMtypesTt>>>) -> !hlfir.expr<?x!fir.type<_QMtypesTt>?> {
1259   ^bb0(%arg2: index):
1260     %6 = fir.undefined !hlfir.expr<!fir.type<_QMtypesTt>?>
1261     hlfir.yield_element %6 : !hlfir.expr<!fir.type<_QMtypesTt>?>
1262   }
1263   return
1266 // -----
1267 func.func @elemental_poly_2(%arg0: !hlfir.expr<?x!fir.type<_QMtypesTt>>, %shape : index) {
1268   %3 = fir.shape %shape : (index) -> !fir.shape<1>
1269   // expected-error@+1 {{'hlfir.elemental' op operand #1 must be any polymorphic object, but got '!hlfir.expr<?x!fir.type<_QMtypesTt>>'}}
1270   %4 = hlfir.elemental %3 mold %arg0 unordered : (!fir.shape<1>, !hlfir.expr<?x!fir.type<_QMtypesTt>>) -> !hlfir.expr<?x!fir.type<_QMtypesTt>?> {
1271   ^bb0(%arg2: index):
1272     %6 = fir.undefined !hlfir.expr<!fir.type<_QMtypesTt>?>
1273     hlfir.yield_element %6 : !hlfir.expr<!fir.type<_QMtypesTt>?>
1274   }
1275   return
1278 // -----
1279 func.func @elemental_poly_3(%arg0: !hlfir.expr<?x!fir.type<_QMtypesTt>?>, %shape : index) {
1280   %3 = fir.shape %shape : (index) -> !fir.shape<1>
1281 // expected-error@+1 {{'hlfir.elemental' op result must be polymorphic when mold is present and vice versa}}
1282   %4 = hlfir.elemental %3 mold %arg0 unordered : (!fir.shape<1>, !hlfir.expr<?x!fir.type<_QMtypesTt>?>) -> !hlfir.expr<?x!fir.type<_QMtypesTt>> {
1283   ^bb0(%arg2: index):
1284     %6 = fir.undefined !hlfir.expr<!fir.type<_QMtypesTt>>
1285     hlfir.yield_element %6 : !hlfir.expr<!fir.type<_QMtypesTt>>
1286   }
1287   return
1290 // -----
1291 func.func @elemental_poly_4(%shape : index) {
1292   %3 = fir.shape %shape : (index) -> !fir.shape<1>
1293 // expected-error@+1 {{'hlfir.elemental' op result must be polymorphic when mold is present and vice versa}}
1294   %4 = hlfir.elemental %3 unordered : (!fir.shape<1>) -> !hlfir.expr<?x!fir.type<_QMtypesTt>?> {
1295   ^bb0(%arg2: index):
1296     %6 = fir.undefined !hlfir.expr<!fir.type<_QMtypesTt>?>
1297     hlfir.yield_element %6 : !hlfir.expr<!fir.type<_QMtypesTt>?>
1298   }
1299   return
1302 // -----
1303 func.func @destroy_with_finalize(%expr: !hlfir.expr<?xi32>) {
1304 // expected-error@+1 {{'hlfir.destroy' op the element type must be finalizable, when 'finalize' is set}}
1305   hlfir.destroy %expr finalize : !hlfir.expr<?xi32>
1306   return
1309 // -----
1311 func.func @end_associate_with_alloc_comp(%var: !hlfir.expr<?x!fir.type<_QMtypesTt{x:!fir.box<!fir.heap<f32>>}>>, %shape: !fir.shape<1>) {
1312   %4:3 = hlfir.associate %var(%shape) {uniq_name = "adapt.valuebyref"} : (!hlfir.expr<?x!fir.type<_QMtypesTt{x:!fir.box<!fir.heap<f32>>}>>, !fir.shape<1>) -> (!fir.box<!fir.array<?x!fir.type<_QMtypesTt{x:!fir.box<!fir.heap<f32>>}>>>, !fir.ref<!fir.array<?x!fir.type<_QMtypesTt{x:!fir.box<!fir.heap<f32>>}>>>, i1)
1313 // expected-error@+1 {{'hlfir.end_associate' op that requires components deallocation must have var operand that is a Fortran entity}}
1314   hlfir.end_associate %4#1, %4#2 : !fir.ref<!fir.array<?x!fir.type<_QMtypesTt{x:!fir.box<!fir.heap<f32>>}>>>, i1
1315   return