// RUN: cir-opt %s -verify-diagnostics -split-input-file !u8i = !cir.int !u64i = !cir.int !rec_S = !cir.struct<"S" padded {!u8i}> module { cir.func dso_local @bad_static_array_ctor_with_num_elements(%p: !cir.ptr>, %n: !u64i) { // expected-error@+1 {{'cir.array.ctor' op when 'num_elements' is present, 'addr' must be a pointer to a !cir.struct or !cir.union type}} cir.array.ctor %p, %n : !cir.ptr>, !u64i { ^bb0(%e: !cir.ptr>): } cir.return } } // ----- !u8i = !cir.int !u64i = !cir.int !rec_S = !cir.struct<"S" padded {!u8i}> module { cir.func private @_ZN1SC1Ev(!cir.ptr) // Static form: addr must be a pointer to an array type. cir.func @bad_static_not_array_ctor(%p: !cir.ptr) { // expected-error@+1 {{'cir.array.ctor' op when 'num_elements' is absent, 'addr' must be a pointer to a !cir.array type}} cir.array.ctor %p : !cir.ptr { ^bb0(%e: !cir.ptr): cir.call @_ZN1SC1Ev(%e) : (!cir.ptr) -> () } cir.return } } // ----- !u8i = !cir.int !rec_S = !cir.struct<"S" padded {!u8i}> module { cir.func private @construct_int(!cir.ptr) // Static form: addr must be a pointer to an array type. cir.func @bad_static_array_not_record_ctor(%p: !cir.ptr>) { // expected-error@+1 {{'cir.array.ctor' op the block argument type must be a pointer to a !cir.struct or !cir.union type}} cir.array.ctor %p : !cir.ptr> { ^bb0(%e: !cir.ptr): cir.call @construct_int(%e) : (!cir.ptr) -> () } cir.return } } // ----- !u8i = !cir.int !u64i = !cir.int !rec_S = !cir.struct<"S" padded {!u8i}> !rec_T = !cir.struct<"T" padded {!u8i}> module { cir.func private @_ZN1SC1Ev(!cir.ptr) // Static form: block argument element type must match innermost array element. cir.func @bad_static_element_mismatch_ctor(%p: !cir.ptr>) { // expected-error@+1 {{'cir.array.ctor' op block argument pointee type must match the innermost array element type}} cir.array.ctor %p : !cir.ptr> { ^bb0(%e: !cir.ptr): } cir.return } } // ----- !u8i = !cir.int !u64i = !cir.int !rec_S = !cir.struct<"S" padded {!u8i}> !rec_T = !cir.struct<"T" padded {!u8i}> module { cir.func private @_ZN1SC1Ev(!cir.ptr) // Dynamic form: addr type must match block argument type. cir.func @bad_dynamic_type_mismatch_ctor(%p: !cir.ptr, %n: !u64i) { // expected-error@+1 {{'cir.array.ctor' op when 'num_elements' is present, 'addr' type must match the block argument type}} cir.array.ctor %p, %n : !cir.ptr, !u64i { ^bb0(%e: !cir.ptr): cir.call @_ZN1SC1Ev(%e) : (!cir.ptr) -> () } cir.return } } // ----- !u8i = !cir.int !u64i = !cir.int !rec_S = !cir.struct<"S" padded {!u8i}> module { cir.func dso_local @bad_static_array_dtor_with_num_elements(%p: !cir.ptr>, %n: !u64i) { // expected-error@+1 {{'cir.array.dtor' op when 'num_elements' is present, 'addr' must be a pointer to a !cir.struct or !cir.union type}} cir.array.dtor %p, %n : !cir.ptr>, !u64i { ^bb0(%e: !cir.ptr>): } cir.return } } // ----- !u8i = !cir.int !rec_S = !cir.struct<"S" padded {!u8i}> module { cir.func private @_ZN1SD1Ev(!cir.ptr) // Static form: addr must be a pointer to an array type. cir.func @bad_static_not_array_dtor(%p: !cir.ptr) { // expected-error@+1 {{'cir.array.dtor' op when 'num_elements' is absent, 'addr' must be a pointer to a !cir.array type}} cir.array.dtor %p : !cir.ptr { ^bb0(%e: !cir.ptr): } cir.return } } // ----- !u8i = !cir.int !rec_S = !cir.struct<"S" padded {!u8i}> module { cir.func private @destroy_int(!cir.ptr) // Static form: addr must be a pointer to an array type. cir.func @bad_static_array_not_record_dtor(%p: !cir.ptr>) { // expected-error@+1 {{'cir.array.dtor' op the block argument type must be a pointer to a !cir.struct or !cir.union type}} cir.array.dtor %p : !cir.ptr> { ^bb0(%e: !cir.ptr): cir.call @destroy_int(%e) : (!cir.ptr) -> () } cir.return } } // ----- !u8i = !cir.int !rec_S = !cir.struct<"S" padded {!u8i}> !rec_T = !cir.struct<"T" padded {!u8i}> module { cir.func private @_ZN1SD1Ev(!cir.ptr) // Static form: addr must be a pointer to an array type. cir.func @bad_static_dtor_not_array_ctor(%p: !cir.ptr>) { // expected-error@+1 {{'cir.array.dtor' op block argument pointee type must match the innermost array element type}} cir.array.dtor %p: !cir.ptr> { ^bb0(%e: !cir.ptr): } cir.return } } // ----- !u8i = !cir.int !u64i = !cir.int !rec_S = !cir.struct<"S" padded {!u8i}> !rec_T = !cir.struct<"T" padded {!u8i}> module { cir.func private @_ZN1SD1Ev(!cir.ptr) // Static form: block argument element type must match innermost array element. cir.func @bad_static_element_mismatch_dtor(%p: !cir.ptr>) { // expected-error@+1 {{'cir.array.dtor' op block argument pointee type must match the innermost array element type}} cir.array.dtor %p : !cir.ptr> { ^bb0(%e: !cir.ptr): } cir.return } } // ----- !u8i = !cir.int !u64i = !cir.int !rec_S = !cir.struct<"S" padded {!u8i}> !rec_T = !cir.struct<"T" padded {!u8i}> module { cir.func private @_ZN1SD1Ev(!cir.ptr) // Dynamic form: addr type must match block argument type. cir.func @bad_dynamic_type_mismatch_dtor(%p: !cir.ptr, %n: !u64i) { // expected-error@+1 {{'cir.array.dtor' op when 'num_elements' is present, 'addr' type must match the block argument type}} cir.array.dtor %p, %n : !cir.ptr, !u64i { ^bb0(%e: !cir.ptr): cir.call @_ZN1SD1Ev(%e) : (!cir.ptr) -> () } cir.return } }