brintos

brintos / llvm-project-archived public Read only

0
0
Text · 57.4 KiB · 553f69c Raw
1486 lines · plain
1// RUN: fir-opt -split-input-file -verify-diagnostics --strict-fir-volatile-verifier %s2 3// expected-error@+1{{custom op 'fir.string_lit' must have character type}}4%0 = fir.string_lit "Hello, World!"(13) : !fir.int<32>5 6// -----7 8// expected-error@+1{{custom op 'fir.string_lit' found an invalid constant}}9%0 = fir.string_lit 20(13) : !fir.int<32>10 11// -----12 13// expected-error@+1{{'fir.string_lit' op values in initializer must be integers}}14%2 = fir.string_lit [158, 2.0](2) : !fir.char<2>15 16// -----17 18func.func @bad_rebox_1(%arg0: !fir.ref<!fir.array<?x?xf32>>) {19  %c10 = arith.constant 10 : index20  %0 = fir.shape %c10 : (index) -> !fir.shape<1>21  // expected-error@+1{{op operand #0 must be box or class, but got '!fir.ref<!fir.array<?x?xf32>>'}}22  %1 = fir.rebox %arg0(%0) : (!fir.ref<!fir.array<?x?xf32>>, !fir.shape<1>) -> !fir.box<!fir.array<?xf32>>23  return24}25 26// -----27 28func.func @bad_rebox_2(%arg0: !fir.box<!fir.array<?x?xf32>>) {29  %c10 = arith.constant 10 : index30  %0 = fir.shape %c10 : (index) -> !fir.shape<1>31  // expected-error@+1{{op result #0 must be box or class, but got '!fir.ref<!fir.array<?xf32>>'}}32  %1 = fir.rebox %arg0(%0) : (!fir.box<!fir.array<?x?xf32>>, !fir.shape<1>) -> !fir.ref<!fir.array<?xf32>>33  return34}35 36// -----37 38func.func @bad_rebox_3(%arg0: !fir.box<!fir.array<*:f32>>) {39  %c10 = arith.constant 10 : index40  %0 = fir.shape %c10 : (index) -> !fir.shape<1>41  // expected-error@+1{{op box operand must not have unknown rank or type}}42  %1 = fir.rebox %arg0(%0) : (!fir.box<!fir.array<*:f32>>, !fir.shape<1>) -> !fir.box<!fir.array<?xf32>>43  return44}45 46// -----47 48func.func @bad_rebox_4(%arg0: !fir.box<!fir.array<?xf32>>) {49  // expected-error@+1{{op result type must not have unknown rank or type}}50  %0 = fir.rebox %arg0 : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<*:f32>>51  return52}53 54// -----55 56func.func @bad_rebox_5(%arg0: !fir.box<!fir.array<?x?xf32>>) {57  %c1 = arith.constant 1 : index58  %c10 = arith.constant 10 : index59  %0 = fir.slice %c1, %c10, %c1 : (index, index, index) -> !fir.slice<1>60  // expected-error@+1{{op slice operand rank must match box operand rank}}61  %1 = fir.rebox %arg0 [%0] : (!fir.box<!fir.array<?x?xf32>>, !fir.slice<1>) -> !fir.box<!fir.array<?xf32>>62  return63}64 65// -----66 67func.func @bad_rebox_6(%arg0: !fir.box<!fir.array<?xf32>>) {68  %c1 = arith.constant 1 : index69  %c10 = arith.constant 10 : index70  %0 = fir.slice %c1, %c10, %c1 : (index, index, index) -> !fir.slice<1>71  %1 = fir.shift %c1, %c1 : (index, index) -> !fir.shift<2>72  // expected-error@+1{{shape operand and input box ranks must match when there is a slice}}73  %2 = fir.rebox %arg0(%1) [%0] : (!fir.box<!fir.array<?xf32>>, !fir.shift<2>, !fir.slice<1>) -> !fir.box<!fir.array<?xf32>>74  return75}76 77// -----78 79func.func @bad_rebox_7(%arg0: !fir.box<!fir.array<?xf32>>) {80  %c1 = arith.constant 1 : index81  %c10 = arith.constant 10 : index82  %0 = fir.slice %c1, %c10, %c1 : (index, index, index) -> !fir.slice<1>83  %1 = fir.shape %c10 : (index) -> !fir.shape<1>84  // expected-error@+1{{shape operand must absent or be a fir.shift when there is a slice}}85  %2 = fir.rebox %arg0(%1) [%0] : (!fir.box<!fir.array<?xf32>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<?xf32>>86  return87}88 89// -----90 91func.func @bad_rebox_8(%arg0: !fir.box<!fir.array<?x?xf32>>) {92  %c1 = arith.constant 1 : index93  %c10 = arith.constant 10 : index94  %undef = fir.undefined index95  %0 = fir.slice %c1, %undef, %undef, %c1, %c10, %c1 : (index, index, index, index, index, index) -> !fir.slice<2>96  // expected-error@+1{{result type rank and rank after applying slice operand must match}}97  %1 = fir.rebox %arg0 [%0] : (!fir.box<!fir.array<?x?xf32>>, !fir.slice<2>) -> !fir.box<!fir.array<?x?xf32>>98  return99}100 101// -----102 103func.func @bad_rebox_9(%arg0: !fir.box<!fir.array<?xf32>>) {104  %c10 = arith.constant 10 : index105  %0 = fir.shift %c10, %c10 : (index, index) -> !fir.shift<2>106  // expected-error@+1{{shape operand and input box ranks must match when the shape is a fir.shift}}107  %1 = fir.rebox %arg0(%0) : (!fir.box<!fir.array<?xf32>>, !fir.shift<2>) -> !fir.box<!fir.array<?x?xf32>>108  return109}110 111// -----112 113func.func @bad_rebox_10(%arg0: !fir.box<!fir.array<?xf32>>) {114  %c10 = arith.constant 10 : index115  %0 = fir.shape %c10, %c10 : (index, index) -> !fir.shape<2>116  // expected-error@+1{{result type and shape operand ranks must match}}117  %1 = fir.rebox %arg0(%0) : (!fir.box<!fir.array<?xf32>>, !fir.shape<2>) -> !fir.box<!fir.array<?xf32>>118  return119}120 121// -----122 123func.func @bad_rebox_11(%arg0: !fir.box<!fir.array<?x?xf32>>) {124  %c42 = arith.constant 42 : index125  %0 = fir.shape %c42 : (index) -> !fir.shape<1>126  // expected-error@+1{{op input and output element types must match for intrinsic types}}127  %1 = fir.rebox %arg0(%0) : (!fir.box<!fir.array<?x?xf32>>, !fir.shape<1>) -> !fir.box<!fir.array<?xf64>>128  return129}130 131// -----132 133func.func @test_rebox_char(%arg0: !fir.box<!fir.array<?x!fir.char<1,20>>>) {134  %c10 = arith.constant 10 : index135  %1 = fir.shape %c10, %c10 : (index, index) -> !fir.shape<2>136  // expected-error@+1{{op input and output element types must match for intrinsic types}}137  %2 = fir.rebox %arg0(%1) : (!fir.box<!fir.array<?x!fir.char<1,20>>>, !fir.shape<2>) -> !fir.box<!fir.array<10x10x!fir.char<1,10>>>138  return139}140 141// -----142 143func.func @array_access(%arr : !fir.ref<!fir.array<?x?xf32>>) {144  %c1 = arith.constant 1 : index145  %c100 = arith.constant 100 : index146  %c50 = arith.constant 50 : index147  %shape = fir.shape %c100, %c50 : (index, index) -> !fir.shape<2>148  // expected-error@+1 {{'fir.array_coor' op operand #0 must be any reference or box, but got 'index'}}149  %p = fir.array_coor %c100(%shape) %c1, %c1 : (index, !fir.shape<2>, index, index) -> !fir.ref<f32>150  return151}152 153// -----154 155func.func @array_access(%arr : !fir.ref<f32>) {156  %c1 = arith.constant 1 : index157  %c100 = arith.constant 100 : index158  %c50 = arith.constant 50 : index159  %shape = fir.shape %c100, %c50 : (index, index) -> !fir.shape<2>160  // expected-error@+1 {{'fir.array_coor' op must be a reference to an array}}161  %p = fir.array_coor %arr(%shape) %c1, %c1 : (!fir.ref<f32>, !fir.shape<2>, index, index) -> !fir.ref<f32>162  return163}164 165// -----166 167func.func @array_access(%arr : !fir.ref<!fir.array<?x?xf32>>) {168  %c1 = arith.constant 1 : index169  %c100 = arith.constant 100 : index170  %c50 = arith.constant 50 : index171  %shape = fir.shape %c100, %c50 : (index, index) -> !fir.shape<2>172  %c47 = arith.constant 47 : index173  %c78 = arith.constant 78 : index174  %c3 = arith.constant 3 : index175  %slice = fir.slice %c47, %c78, %c3 : (index,index,index) -> !fir.slice<1>176  // expected-error@+1 {{'fir.array_coor' op rank of dimension in slice mismatched}}177  %p = fir.array_coor %arr(%shape)[%slice] %c1, %c1 : (!fir.ref<!fir.array<?x?xf32>>, !fir.shape<2>, !fir.slice<1>, index, index) -> !fir.ref<f32>178  return179}180 181// -----182 183func.func @array_access(%arr : !fir.ref<!fir.array<?x?xf32>>) {184  %c1 = arith.constant 1 : index185  %c100 = arith.constant 100 : index186  %shape = fir.shape %c100 : (index) -> !fir.shape<1>187  // expected-error@+1 {{'fir.array_coor' op rank of dimension mismatched}}188  %p = fir.array_coor %arr(%shape) %c1, %c1 : (!fir.ref<!fir.array<?x?xf32>>, !fir.shape<1>, index, index) -> !fir.ref<f32>189  return190}191 192// -----193 194func.func @array_access(%arr : !fir.ref<!fir.array<?x?xf32>>) {195  %c1 = arith.constant 1 : index196  %c100 = arith.constant 100 : index197  %shift = fir.shift %c1 : (index) -> !fir.shift<1>198  // expected-error@+1 {{'fir.array_coor' op shift can only be provided with fir.box memref}}199  %p = fir.array_coor %arr(%shift) %c1, %c1 : (!fir.ref<!fir.array<?x?xf32>>, !fir.shift<1>, index, index) -> !fir.ref<f32>200  return201}202 203// -----204 205func.func @array_access(%arr : !fir.ref<!fir.array<?x?xf32>>) {206  %c1 = arith.constant 1 : index207  %c100 = arith.constant 100 : index208  %c50 = arith.constant 50 : index209  %shape = fir.shape %c100, %c50 : (index, index) -> !fir.shape<2>210  // expected-error@+1 {{'fir.array_coor' op number of indices do not match dim rank}}211  %p = fir.array_coor %arr(%shape) %c1 : (!fir.ref<!fir.array<?x?xf32>>, !fir.shape<2>, index) -> !fir.ref<f32>212  return213}214 215// -----216 217func.func @test_misc_ops(%arr1 : !fir.ref<!fir.array<?x?xf32>>, %m : index, %n : index, %o : index, %p : index) {218  %c2 = arith.constant 2 : index219  %s = fir.shape_shift %m, %n, %o, %p : (index, index, index, index) -> !fir.shapeshift<2>220  // expected-error@+1 {{'fir.array_load' op operand #0 must be any reference or box, but got 'index'}}221  %av1 = fir.array_load %c2(%s) : (index, !fir.shapeshift<2>) -> !fir.array<?x?xf32>222  return223}224 225// -----226 227func.func @test_misc_ops(%arr1 : !fir.ref<f32>, %m : index, %n : index, %o : index, %p : index) {228  %s = fir.shape_shift %m, %n, %o, %p : (index, index, index, index) -> !fir.shapeshift<2>229  // expected-error@+1 {{'fir.array_load' op must be a reference to an array}}230  %av1 = fir.array_load %arr1(%s) : (!fir.ref<f32>, !fir.shapeshift<2>) -> !fir.array<?x?xf32>231  return232}233 234// -----235 236func.func @test_misc_ops(%arr1 : !fir.ref<!fir.array<?x?xf32>>, %m : index, %n : index, %o : index, %p : index) {237  %s = fir.shape_shift %m, %n: (index, index) -> !fir.shapeshift<1>238  // expected-error@+1 {{'fir.array_load' op rank of dimension mismatched}}239  %av1 = fir.array_load %arr1(%s) : (!fir.ref<!fir.array<?x?xf32>>, !fir.shapeshift<1>) -> !fir.array<?x?xf32>240  return241}242 243// -----244 245func.func @test_misc_ops(%arr1 : !fir.ref<!fir.array<?x?xf32>>, %m : index, %n : index, %o : index, %p : index) {246  %c2 = arith.constant 2 : index247  %shift = fir.shift %c2 : (index) -> !fir.shift<1>248  // expected-error@+1 {{'fir.array_load' op shift can only be provided with fir.box memref}}249  %av1 = fir.array_load %arr1(%shift) : (!fir.ref<!fir.array<?x?xf32>>, !fir.shift<1>) -> !fir.array<?x?xf32>250  return251}252 253// -----254 255func.func @test_misc_ops(%arr1 : !fir.ref<!fir.array<?x?xf32>>, %m : index, %n : index, %o : index, %p : index) {256  %c47 = arith.constant 47 : index257  %c78 = arith.constant 78 : index258  %c3 = arith.constant 3 : index259  %slice = fir.slice %c47, %c78, %c3 : (index,index,index) -> !fir.slice<1>260  %s = fir.shape_shift %m, %n, %o, %p: (index, index, index, index) -> !fir.shapeshift<2>261  // expected-error@+1 {{'fir.array_load' op rank of dimension in slice mismatched}}262  %av1 = fir.array_load %arr1(%s)[%slice] : (!fir.ref<!fir.array<?x?xf32>>, !fir.shapeshift<2>, !fir.slice<1>) -> !fir.array<?x?xf32>263  return264}265 266// -----267 268func.func @test_coordinate_of(%arr : !fir.ref<!fir.array<?x?xf32>>) {269  %1 = arith.constant 10 : i32270  // expected-error@+1 {{'fir.coordinate_of' op cannot find coordinate with unknown extents}}271  %2 = fir.coordinate_of %arr, %1 : (!fir.ref<!fir.array<?x?xf32>>, i32) -> !fir.ref<f32>272  return273}274 275// -----276 277func.func @test_coordinate_of(%arr : !fir.ref<!fir.array<*:f32>>) {278  %1 = arith.constant 10 : i32279  // expected-error@+1 {{'fir.coordinate_of' op cannot find coordinate in unknown shape}}280  %2 = fir.coordinate_of %arr, %1 : (!fir.ref<!fir.array<*:f32>>, i32) -> !fir.ref<f32>281  return282}283 284// -----285 286func.func @test_coordinate_of(%arr : !fir.ref<!fir.char<10>>) {287  %1 = arith.constant 10 : i32288  // expected-error@+1 {{'fir.coordinate_of' op cannot apply to this element type}}289  %2 = fir.coordinate_of %arr, %1 : (!fir.ref<!fir.char<10>>, i32) -> !fir.ref<!fir.char<10>>290  return291}292 293// -----294 295func.func @test_coordinate_of(%arr : !fir.ref<!fir.char<10, 2>>) {296  %1 = arith.constant 10 : i32297  // expected-error@+1 {{'fir.coordinate_of' op cannot apply to character singleton}}298  %2 = fir.coordinate_of %arr, %1, %1 : (!fir.ref<!fir.char<10, 2>>, i32, i32) -> !fir.ref<!fir.char<10>>299  return300}301 302// -----303 304%0 = arith.constant 22 : i32305// expected-error@+1 {{'fir.embox' op operand #0 must be any reference, but got 'i32'}}306%1 = fir.embox %0 : (i32) -> !fir.box<i32>307 308// -----309 310func.func @fun(%0 : !fir.ref<i32>) {311  %c_100 = arith.constant 100 : index312  %1 = fir.shape %c_100 : (index) -> !fir.shape<1>313  // expected-error@+1 {{'fir.embox' op shape must not be provided for a scalar}}314  %2 = fir.embox %0(%1) : (!fir.ref<i32>, !fir.shape<1>) -> !fir.box<i32>315}316 317// -----318 319func.func @fun(%0 : !fir.ref<i32>) {320  %c_100 = arith.constant 100 : index321  %1 = fir.slice %c_100, %c_100, %c_100 : (index, index, index) -> !fir.slice<1>322  // expected-error@+1 {{'fir.embox' op operand #1 must be any legal shape type, but got '!fir.slice<1>'}}323  %2 = fir.embox %0(%1) : (!fir.ref<i32>, !fir.slice<1>) -> !fir.box<i32>324}325 326// -----327 328func.func @fun(%0 : !fir.ref<i32>) {329  %c_100 = arith.constant 100 : index330  %1 = fir.shape %c_100 : (index) -> !fir.shape<1>331  // expected-error@+1 {{'fir.embox' op operand #1 must be FIR slice, but got '!fir.shape<1>'}}332  %2 = fir.embox %0[%1] : (!fir.ref<i32>, !fir.shape<1>) -> !fir.box<i32>333}334 335// -----336 337func.func @fun(%0 : !fir.ref<i32>) {338  %c_100 = arith.constant 100 : index339  %1 = fir.slice %c_100, %c_100, %c_100 : (index, index, index) -> !fir.slice<1>340  // expected-error@+1 {{'fir.embox' op slice must not be provided for a scalar}}341  %2 = fir.embox %0[%1] : (!fir.ref<i32>, !fir.slice<1>) -> !fir.box<i32>342}343 344// -----345 346func.func @embox_tdesc(%arg0: !fir.class<!fir.array<10x!fir.type<derived{a:i32,b:i32}>>>) {347  %0 = fir.alloca i32348  %c1_i32 = arith.constant 1 : i32349  %1 = fir.convert %c1_i32 : (i32) -> index350  %c10_i32 = arith.constant 10 : i32351  %2 = fir.convert %c10_i32 : (i32) -> index352  %c1 = arith.constant 1 : index353  %3 = fir.convert %1 : (index) -> i32354  %4:2 = fir.do_loop %arg2 = %1 to %2 step %c1 iter_args(%arg3 = %3) -> (index, i32) {355    fir.store %arg3 to %0 : !fir.ref<i32>356    %9 = fir.load %0 : !fir.ref<i32>357    %10 = fir.convert %9 : (i32) -> i64358    %c1_i64 = arith.constant 1 : i64359    %11 = arith.subi %10, %c1_i64 : i64360    %12 = fir.coordinate_of %arg0, %11 : (!fir.class<!fir.array<10x!fir.type<derived{a:i32,b:i32}>>>, i64) -> !fir.ref<!fir.type<derived{a:i32,b:i32}>>361    // expected-error@+1 {{'fir.embox' op source_box must be used with fir.class result type}}362    %13 = fir.embox %12 source_box %arg0 : (!fir.ref<!fir.type<derived{a:i32,b:i32}>>, !fir.class<!fir.array<10x!fir.type<derived{a:i32,b:i32}>>>) -> !fir.box<!fir.type<derived{a:i32,b:i32}>>363    %14 = arith.addi %arg2, %c1 : index364    %15 = fir.convert %c1 : (index) -> i32365    %16 = fir.load %0 : !fir.ref<i32>366    %17 = arith.addi %16, %15 : i32367    fir.result %14, %17 : index, i32368  }369  fir.store %4#1 to %0 : !fir.ref<i32>370  return371}372 373// -----374 375%lo = arith.constant 1 : index376%c1 = arith.constant 1 : index377%up = arith.constant 10 : index378%okIn = arith.constant 1 : i1379%shIn = arith.constant 1 : i16380// expected-error@+1 {{'fir.iterate_while' op expected body first argument to be an index argument for the induction variable}}381%v:3 = fir.iterate_while (%i = %lo to %up step %c1) and (%ok = %okIn) iter_args(%sh = %shIn) -> (i16, i1, i16) {382  %shNew = fir.call @bar(%sh) : (i16) -> i16383  %okNew = fir.call @foo(%sh) : (i16) -> i1384  fir.result %shNew, %okNew, %shNew : i16, i1, i16385}386 387// -----388 389%lo = arith.constant 1 : index390%c1 = arith.constant 1 : index391%up = arith.constant 10 : index392%okIn = arith.constant 1 : i1393%shIn = arith.constant 1 : i16394// expected-error@+1 {{'fir.iterate_while' op expected body second argument to be an index argument for the induction variable}}395%v:3 = fir.iterate_while (%i = %lo to %up step %c1) and (%ok = %okIn) iter_args(%sh = %shIn) -> (index, f32, i16) {396  %shNew = fir.call @bar(%sh) : (i16) -> i16397  %dummy = fir.call @foo(%sh) : (i16) -> f32398  fir.result %i, %dummy, %shNew : index, f32, i16399}400 401// -----402 403%c1 = arith.constant 1 : index404%c10 = arith.constant 10 : index405// expected-error@+1 {{'fir.do_loop' op unordered loop has no final value}}406fir.do_loop %i = %c1 to %c10 step %c1 unordered -> index {407}408 409// -----410 411%c1 = arith.constant 1 : index412%c10 = arith.constant 10 : index413fir.do_loop %i = %c1 to %c10 step %c1 -> index {414  %f1 = arith.constant 1.0 : f32415  // expected-error@+1 {{'fir.result' op types mismatch between result op and its parent}}416  fir.result %f1 : f32417}418 419// -----420 421%c1 = arith.constant 1 : index422%c10 = arith.constant 10 : index423// expected-error@+1 {{'fir.result' op parent of result must have same arity}}424fir.do_loop %i = %c1 to %c10 step %c1 -> index {425}426 427// -----428 429func.func @ugly_char_convert() {430  %1 = fir.undefined i32431  %2 = fir.undefined !fir.ref<!fir.char<1>>432  %3 = fir.undefined !fir.ref<!fir.array<?x!fir.char<1>>>433  // expected-error@+1 {{'fir.char_convert' op buffers must have different KIND values}}434  fir.char_convert %2 for %1 to %3 : !fir.ref<!fir.char<1>>, i32, !fir.ref<!fir.array<?x!fir.char<1>>>435  return436}437 438// -----439 440func.func @ugly_char_convert() {441  %1 = fir.undefined i32442  %2 = fir.undefined !fir.ref<!fir.char<1>>443  %3 = fir.undefined !fir.ref<!fir.array<?xf32>>444  // expected-error@+1 {{'fir.char_convert' op not a reference to a character}}445  fir.char_convert %2 for %1 to %3 : !fir.ref<!fir.char<1>>, i32, !fir.ref<!fir.array<?xf32>>446  return447}448 449// -----450 451func.func @ugly_char_convert() {452  %1 = fir.undefined i32453  %2 = fir.undefined !fir.ref<!fir.char<1>>454  %3 = fir.undefined !fir.ref<!fir.array<?x!fir.char<2,?>>>455  // expected-error@+1 {{'fir.char_convert' op operand #0 must be any reference, but got 'i32'}}456  fir.char_convert %1 for %1 to %3 : i32, i32, !fir.ref<!fir.array<?x!fir.char<2,?>>>457  return458}459 460// -----461 462func.func @ugly_char_convert() {463  %1 = fir.undefined i32464  %2 = fir.undefined !fir.ref<!fir.char<1>>465  %3 = fir.undefined !fir.ref<!fir.array<?x!fir.char<2,?>>>466  // expected-error@+1 {{'fir.char_convert' op operand #1 must be any integer, but got '!fir.ref<!fir.char<1>>'}}467  fir.char_convert %2 for %2 to %3 : !fir.ref<!fir.char<1>>, !fir.ref<!fir.char<1>>, !fir.ref<!fir.array<?x!fir.char<2,?>>>468  return469}470 471// -----472 473fir.global internal @_QEmultiarray : !fir.array<32x32xi32> {474  %c0_i32 = arith.constant 1 : i32475  %0 = fir.undefined !fir.array<32x32xi32>476  // expected-error@+1 {{'fir.insert_on_range' op has uneven number of values in ranges}}477  %2 = "fir.insert_on_range"(%0, %c0_i32) { coor = dense<[0, 31, 0]> : tensor<3xindex> } : (!fir.array<32x32xi32>, i32) -> !fir.array<32x32xi32>478  fir.has_value %2 : !fir.array<32x32xi32>479}480 481// -----482 483fir.global internal @_QEmultiarray : !fir.array<32x32xi32> {484  %c0_i32 = arith.constant 1 : i32485  %0 = fir.undefined !fir.array<32x32xi32>486  // expected-error@+1 {{'fir.insert_on_range' op has uneven number of values in ranges}}487  %2 = "fir.insert_on_range"(%0, %c0_i32) { coor = dense<[0]> : tensor<1xindex> }  : (!fir.array<32x32xi32>, i32) -> !fir.array<32x32xi32>488  fir.has_value %2 : !fir.array<32x32xi32>489}490 491// -----492 493fir.global internal @_QEmultiarray : !fir.array<32x32xi32> {494  %c0_i32 = arith.constant 1 : i32495  %0 = fir.undefined !fir.array<32x32xi32>496  // expected-error@+1 {{'fir.insert_on_range' op negative range bound}}497  %2 = fir.insert_on_range %0, %c0_i32 from (-1) to (0) : (!fir.array<32x32xi32>, i32) -> !fir.array<32x32xi32>498  fir.has_value %2 : !fir.array<32x32xi32>499}500 501// -----502 503fir.global internal @_QEmultiarray : !fir.array<32x32xi32> {504  %c0_i32 = arith.constant 1 : i32505  %0 = fir.undefined !fir.array<32x32xi32>506  // expected-error@+1 {{'fir.insert_on_range' op empty range}}507  %2 = fir.insert_on_range %0, %c0_i32 from (10) to (9) : (!fir.array<32x32xi32>, i32) -> !fir.array<32x32xi32>508  fir.has_value %2 : !fir.array<32x32xi32>509}510 511// -----512 513fir.global internal @_QEmultiarray : !fir.array<?xi32> {514  %c0_i32 = arith.constant 1 : i32515  %0 = fir.undefined !fir.array<?xi32>516  // expected-error@+1 {{'fir.insert_on_range' op must have constant shape and size}}517  %2 = fir.insert_on_range %0, %c0_i32 from (0) to (10) : (!fir.array<?xi32>, i32) -> !fir.array<?xi32>518  fir.has_value %2 : !fir.array<?xi32>519}520 521// -----522 523fir.global internal @_QEmultiarray : !fir.array<*:i32> {524  %c0_i32 = arith.constant 1 : i32525  %0 = fir.undefined !fir.array<*:i32>526  // expected-error@+1 {{'fir.insert_on_range' op must have constant shape and size}}527  %2 = fir.insert_on_range %0, %c0_i32 from (0) to (10) : (!fir.array<*:i32>, i32) -> !fir.array<*:i32>528  fir.has_value %2 : !fir.array<*:i32>529}530 531// -----532 533func.func @bad_save_result(%buffer : !fir.ref<!fir.array<?xf64>>, %n :index) {534  %res = fir.call @array_func() : () -> !fir.array<?xf32>535  %shape = fir.shape %n : (index) -> !fir.shape<1>536  // expected-error@+1 {{'fir.save_result' op value type must match memory reference type}}537  fir.save_result %res to %buffer(%shape) : !fir.array<?xf32>, !fir.ref<!fir.array<?xf64>>, !fir.shape<1>538  return539}540 541// -----542 543func.func @bad_save_result(%buffer : !fir.ref<!fir.box<!fir.array<*:f32>>>) {544  %res = fir.call @array_func() : () -> !fir.box<!fir.array<*:f32>>545  // expected-error@+1 {{'fir.save_result' op cannot save !fir.box of unknown rank or type}}546  fir.save_result %res to %buffer : !fir.box<!fir.array<*:f32>>, !fir.ref<!fir.box<!fir.array<*:f32>>>547  return548}549 550// -----551 552func.func @bad_save_result(%buffer : !fir.ref<f64>) {553  %res = fir.call @array_func() : () -> f64554  // expected-error@+1 {{'fir.save_result' op operand #0 must be fir.box, fir.array or fir.type, but got 'f64'}}555  fir.save_result %res to %buffer : f64, !fir.ref<f64>556  return557}558 559// -----560 561func.func @bad_save_result(%buffer : !fir.ref<!fir.box<!fir.array<?xf32>>>, %n : index) {562  %res = fir.call @array_func() : () -> !fir.box<!fir.array<?xf32>>563  %shape = fir.shape %n : (index) -> !fir.shape<1>564  // expected-error@+1 {{'fir.save_result' op must not have shape or length operands if the value is a fir.box}}565  fir.save_result %res to %buffer(%shape) : !fir.box<!fir.array<?xf32>>, !fir.ref<!fir.box<!fir.array<?xf32>>>, !fir.shape<1>566  return567}568 569// -----570 571func.func @bad_save_result(%buffer : !fir.ref<!fir.array<?xf32>>, %n :index) {572  %res = fir.call @array_func() : () -> !fir.array<?xf32>573  %shape = fir.shape %n, %n : (index, index) -> !fir.shape<2>574  // expected-error@+1 {{'fir.save_result' op shape operand must be provided and have the value rank when the value is a fir.array}}575  fir.save_result %res to %buffer(%shape) : !fir.array<?xf32>, !fir.ref<!fir.array<?xf32>>, !fir.shape<2>576  return577}578 579// -----580 581func.func @bad_save_result(%buffer : !fir.ref<!fir.type<t{x:f32}>>, %n :index) {582  %res = fir.call @array_func() : () -> !fir.type<t{x:f32}>583  %shape = fir.shape %n : (index) -> !fir.shape<1>584  // expected-error@+1 {{'fir.save_result' op shape operand should only be provided if the value is a fir.array}}585  fir.save_result %res to %buffer(%shape) : !fir.type<t{x:f32}>, !fir.ref<!fir.type<t{x:f32}>>, !fir.shape<1>586  return587}588 589// -----590 591func.func @bad_save_result(%buffer : !fir.ref<!fir.type<t{x:f32}>>, %n :index) {592  %res = fir.call @array_func() : () -> !fir.type<t{x:f32}>593  // expected-error@+1 {{'fir.save_result' op length parameters number must match with the value type length parameters}}594  fir.save_result %res to %buffer typeparams %n : !fir.type<t{x:f32}>, !fir.ref<!fir.type<t{x:f32}>>, index595  return596}597 598// -----599 600func.func @bad_save_result(%buffer : !fir.ref<!fir.array<?xf32>>, %n :index) {601  %res = fir.call @array_func() : () -> !fir.array<?xf32>602  %shape = fir.shape %n : (index) -> !fir.shape<1>603  // expected-error@+1 {{'fir.save_result' op length parameters must not be provided for this value type}}604  fir.save_result %res to %buffer(%shape) typeparams %n : !fir.array<?xf32>, !fir.ref<!fir.array<?xf32>>, !fir.shape<1>, index605  return606}607 608// -----609 610func.func @test_misc_ops(%arr1 : !fir.ref<!fir.array<?x?xf32>>, %m : index, %n : index, %o : index, %p : index) {611  %s = fir.shape_shift %m, %n, %o, %p : (index, index, index, index) -> !fir.shapeshift<2>612  %av1 = fir.array_load %arr1(%s) : (!fir.ref<!fir.array<?x?xf32>>, !fir.shapeshift<2>) -> !fir.array<?x?xf32>613  // expected-error@+1 {{'fir.array_fetch' op number of indices != dimension of array}}614  %f = fir.array_fetch %av1, %m : (!fir.array<?x?xf32>, index) -> f32615  return616}617 618// -----619 620func.func @test_misc_ops(%arr1 : !fir.ref<!fir.array<?x?xf32>>, %m : index, %n : index, %o : index, %p : index) {621  %s = fir.shape_shift %m, %n, %o, %p : (index, index, index, index) -> !fir.shapeshift<2>622  %av1 = fir.array_load %arr1(%s) : (!fir.ref<!fir.array<?x?xf32>>, !fir.shapeshift<2>) -> !fir.array<?x?xf32>623  // expected-error@+1 {{'fir.array_fetch' op return type does not match array}}624  %f = fir.array_fetch %av1, %m, %n : (!fir.array<?x?xf32>, index, index) -> i32625  return626}627 628// -----629 630func.func @test_misc_ops(%arr1 : !fir.ref<!fir.array<?x?xf32>>, %m : index, %n : index, %o : index, %p : index) {631  %s = fir.shape_shift %m, %n, %o, %p : (index, index, index, index) -> !fir.shapeshift<2>632  %av1 = fir.array_load %arr1(%s) : (!fir.ref<!fir.array<?x?xf32>>, !fir.shapeshift<2>) -> !fir.array<?x?xf32>633  %f = fir.array_fetch %av1, %m, %n : (!fir.array<?x?xf32>, index, index) -> f32634  // expected-error@+1 {{'fir.array_update' op number of indices != dimension of array}}635  %av2 = fir.array_update %av1, %f, %m : (!fir.array<?x?xf32>, f32, index) -> !fir.array<?x?xf32>636  return637}638 639// -----640 641func.func @test_misc_ops(%arr1 : !fir.ref<!fir.array<?x?xf32>>, %m : index, %n : index, %o : index, %p : index) {642  %s = fir.shape_shift %m, %n, %o, %p : (index, index, index, index) -> !fir.shapeshift<2>643  %av1 = fir.array_load %arr1(%s) : (!fir.ref<!fir.array<?x?xf32>>, !fir.shapeshift<2>) -> !fir.array<?x?xf32>644  %c0 = arith.constant 0 : i32645  // expected-error@+1 {{'fir.array_update' op merged value does not have element type}}646  %av2 = fir.array_update %av1, %c0, %m, %n : (!fir.array<?x?xf32>, i32, index, index) -> !fir.array<?x?xf32>647  return648}649 650// -----651 652func.func @test_misc_ops(%arr1 : !fir.ref<!fir.array<?x?xf32>>, %m : index, %n : index, %o : index, %p : index, %f: !fir.ref<i32>) {653  %s = fir.shape_shift %m, %n, %o, %p : (index, index, index, index) -> !fir.shapeshift<2>654  %av1 = fir.array_load %arr1(%s) : (!fir.ref<!fir.array<?x?xf32>>, !fir.shapeshift<2>) -> !fir.array<?x?xf32>655  // expected-error@+1 {{'fir.array_update' op does not support reference type for merge}}656  %av2 = fir.array_update %av1, %f, %m, %n : (!fir.array<?x?xf32>, !fir.ref<i32>, index, index) -> !fir.array<?x?xf32>657  return658}659 660// -----661 662func.func @test_misc_ops(%arr1 : !fir.ref<!fir.array<?x?xf32>>, %m : index, %n : index, %o : index, %p : index) {663  %s = fir.shape_shift %m, %n, %o, %p : (index, index, index, index) -> !fir.shapeshift<2>664  %av1 = fir.array_load %arr1(%s) : (!fir.ref<!fir.array<?x?xf32>>, !fir.shapeshift<2>) -> !fir.array<?x?xf32>665  %f = fir.array_fetch %av1, %m, %n : (!fir.array<?x?xf32>, index, index) -> f32666  %av2 = fir.array_update %av1, %f, %m, %n : (!fir.array<?x?xf32>, f32, index, index) -> !fir.array<?x?xf32>667  // expected-error@+1 {{'fir.array_merge_store' op operand #0 must be result of a fir.array_load op}}668  fir.array_merge_store %av2, %av2 to %arr1 : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.ref<!fir.array<?x?xf32>>669  return670}671 672// -----673 674func.func @bad_array_modify(%arr1 : !fir.ref<!fir.array<?x?xf32>>, %m : index, %n : index, %o : index, %p : index, %f : f32) {675  %i10 = arith.constant 10 : index676  %j20 = arith.constant 20 : index677  %s = fir.shape_shift %m, %n, %o, %p : (index, index, index, index) -> !fir.shapeshift<2>678  %av1 = fir.array_load %arr1(%s) : (!fir.ref<!fir.array<?x?xf32>>, !fir.shapeshift<2>) -> !fir.array<?x?xf32>679  // expected-error@+1 {{'fir.array_modify' op number of indices must match array dimension}}680  %addr, %av2 = fir.array_modify %av1, %i10 : (!fir.array<?x?xf32>, index) -> (!fir.ref<f32>, !fir.array<?x?xf32>)681  fir.store %f to %addr : !fir.ref<f32>682  fir.array_merge_store %av1, %av2 to %arr1 : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.ref<!fir.array<?x?xf32>>683  return684}685 686// -----687 688func.func @slice_must_be_integral() {689  %0 = arith.constant 42 : i32690  %1 = fir.field_index field, !fir.type<t(param:i32){field:i32}> (%0 : i32)691  // expected-error@+1 {{'fir.slice' op operand #0 must be variadic of any integer, but got '!fir.field'}}692  %2 = fir.slice %1, %1, %1 : (!fir.field, !fir.field, !fir.field) -> !fir.slice<1>693  return694}695 696// -----697 698func.func @array_coor_no_slice_substr(%a : !fir.ref<!fir.array<?x?xf32>>) {699  %c1 = arith.constant 1 : index700  %c10 = arith.constant 10 : index701  %slice = fir.slice %c1, %c10, %c1 substr %c1, %c10 : (index, index, index, index, index) -> !fir.slice<1>702  // expected-error@+1 {{'fir.array_coor' op array_coor cannot take a slice with substring}}703  %p = fir.array_coor %a[%slice] %c1, %c1 : (!fir.ref<!fir.array<?x?xf32>>, !fir.slice<1>, index, index) -> !fir.ref<f32>704  return705}706 707// -----708 709func.func @array_coor_no_slice_substr(%a : !fir.ref<!fir.array<?x?xf32>>) {710  %c1 = arith.constant 1 : index711  %c10 = arith.constant 10 : index712  %slice = fir.slice %c1, %c10, %c1 substr %c1, %c10 : (index, index, index, index, index) -> !fir.slice<1>713  // expected-error@+1 {{'fir.array_load' op array_load cannot take a slice with substring}}714  %v = fir.array_load %a[%slice] : (!fir.ref<!fir.array<?x?xf32>>, !fir.slice<1>) -> !fir.array<?x?xf32>715  return716}717 718// -----719 720func.func @array_merge_store_no_slice_substr(%arr1 : !fir.ref<!fir.array<?x?xf32>>, %m : index, %n : index, %o : index, %p : index, %f : f32) {721  %i10 = arith.constant 10 : index722  %j20 = arith.constant 20 : index723  %c1 = arith.constant 1 : index724  %c10 = arith.constant 10 : index725  %s = fir.shape_shift %m, %n, %o, %p : (index, index, index, index) -> !fir.shapeshift<2>726  %slice = fir.slice %c1, %c10, %c1 substr %c1, %c10 : (index, index, index, index, index) -> !fir.slice<1>727  %av1 = fir.array_load %arr1(%s) : (!fir.ref<!fir.array<?x?xf32>>, !fir.shapeshift<2>) -> !fir.array<?x?xf32>728  %addr, %av2 = fir.array_modify %av1, %i10, %i10 : (!fir.array<?x?xf32>, index, index) -> (!fir.ref<f32>, !fir.array<?x?xf32>)729  fir.store %f to %addr : !fir.ref<f32>730  // expected-error@+1 {{'fir.array_merge_store' op array_merge_store cannot take a slice with substring}}731  fir.array_merge_store %av1, %av2 to %arr1[%slice] : !fir.array<?x?xf32>, !fir.array<?x?xf32>, !fir.ref<!fir.array<?x?xf32>>, !fir.slice<1>732  return733}734 735// -----736 737func.func @array_access(%a : !fir.ref<!fir.array<?x?xf32>>) {738  %c1 = arith.constant 1 : index739  %n = arith.constant 0 : index740  %m = arith.constant 50 : index741  %s = fir.shape %n, %m : (index, index) -> !fir.shape<2>742  %v = fir.array_load %a(%s) : (!fir.ref<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>743  // expected-error@+1 {{'fir.array_access' op number of indices != dimension of array}}744  %p = fir.array_access %v, %c1 : (!fir.array<?x?xf32>, index) -> !fir.ref<f32>745  return746}747 748// -----749 750func.func @array_access(%a : !fir.ref<!fir.array<?x?xf32>>) {751  %c1 = arith.constant 1 : index752  %n = arith.constant 0 : index753  %m = arith.constant 50 : index754  %s = fir.shape %n, %m : (index, index) -> !fir.shape<2>755  %v = fir.array_load %a(%s) : (!fir.ref<!fir.array<?x?xf32>>, !fir.shape<2>) -> !fir.array<?x?xf32>756  // expected-error@+1 {{'fir.array_access' op return type does not match array}}757  %p = fir.array_access %v, %c1, %c1 : (!fir.array<?x?xf32>, index, index) -> !fir.ref<f64>758  return759}760 761// -----762 763func.func @foo(%arg0: !fir.ref<!fir.array<30x!fir.type<t{c:!fir.array<20xi32>}>>>) {764  %c1 = arith.constant 1 : index765  %c0 = arith.constant 0 : index766  %c9 = arith.constant 9 : index767  %c19 = arith.constant 19 : index768  %c30 = arith.constant 30 : index769  %0 = fir.shape %c30 : (index) -> !fir.shape<1>770  %1 = fir.array_load %arg0(%0) : (!fir.ref<!fir.array<30x!fir.type<t{c:!fir.array<20xi32>}>>>, !fir.shape<1>) -> !fir.array<30x!fir.type<t{c:!fir.array<20xi32>}>>771  %2 = fir.do_loop %arg1 = %c1 to %c9 step %c1 unordered iter_args(%arg2 = %1) -> (!fir.array<30x!fir.type<t{c:!fir.array<20xi32>}>>) {772    %3 = fir.field_index c, !fir.type<t{c:!fir.array<20xi32>}>773    %4 = fir.do_loop %arg3 = %c0 to %c19 step %c1 unordered iter_args(%arg4 = %arg2) -> (!fir.array<30x!fir.type<t{c:!fir.array<20xi32>}>>) {774      // expected-error@+1 {{'fir.array_access' op return type and/or indices do not type check}}775      %5 = fir.array_access %1, %arg1, %3, %arg3 : (!fir.array<30x!fir.type<t{c:!fir.array<20xi32>}>>, index, !fir.field, index) -> !fir.ref<f32>776      %6 = fir.call @ifoo(%5) : (!fir.ref<f32>) -> i32777      %7 = fir.array_update %arg4, %6, %arg1, %3, %arg3 : (!fir.array<30x!fir.type<t{c:!fir.array<20xi32>}>>, i32, index, !fir.field, index) -> !fir.array<30x!fir.type<t{c:!fir.array<20xi32>}>>778      fir.result %7 : !fir.array<30x!fir.type<t{c:!fir.array<20xi32>}>>779    }780    fir.result %4 : !fir.array<30x!fir.type<t{c:!fir.array<20xi32>}>>781  }782  fir.array_merge_store %1, %2 to %arg0 : !fir.array<30x!fir.type<t{c:!fir.array<20xi32>}>>, !fir.array<30x!fir.type<t{c:!fir.array<20xi32>}>>, !fir.ref<!fir.array<30x!fir.type<t{c:!fir.array<20xi32>}>>>783  return784}785func.func private @ifoo(!fir.ref<f32>) -> i32786 787// -----788 789func.func private @dispatch(%arg0: !fir.class<!fir.type<derived{a:i32,b:i32}>>) -> () {790  // expected-error@+1 {{'fir.dispatch' op pass_arg_pos must be smaller than the number of operands}}791  fir.dispatch "proc1"(%arg0 : !fir.class<!fir.type<derived{a:i32,b:i32}>>) (%arg0 : !fir.class<!fir.type<derived{a:i32,b:i32}>>) {pass_arg_pos = 1 : i32}792  return793}794 795// -----796 797func.func private @dispatch(%arg0: !fir.class<!fir.type<derived{a:i32,b:i32}>>, %arg1: i32) -> () {798  // expected-error@+1 {{'fir.dispatch' op pass_arg_pos must be a polymorphic operand}}799  fir.dispatch "proc1"(%arg0 : !fir.class<!fir.type<derived{a:i32,b:i32}>>) (%arg0, %arg1 : !fir.class<!fir.type<derived{a:i32,b:i32}>>, i32) {pass_arg_pos = 1 : i32}800  return801}802 803// -----804func.func @test_fortran_var_attrs() {805  // expected-error@+1 {{Unknown fortran variable attribute: volatypo}}806  %0 = fir.alloca f32 {fortran_attrs = #fir.var_attrs<volatypo>}807}808 809// -----810func.func @bad_numeric_declare(%arg0: !fir.ref<f32>) {811  %c1 = arith.constant 1 : index812  // expected-error@+1 {{'fir.declare' op requires attribute 'uniq_name'}}813  %0 = fir.declare %arg0 typeparams %c1 {uniq_typo = "x"} : (!fir.ref<f32>, index) -> !fir.ref<f32>814  return815}816 817// -----818func.func @bad_numeric_declare(%arg0: !fir.ref<f32>) {819  %c1 = arith.constant 1 : index820  // expected-error@+1 {{'fir.declare' op of numeric, logical, or assumed type entity must not have length parameters}}821  %0 = fir.declare %arg0 typeparams %c1 {uniq_name = "x"} : (!fir.ref<f32>, index) -> !fir.ref<f32>822  return823}824 825// -----826func.func @bad_char_declare(%arg0: !fir.boxchar<1> ) {827  %0:2 = fir.unboxchar %arg0 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)828  // expected-error@+1 {{'fir.declare' op must be provided exactly one type parameter when its base is a character that is not a box}}829  %1 = fir.declare %0#0 {uniq_name = "c"} : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1,?>>830  return831}832 833// -----834func.func @bad_char_declare(%arg0: !fir.boxchar<1> ) {835  %0:2 = fir.unboxchar %arg0 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)836  // expected-error@+1 {{'fir.declare' op of character entity must have at most one length parameter}}837  %1 = fir.declare %0#0 typeparams %0#1, %0#1 {uniq_name = "c"} : (!fir.ref<!fir.char<1,?>>, index, index) -> !fir.ref<!fir.char<1,?>>838  return839}840 841// -----842func.func @bad_derived_declare(%arg0: !fir.ref<!fir.type<t{field:i32}>>) {843  %c1 = arith.constant 1 : index844  // expected-error@+1 {{'fir.declare' op has too many length parameters}}845  %0 = fir.declare %arg0 typeparams %c1 {uniq_name = "x"} : (!fir.ref<!fir.type<t{field:i32}>>, index) -> !fir.ref<!fir.type<t{field:i32}>>846  return847}848 849// -----850func.func @bad_pdt_declare(%arg0: !fir.ref<!fir.type<pdt(param:i32){field:i32}>>) {851  // expected-error@+1 {{'fir.declare' op must be provided all the derived type length parameters when the base is not a box}}852  %0 = fir.declare %arg0 {uniq_name = "x"} : (!fir.ref<!fir.type<pdt(param:i32){field:i32}>>) -> !fir.ref<!fir.type<pdt(param:i32){field:i32}>>853  return854}855 856// -----857func.func @bad_pdt_declare_2(%arg0: !fir.ref<!fir.type<pdt(param:i32){field:i32}>>) {858  %c1 = arith.constant 1 : index859  // expected-error@+1 {{'fir.declare' op has too many length parameters}}860  %0 = fir.declare %arg0 typeparams %c1, %c1 {uniq_name = "x"} : (!fir.ref<!fir.type<pdt(param:i32){field:i32}>>, index, index) -> !fir.ref<!fir.type<pdt(param:i32){field:i32}>>861  return862}863 864 865// -----866func.func @bad_array_declare(%arg0: !fir.ref<!fir.array<?x?xf32>>) {867  // expected-error@+1 {{'fir.declare' op of array entity with a raw address base must have a shape operand that is a shape or shapeshift}}868  %0 = fir.declare %arg0 {uniq_name = "x"} : (!fir.ref<!fir.array<?x?xf32>>) -> !fir.ref<!fir.array<?x?xf32>>869  return870}871 872// -----873func.func @bad_array_declare_2(%arg0: !fir.ref<!fir.array<?x?xf32>>) {874  %c1 = arith.constant 1 : index875  %c2 = arith.constant 2 : index876  %shift = fir.shift %c1, %c2 : (index, index) -> !fir.shift<2>877  // expected-error@+1 {{'fir.declare' op of array entity with a raw address base must have a shape operand that is a shape or shapeshift}}878  %0 = fir.declare %arg0(%shift) {uniq_name = "x"} : (!fir.ref<!fir.array<?x?xf32>>, !fir.shift<2>) -> !fir.ref<!fir.array<?x?xf32>>879  return880}881 882// -----883func.func @bad_array_declare_3(%arg0: !fir.ref<!fir.array<?x?xf32>>) {884  %c1 = arith.constant 1 : index885  %shape = fir.shape %c1 : (index) -> !fir.shape<1>886  // expected-error@+1 {{'fir.declare' op has conflicting shape and base operand ranks}}887  %0 = fir.declare %arg0(%shape) {uniq_name = "x"} : (!fir.ref<!fir.array<?x?xf32>>, !fir.shape<1>) -> !fir.ref<!fir.array<?x?xf32>>888  return889}890 891// -----892func.func @bad_array_declare_4(%arg0: !fir.ref<!fir.array<?x?xf32>>) {893  %c1 = arith.constant 1 : index894  %shape = fir.shape_shift %c1, %c1 : (index, index) -> !fir.shapeshift<1>895  // expected-error@+1 {{'fir.declare' op has conflicting shape and base operand ranks}}896  %0 = fir.declare %arg0(%shape) {uniq_name = "x"} : (!fir.ref<!fir.array<?x?xf32>>, !fir.shapeshift<1>) -> !fir.ref<!fir.array<?x?xf32>>897  return898}899 900// -----901func.func @bad_array_declare_box(%arg0: !fir.box<!fir.array<?x?xf32>>) {902  %c1 = arith.constant 1 : index903  %shape = fir.shift %c1 : (index) -> !fir.shift<1>904  // expected-error@+1 {{'fir.declare' op has conflicting shape and base operand ranks}}905  %0 = fir.declare %arg0(%shape) {uniq_name = "x"} : (!fir.box<!fir.array<?x?xf32>>, !fir.shift<1>) -> !fir.box<!fir.array<?x?xf32>>906  return907}908 909// -----910func.func @bad_array_declare_char_boxaddr(%arg0: !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?x!fir.char<1,?>>>>>) {911  %c1 = arith.constant 1 : index912  %c2 = arith.constant 2 : index913  %shape = fir.shift %c1, %c2 : (index, index) -> !fir.shift<2>914  // expected-error@+1 {{'fir.declare' op for box address must not have a shape operand}}915  %0 = fir.declare %arg0(%shape) {uniq_name = "x"} : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?x?x!fir.char<1,?>>>>>, !fir.shift<2>) -> !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?x!fir.char<1,?>>>>>916  return917}918 919// -----920func.func @bad_array_declare_unlimited_polymorphic_boxaddr(%arg0: !fir.ref<!fir.class<!fir.ptr<!fir.array<?x?xnone>>>>) {921  %c1 = arith.constant 1 : index922  %c2 = arith.constant 2 : index923  %shape = fir.shift %c1, %c2 : (index, index) -> !fir.shift<2>924  // expected-error@+1 {{'fir.declare' op for box address must not have a shape operand}}925  %0 = fir.declare %arg0(%shape) {uniq_name = "x"} : (!fir.ref<!fir.class<!fir.ptr<!fir.array<?x?xnone>>>>, !fir.shift<2>) -> !fir.ref<!fir.class<!fir.ptr<!fir.array<?x?xnone>>>>926  return927}928 929// -----930 931func.func @invalid_selector(%arg : !fir.box<!fir.ref<i32>>) -> i32 {932  %0 = arith.constant 1 : i32933  %2 = arith.constant 3 : i32934  // expected-error@+1{{'fir.select_type' op selector must be polymorphic}}935  fir.select_type %arg : !fir.box<!fir.ref<i32>> [936    #fir.type_is<!fir.int<4>>,^bb1(%0:i32),937    #fir.type_is<!fir.int<8>>,^bb2(%2:i32),938    unit,^bb5 ]939^bb1(%a : i32) :940  return %a : i32941^bb2(%b : i32) :942  return %b : i32943^bb5 :944  %zero = arith.constant 0 : i32945  return %zero : i32946}947 948// -----949 950func.func @logical_to_fp(%arg0: !fir.logical<4>) -> f32 {951  // expected-error@+1{{'fir.convert' op invalid type conversion}}952  %0 = fir.convert %arg0 : (!fir.logical<4>) -> f32953  return %0 : f32954}955 956// -----957 958func.func @fp_to_logical(%arg0: f32) -> !fir.logical<4> {959  // expected-error@+1{{'fir.convert' op invalid type conversion}}960  %0 = fir.convert %arg0 : (f32) -> !fir.logical<4>961  return %0 : !fir.logical<4>962}963 964// -----965 966func.func @rec_to_rec(%arg0: !fir.type<t1{i:i32, f:f32}>) -> !fir.type<t2{f:f32, i:i32}> {967  // expected-error@+1{{'fir.convert' op invalid type conversion}}968  %0 = fir.convert %arg0 : (!fir.type<t1{i:i32, f:f32}>) -> !fir.type<t2{f:f32, i:i32}>969  return %0 : !fir.type<t2{f:f32, i:i32}>970}971 972// -----973 974func.func @bad_box_offset(%not_a_box : !fir.ref<i32>) {975  // expected-error@+1{{'fir.box_offset' op box_ref operand must have !fir.ref<!fir.box<T>> or !fir.ref<!fir.boxchar<k>> type}}976  %addr1 = fir.box_offset %not_a_box base_addr : (!fir.ref<i32>) -> !fir.llvm_ptr<!fir.ref<i32>>977  return978}979 980// -----981 982func.func @bad_box_offset(%boxchar : !fir.ref<!fir.boxchar<1>>) {983  // expected-error@+1{{'fir.box_offset' op cannot address derived_type field of a fir.boxchar}}984  %addr1 = fir.box_offset %boxchar derived_type : (!fir.ref<!fir.boxchar<1>>) -> !fir.llvm_ptr<!fir.ref<!fir.char<1,?>>>985  return986}987 988// -----989 990func.func @bad_box_offset(%no_addendum : !fir.ref<!fir.box<i32>>) {991  // expected-error@+1{{'fir.box_offset' op can only address derived_type field of derived type or unlimited polymorphic fir.box}}992  %addr1 = fir.box_offset %no_addendum derived_type : (!fir.ref<!fir.box<i32>>) -> !fir.llvm_ptr<!fir.tdesc<!fir.type<none>>>993  return994}995 996// -----997 998func.func @bad_rebox_assumed_rank_1(%arg0: !fir.ref<!fir.array<*:f32>> ) {999  // expected-error@+1{{'fir.rebox_assumed_rank' op input must be a box or box address}}1000  %1 = fir.rebox_assumed_rank %arg0 lbs ones : (!fir.ref<!fir.array<*:f32>>) -> !fir.box<!fir.array<*:f32>>1001  return1002}1003 1004// -----1005 1006func.func @bad_rebox_assumed_rank_2(%arg0: !fir.box<!fir.array<*:f32>> ) {1007  // expected-error@+1{{'fir.rebox_assumed_rank' op result #0 must be box or class, but got '!fir.ref<!fir.box<!fir.array<*:f32>>>'}}1008  %1 = fir.rebox_assumed_rank %arg0 lbs ones : (!fir.box<!fir.array<*:f32>>) -> !fir.ref<!fir.box<!fir.array<*:f32>>>1009  return1010}1011 1012// -----1013 1014func.func @bad_rebox_assumed_rank_3(%arg0: !fir.box<!fir.array<*:f32>> ) {1015  // expected-error@+1{{'fir.rebox_assumed_rank' op input and output element types are incompatible}}1016  %1 = fir.rebox_assumed_rank %arg0 lbs ones : (!fir.box<!fir.array<*:f32>>) -> !fir.box<!fir.array<*:i32>>1017  return1018}1019 1020// -----1021 1022func.func @bad_is_assumed_size(%arg0: !fir.ref<!fir.array<*:none>>) {1023  // expected-error@+1{{op operand #0 must be box or class, but got '!fir.ref<!fir.array<*:none>>'}}1024  %1 = fir.is_assumed_size %arg0 : (!fir.ref<!fir.array<*:none>>) -> i11025  return1026}1027 1028// -----1029 1030!t=!fir.type<sometype{i:i32}>1031!t2=!fir.type<sometype2{j:i32}>1032func.func @bad_copy_1(%arg0: !fir.ref<!t>, %arg1: !fir.ref<!t2>) {1033  // expected-error@+1{{'fir.copy' op source and destination must have the same value type}}1034  fir.copy %arg0 to %arg1 no_overlap : !fir.ref<!t>, !fir.ref<!t2>1035  return1036}1037 1038// -----1039 1040!t=!fir.type<sometype{i:i32}>1041func.func @bad_copy_2(%arg0: !fir.ref<!t>, %arg1: !t) {1042  // expected-error@+1{{'fir.copy' op operand #0 must be a reference type to a constant size fir.array, fir.char, or fir.type, but got '!fir.type<sometype{i:i32}>'}}1043  fir.copy %arg1 to %arg0 no_overlap : !t, !fir.ref<!t>1044  return1045}1046 1047// -----1048 1049!t=!fir.array<?xi32>1050func.func @bad_copy_3(%arg0: !fir.ref<!t>, %arg1: !fir.ref<!t>) {1051  // expected-error@+1{{'fir.copy' op operand #0 must be a reference type to a constant size fir.array, fir.char, or fir.type, but got '!fir.ref<!fir.array<?xi32>>'}}1052  fir.copy %arg0 to %arg1 no_overlap : !fir.ref<!t>, !fir.ref<!t>1053  return1054}1055 1056// -----1057 1058!t=f321059func.func @bad_copy_4(%arg0: !fir.ref<!t>, %arg1: !fir.ref<!t>) {1060  // expected-error@+1{{'fir.copy' op operand #0 must be a reference type to a constant size fir.array, fir.char, or fir.type, but got '!fir.ref<f32>'}}1061  fir.copy %arg0 to %arg1 no_overlap : !fir.ref<!t>, !fir.ref<!t>1062  return1063}1064 1065// -----1066 1067func.func @bad_pack_array1(%arg0: !fir.ref<!fir.box<!fir.array<?xi32>>>) {1068  // expected-error@+1{{op operand #0 must be any boxed array, but got '!fir.ref<!fir.box<!fir.array<?xi32>>>'}}1069  %0 = fir.pack_array %arg0 stack whole : (!fir.ref<!fir.box<!fir.array<?xi32>>>) -> !fir.ref<!fir.box<!fir.array<?xi32>>>1070  return1071}1072 1073// -----1074 1075func.func @bad_pack_array2(%arg0: !fir.box<!fir.array<?xi32>>) {1076  // expected-error@+1{{op failed to verify that all of {array, result} have same type}}1077  %0 = fir.pack_array %arg0 stack whole : (!fir.box<!fir.array<?xi32>>) -> !fir.box<!fir.array<?xi64>>1078  return1079}1080 1081// -----1082 1083func.func @bad_pack_array3(%arg0: !fir.box<!fir.array<?x!fir.char<1,?>>>, %arg1: i32) {1084  // expected-error@+1{{op invalid type parameters}}1085  %0 = fir.pack_array %arg0 stack whole typeparams %arg1, %arg1 : (!fir.box<!fir.array<?x!fir.char<1,?>>>, i32, i32) -> !fir.box<!fir.array<?x!fir.char<1,?>>>1086  return1087}1088 1089// -----1090 1091func.func @bad_pack_array4(%arg0: !fir.box<!fir.array<?xf32>>) {1092  // expected-error@+1{{op attribute 'max_size' failed to satisfy constraint: 64-bit unsigned integer attribute}}1093  %0 = fir.pack_array %arg0 stack whole constraints {max_size = -1 : i64} : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<?xf32>>1094  return1095}1096 1097// -----1098 1099func.func @bad_pack_array5(%arg0: !fir.box<!fir.array<?xf32>>) {1100  // expected-error@+1{{op attribute 'max_element_size' failed to satisfy constraint: 64-bit unsigned integer attribute}}1101  %0 = fir.pack_array %arg0 stack whole constraints {max_element_size = -1 : i64} : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<?xf32>>1102  return1103}1104 1105// -----1106 1107func.func @bad_pack_array6(%arg0: !fir.box<!fir.array<?xf32>>) {1108  // expected-error@+1{{op attribute 'min_stride' failed to satisfy constraint: 64-bit unsigned integer attribute}}1109  %0 = fir.pack_array %arg0 stack whole constraints {min_stride = -1 : i64} : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<?xf32>>1110  return1111}1112 1113// -----1114 1115func.func @bad_pack_array7(%arg0: !fir.box<!fir.array<?xf32>>) {1116  // expected-error@+1{{op 'innermost' is invalid for 1D arrays, use 'whole' instead}}1117  %0 = fir.pack_array %arg0 stack innermost : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<?xf32>>1118  return1119}1120 1121// -----1122 1123func.func @bad_unpack_array1(%arg0: !fir.ref<!fir.box<!fir.array<?xi32>>>, %arg1: !fir.ref<!fir.box<!fir.array<?xi32>>>) {1124  // expected-error@+1{{op operand #0 must be any boxed array, but got '!fir.ref<!fir.box<!fir.array<?xi32>>>'}}1125  fir.unpack_array %arg0 to %arg1 stack : !fir.ref<!fir.box<!fir.array<?xi32>>>1126  return1127}1128 1129// -----1130 1131func.func @bad_unpack_array2(%arg0: !fir.box<!fir.array<?xf32>>) {1132  %0 = fir.pack_array %arg0 stack whole : (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<?xf32>>1133  // expected-error@+1{{op the pack operation uses different memory for the temporary (stack vs heap)}}1134  fir.unpack_array %0 to %arg0 heap no_copy : !fir.box<!fir.array<?xf32>>1135  return1136}1137 1138// -----1139 1140func.func @bad_unpack_array3(%arg0: !fir.box<!fir.array<?xf32>>) {1141  %0 = fir.pack_array %arg0 heap whole no_copy: (!fir.box<!fir.array<?xf32>>) -> !fir.box<!fir.array<?xf32>>1142  // expected-error@+1{{op the pack operation uses different memory for the temporary (stack vs heap)}}1143  fir.unpack_array %0 to %arg0 stack : !fir.box<!fir.array<?xf32>>1144  return1145}1146 1147// -----1148 1149func.func @bad_unpack_array4(%arg0: !fir.box<!fir.array<?xf32>>, %arg1: !fir.box<!fir.array<?xi32>>) {1150  // expected-note@-1 {{prior use here}}1151  // expected-error@+1{{use of value '%arg0' expects different type than prior uses: '!fir.box<!fir.array<?xi32>>' vs '!fir.box<!fir.array<?xf32>>'}}1152  fir.unpack_array %arg0 to %arg1 stack : !fir.box<!fir.array<?xi32>>1153  return1154}1155 1156// -----1157 1158func.func @bad_is_contiguous_box(%arg0: !fir.ref<!fir.box<!fir.array<?xi32>>>) -> i1 {1159  // expected-error@+1{{op operand #0 must be any box, but got '!fir.ref<!fir.box<!fir.array<?xi32>>>'}}1160  %0 = fir.is_contiguous_box %arg0 whole : (!fir.ref<!fir.box<!fir.array<?xi32>>>) -> i11161  return %0 : i11162}1163 1164// -----1165 1166func.func @bad_box_total_elements(%arg0: !fir.ref<!fir.box<!fir.array<?xi32>>>) -> i32 {1167  // expected-error@+1{{op operand #0 must be any box, but got '!fir.ref<!fir.box<!fir.array<?xi32>>>'}}1168  %0 = fir.box_total_elements %arg0 : (!fir.ref<!fir.box<!fir.array<?xi32>>>) -> i321169  return %0 : i321170}1171 1172// -----1173 1174func.func @empty_dc_wrapper_body() {1175  // expected-error@+1 {{'fir.do_concurrent' op expects a non-empty block}}1176  fir.do_concurrent {1177  }1178  return1179}1180 1181// -----1182 1183func.func @dc_wrong_terminator() {1184  // expected-error@+1 {{'fir.do_concurrent' op must be terminated by 'fir.do_concurrent.loop'}}1185  fir.do_concurrent {1186    llvm.return1187  }1188  return1189}1190 1191// -----1192 1193func.func @dc_0d() {1194   // expected-error@+2 {{'fir.do_concurrent.loop' op needs at least one tuple element for lowerBound, upperBound and step}}1195  fir.do_concurrent {1196    fir.do_concurrent.loop () = () to () step () {1197      %tmp = fir.alloca i321198    }1199  }1200  return1201}1202 1203// -----1204 1205func.func @dc_invalid_parent(%arg0: index, %arg1: index) {1206  // expected-error@+1 {{'fir.do_concurrent.loop' op expects parent op 'fir.do_concurrent'}}1207  "fir.do_concurrent.loop"(%arg0, %arg1) <{operandSegmentSizes = array<i32: 1, 1, 0, 0, 0>}> ({1208  ^bb0(%arg2: index):1209     %tmp = "fir.alloca"() <{in_type = i32, operandSegmentSizes = array<i32: 0, 0>}> : () -> !fir.ref<i32>1210  }) : (index, index) -> ()1211  return1212}1213 1214// -----1215 1216func.func @dc_invalid_control(%arg0: index, %arg1: index) {1217  // expected-error@+2 {{'fir.do_concurrent.loop' op different number of tuple elements for lowerBound, upperBound or step}}1218  fir.do_concurrent {1219    "fir.do_concurrent.loop"(%arg0, %arg1) <{operandSegmentSizes = array<i32: 1, 1, 0, 0, 0>}> ({1220    ^bb0(%arg2: index):1221      %tmp = "fir.alloca"() <{in_type = i32, operandSegmentSizes = array<i32: 0, 0>}> : () -> !fir.ref<i32>1222    }) : (index, index) -> ()1223  }1224  return1225}1226 1227// -----1228 1229func.func @dc_invalid_ind_var(%arg0: index, %arg1: index) {1230  // expected-error@+2 {{'fir.do_concurrent.loop' op expects the same number of induction variables: 2 as bound and step values: 1}}1231  fir.do_concurrent {1232    "fir.do_concurrent.loop"(%arg0, %arg1, %arg0) <{operandSegmentSizes = array<i32: 1, 1, 1, 0, 0>}> ({1233    ^bb0(%arg3: index, %arg4: index):1234      %tmp = "fir.alloca"() <{in_type = i32, operandSegmentSizes = array<i32: 0, 0>}> : () -> !fir.ref<i32>1235    }) : (index, index, index) -> ()1236  }1237  return1238}1239 1240// -----1241 1242func.func @dc_invalid_ind_var_type(%arg0: index, %arg1: index) {1243  // expected-error@+2 {{'fir.do_concurrent.loop' op expects arguments for the induction variable to be of index type}}1244  fir.do_concurrent {1245    "fir.do_concurrent.loop"(%arg0, %arg1, %arg0) <{operandSegmentSizes = array<i32: 1, 1, 1, 0, 0>}> ({1246    ^bb0(%arg3: i32):1247      %tmp = "fir.alloca"() <{in_type = i32, operandSegmentSizes = array<i32: 0, 0>}> : () -> !fir.ref<i32>1248    }) : (index, index, index) -> ()1249  }1250  return1251}1252 1253// -----1254 1255func.func @dc_invalid_reduction(%arg0: index, %arg1: index) {1256  %sum = fir.alloca i321257  // expected-error@+2 {{'fir.do_concurrent.loop' op mismatch in number of reduction variables and reduction attributes}}1258  fir.do_concurrent {1259    "fir.do_concurrent.loop"(%arg0, %arg1, %arg0, %sum) <{operandSegmentSizes = array<i32: 1, 1, 1, 0, 1>}> ({1260    ^bb0(%arg3: index, %sum_arg: i32):1261      %tmp = "fir.alloca"() <{in_type = i32, operandSegmentSizes = array<i32: 0, 0>}> : () -> !fir.ref<i32>1262    }) : (index, index, index, !fir.ref<i32>) -> ()1263  }1264  return1265}1266 1267// -----1268 1269func.func @dc_reduce_no_attr() {1270  %3 = fir.alloca i32 {bindc_name = "s", uniq_name = "dc_reduce"}1271  %4:2 = hlfir.declare %3 {uniq_name = "dc_reduce"} : (!fir.ref<i32>) -> (!fir.ref<i32>, !fir.ref<i32>)1272  %c1 = arith.constant 1 : index 1273  // expected-error@+2 {{expected attribute value}}1274  fir.do_concurrent {1275    fir.do_concurrent.loop (%arg0) = (%c1) to (%c1) step (%c1) reduce(@add_reduction_i32 %4#0 -> %arg1 : !fir.ref<i32>) {1276    }1277  }1278  return1279}1280 1281// -----1282 1283// Should fail when volatility changes from a fir.convert1284func.func @bad_convert_volatile(%arg0: !fir.ref<i32>) -> !fir.ref<i32, volatile> {1285  // expected-error@+1 {{op this conversion does not preserve volatility}}1286  %0 = fir.convert %arg0 : (!fir.ref<i32>) -> !fir.ref<i32, volatile>1287  return %0 : !fir.ref<i32, volatile>1288}1289 1290// -----1291 1292// Should fail when volatility changes from a fir.convert1293func.func @bad_convert_volatile2(%arg0: !fir.ref<i32, volatile>) -> !fir.ref<i32> {1294  // expected-error@+1 {{op this conversion does not preserve volatility}}1295  %0 = fir.convert %arg0 : (!fir.ref<i32, volatile>) -> !fir.ref<i32>1296  return %0 : !fir.ref<i32>1297}1298 1299// -----1300 1301// Should fail when the element type and the containing type change1302func.func @bad_convert_volatile3(%arg0: !fir.ref<i32>) -> !fir.box<i64> {1303  // expected-error@+1 {{'fir.volatile_cast' op types must be identical except for volatility}}1304  %0 = fir.volatile_cast %arg0 : (!fir.ref<i32>) -> !fir.box<i64>1305  return %0 : !fir.box<i64>1306}1307 1308// -----1309 1310// Should fail when the containing type changes1311func.func @bad_convert_volatile4(%arg0: !fir.ref<i32>) -> !fir.box<i32> {1312  // expected-error@+1 {{'fir.volatile_cast' op types must be identical except for volatility}}1313  %0 = fir.volatile_cast %arg0 : (!fir.ref<i32>) -> !fir.box<i32>1314  return %0 : !fir.box<i32>1315}1316 1317// -----1318 1319// Should fail when the containing type changes1320func.func @bad_convert_volatile5(%arg0: !fir.ref<i32>) -> !fir.box<i32, volatile> {1321  // expected-error@+1 {{'fir.volatile_cast' op types must be identical except for volatility}}1322  %0 = fir.volatile_cast %arg0 : (!fir.ref<i32>) -> !fir.box<i32, volatile>1323  return %0 : !fir.box<i32, volatile>1324}1325 1326// -----1327 1328// Should fail when the element type changes1329func.func @bad_convert_volatile6(%arg0: !fir.ref<i32>) -> !fir.ref<i64> {1330  // expected-error@+1 {{'fir.volatile_cast' op types must be identical except for volatility}}1331  %0 = fir.volatile_cast %arg0 : (!fir.ref<i32>) -> !fir.ref<i64>1332  return %0 : !fir.ref<i64>1333}1334 1335// -----1336 1337fir.local {type = local} @x.localizer : i32 init {1338^bb0(%arg0: i32, %arg1: i32):1339  %0 = arith.constant 0.0 : f321340  // expected-error @below {{Invalid yielded value. Expected type: 'i32', got: 'f32'}}1341  fir.yield(%0 : f32)1342}1343 1344// -----1345 1346// expected-error @below {{Region argument type mismatch: got 'f32' expected 'i32'.}}1347fir.local {type = local} @x.localizer : i32 init {1348^bb0(%arg0: i32, %arg1: f32):1349  fir.yield1350}1351 1352// -----1353 1354fir.local {type = local} @x.localizer : f32 init {1355^bb0(%arg0: f32, %arg1: f32):1356  fir.yield(%arg0: f32)1357} dealloc {1358^bb0(%arg0: f32):1359  // expected-error @below {{Did not expect any values to be yielded.}}1360  fir.yield(%arg0 : f32)1361}1362 1363// -----1364 1365fir.local {type = local} @x.localizer : i32 init {1366^bb0(%arg0: i32, %arg1: i32):1367  // expected-error @below {{expected exit block terminator to be an `fir.yield` op.}}1368  fir.unreachable1369}1370 1371// -----1372 1373// expected-error @below {{`init`: expected 2 region arguments, got: 1}}1374fir.local {type = local} @x.localizer : f32 init {1375^bb0(%arg0: f32):1376  fir.yield(%arg0 : f32)1377}1378 1379// -----1380 1381// expected-error @below {{`copy`: expected 2 region arguments, got: 1}}1382fir.local {type = local_init} @x.privatizer : f32 copy {1383^bb0(%arg0: f32):1384  fir.yield(%arg0 : f32)1385}1386 1387// -----1388 1389// expected-error @below {{`dealloc`: expected 1 region arguments, got: 2}}1390fir.local {type = local} @x.localizer : f32 dealloc {1391^bb0(%arg0: f32, %arg1: f32):1392  fir.yield1393}1394 1395// -----1396 1397// expected-error @below {{`local` specifiers do not require a `copy` region.}}1398fir.local {type = local} @x.localizer : f32 copy {1399^bb0(%arg0: f32, %arg1 : f32):1400  fir.yield(%arg0 : f32)1401}1402 1403// -----1404 1405// expected-error @below {{`local_init` specifiers require at least a `copy` region.}}1406fir.local {type = local_init} @x.localizer : f32 init {1407^bb0(%arg0: f32, %arg1: f32):1408  fir.yield(%arg0 : f32)1409}1410 1411// -----1412 1413func.func @wrong_weights_number_in_if_then(%cond: i1) {1414// expected-error @below {{expects number of region weights to match number of regions: 1 vs 2}}1415  fir.if %cond weights([50]) {1416  }1417  return1418}1419 1420// -----1421 1422func.func @wrong_weights_number_in_if_then_else(%cond: i1) {1423// expected-error @below {{expects number of region weights to match number of regions: 3 vs 2}}1424  fir.if %cond weights([50, 40, 10]) {1425  } else {1426  }1427  return1428}1429 1430// -----1431 1432func.func @fir_declare_bad_storage_offset(%arg0: !fir.ref<!fir.array<8xi8>>) {1433  %c0 = arith.constant 0 : index1434  %addr = fir.address_of(@block_) : !fir.ref<!fir.array<8xi8>>1435  %2 = fir.convert %addr : (!fir.ref<!fir.array<8xi8>>) -> !fir.ref<!fir.array<?xi8>>1436  %var = fir.coordinate_of %2, %c0 : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>1437  // expected-error@+1 {{negative integer literal not valid for unsigned integer type}}1438  %decl = fir.declare %var storage (%addr[-1]) {uniq_name = "a"} : (!fir.ref<i8>, !fir.ref<!fir.array<8xi8>>) -> !fir.ref<i8>1439  return1440}1441 1442// -----1443 1444"func.func"() <{function_type = (!fir.ref<!fir.array<8xi8>>) -> (), sym_name = "fir_declare_bad_storage_offset"}> ({1445^bb0(%arg0: !fir.ref<!fir.array<8xi8>>):1446  %0 = "arith.constant"() <{value = 0 : index}> : () -> index1447  %1 = "fir.address_of"() <{symbol = @block_}> : () -> !fir.ref<!fir.array<8xi8>>1448  %2 = "fir.convert"(%1) : (!fir.ref<!fir.array<8xi8>>) -> !fir.ref<!fir.array<?xi8>>1449  %3 = "fir.coordinate_of"(%2, %0) <{baseType = !fir.ref<!fir.array<?xi8>>}> : (!fir.ref<!fir.array<?xi8>>, index) -> !fir.ref<i8>1450// expected-error@+1 {{storage offset specified without the storage reference}}1451  %4 = "fir.declare"(%3) <{operandSegmentSizes = array<i32: 1, 0, 0, 0, 0>, storage_offset = 1 : ui64, uniq_name = "a"}> : (!fir.ref<i8>) -> !fir.ref<i8>1452  "func.return"() : () -> ()1453}) : () -> ()1454 1455// -----1456 1457func.func @fir_declare_bad_storage(%arg0: !fir.ref<i8>) {1458  // expected-error@+1 {{storage must be a vector}}1459  %decl = fir.declare %arg0 storage (%arg0[0]) {uniq_name = "a"} : (!fir.ref<i8>, !fir.ref<i8>) -> !fir.ref<i8>1460  return1461}1462 1463// -----1464 1465func.func @fir_declare_bad_storage(%arg0: !fir.ref<i8>, %arg1: !fir.ref<!fir.array<?xi8>>) {1466  // expected-error@+1 {{storage must have known extent}}1467  %decl = fir.declare %arg0 storage (%arg1[0]) {uniq_name = "a"} : (!fir.ref<i8>, !fir.ref<!fir.array<?xi8>>) -> !fir.ref<i8>1468  return1469}1470 1471// -----1472 1473func.func @fir_declare_bad_storage(%arg0: !fir.ref<i8>, %arg1: !fir.ref<!fir.array<1xi32>>) {1474  // expected-error@+1 {{storage must be an array of i8 elements}}1475  %decl = fir.declare %arg0 storage (%arg1[0]) {uniq_name = "a"} : (!fir.ref<i8>, !fir.ref<!fir.array<1xi32>>) -> !fir.ref<i8>1476  return1477}1478 1479// -----1480 1481func.func @fir_declare_bad_storage_offset(%arg0: !fir.ref<i8>, %arg1: !fir.ref<!fir.array<1xi8>>) {1482  // expected-error@+1 {{storage offset exceeds the storage size}}1483  %decl = fir.declare %arg0 storage (%arg1[2]) {uniq_name = "a"} : (!fir.ref<i8>, !fir.ref<!fir.array<1xi8>>) -> !fir.ref<i8>1484  return1485}1486