// RUN: cir-opt %s -verify-diagnostics -split-input-file !u32i = !cir.int cir.func @reference_unknown_vtable() { // expected-error @below {{'cir.vtable.address_point' op 'some_vtable' does not reference a valid cir.global}} %0 = cir.vtable.address_point(@some_vtable, address_point = ) : !cir.vptr cir.return } // ----- !u8i = !cir.int !u32i = !cir.int cir.global linkonce_odr @_ZTT1D = #cir.const_array<[#cir.global_view<@_ZTV1D, [0 : i32, 3 : i32]> : !cir.ptr, #cir.global_view<@_ZTC1D0_1B, [0 : i32, 3 : i32]> : !cir.ptr]> : !cir.array x 2> cir.func @reference_non_vtable() { // expected-error @below {{Expected #cir.vtable in initializer for global '_ZTT1D'}} %0 = cir.vtable.address_point(@_ZTT1D, address_point = ) : !cir.vptr cir.return } // ----- !rec_S = !cir.struct<"S" {!cir.vptr}> !u8i = !cir.int !rec_anon_struct = !cir.struct<{!cir.array x 4>}> module { // expected-error @below {{expected !cir.struct or !cir.union type result}} cir.global external @_ZTV1S = #cir.vtable<{#cir.const_array<[#cir.ptr : !cir.ptr, #cir.ptr : !cir.ptr, #cir.global_view<@_ZN1S3keyEv> : !cir.ptr, #cir.global_view<@_ZN1S6nonKeyEv> : !cir.ptr]> : !cir.array x 4>}> : !cir.ptr cir.func private dso_local @_ZN1S3keyEv(%arg0: !cir.ptr) cir.func private dso_local @_ZN1S6nonKeyEv(%arg0: !cir.ptr) } // ----- !rec_S = !cir.struct<"S" {!cir.vptr}> !u8i = !cir.int !rec_anon_struct = !cir.struct<{}> module { // expected-error @below {{expected record type with one or more subtype}} cir.global external @_ZTV1S = #cir.vtable<{}> : !rec_anon_struct {alignment = 8 : i64} cir.func private dso_local @_ZN1S3keyEv(%arg0: !cir.ptr) cir.func private dso_local @_ZN1S6nonKeyEv(%arg0: !cir.ptr) } // ----- !rec_S = !cir.struct<"S" {!cir.vptr}> !u8i = !cir.int !rec_anon_struct = !cir.struct<{!cir.ptr}> module { // expected-error @below {{expected constant array subtype}} cir.global external @_ZTV1S = #cir.vtable<{#cir.ptr : !cir.ptr}> : !rec_anon_struct {alignment = 8 : i64} cir.func private dso_local @_ZN1S3keyEv(%arg0: !cir.ptr) cir.func private dso_local @_ZN1S6nonKeyEv(%arg0: !cir.ptr) } // ----- !rec_S = !cir.struct<"S" {!cir.vptr}> !u64i = !cir.int !rec_anon_struct = !cir.struct<{!cir.array}> module { // expected-error @below {{expected GlobalViewAttr or ConstPtrAttr}} cir.global external @_ZTV1S = #cir.vtable<{#cir.const_array<[#cir.int<1> : !u64i, #cir.int<1> : !u64i, #cir.int<3> : !u64i, #cir.int<4> : !u64i]> : !cir.array}> : !rec_anon_struct {alignment = 8 : i64} cir.func private dso_local @_ZN1S3keyEv(%arg0: !cir.ptr) cir.func private dso_local @_ZN1S6nonKeyEv(%arg0: !cir.ptr) } // ----- !rec_Q = !cir.struct<"Q" {!cir.vptr}> !rec_S = !cir.struct<"S" {!cir.vptr}> !rec_S2 = !cir.struct<"S2" {!rec_Q, !rec_S}> !u8i = !cir.int !rec_anon_struct = !cir.struct<{!cir.array x 4>, !cir.ptr}> module { // expected-error @below {{expected constant array subtype}} cir.global external @_ZTV2S2 = #cir.vtable<{#cir.const_array<[#cir.ptr : !cir.ptr, #cir.ptr : !cir.ptr, #cir.global_view<@_ZN1S3keyEv> : !cir.ptr, #cir.global_view<@_ZN1S6nonKeyEv> : !cir.ptr]> : !cir.array x 4>, #cir.ptr : !cir.ptr}> : !rec_anon_struct {alignment = 8 : i64} cir.func private dso_local @_ZN1S3keyEv(%arg0: !cir.ptr) cir.func private dso_local @_ZN1S6nonKeyEv(%arg0: !cir.ptr) cir.func private dso_local @_ZN2S23keyEv(%arg0: !cir.ptr) } // ----- !u32i = !cir.int !void = !cir.void cir.func @reference_unknown_vtt() { // expected-error @below {{'cir.vtt.address_point' op 'some_vtt' does not reference a valid cir.global}} %0 = cir.vtt.address_point @some_vtt, offset = 1 -> !cir.ptr> cir.return } // ----- !u8i = !cir.int !u32i = !cir.int !void = !cir.void !rec_anon_struct = !cir.struct<{!cir.array x 4>}> cir.global external @_ZTV1S = #cir.vtable<{#cir.const_array<[#cir.ptr : !cir.ptr, #cir.ptr : !cir.ptr, #cir.global_view<@_ZN1S3keyEv> : !cir.ptr, #cir.global_view<@_ZN1S6nonKeyEv> : !cir.ptr]> : !cir.array x 4>}> : !rec_anon_struct {alignment = 8 : i64} cir.func @reference_non_vtt() { // expected-error @below {{'cir.vtt.address_point' op Expected constant array in initializer for global VTT '_ZTV1S'}} %0 = cir.vtt.address_point @_ZTV1S, offset = 1 -> !cir.ptr> cir.return } // ----- !u8i = !cir.int !u32i = !cir.int !void = !cir.void !rec_anon_struct = !cir.struct<{!cir.array x 4>}> !rec_C = !cir.struct cir.global linkonce_odr @_ZTT1C = #cir.const_array<[#cir.global_view<@_ZTV1C, [0 : i32, 3 : i32]> : !cir.ptr, #cir.global_view<@_ZTC1C0_1B, [0 : i32, 3 : i32]> : !cir.ptr]> : !cir.array x 2> {alignment = 8 : i64} cir.func @reference_name_and_value(%arg0: !cir.ptr, %arg1: !cir.ptr>) { // expected-error @below {{'cir.vtt.address_point' op should use either a symbol or value, but not both}} %0 = cir.vtt.address_point @_ZTT1C %arg1 : !cir.ptr>, offset = 1 -> !cir.ptr> cir.return } // ----- !u8i = !cir.int !u32i = !cir.int !void = !cir.void !rec_anon_struct = !cir.struct<{!cir.array x 4>}> !rec_C = !cir.struct cir.global linkonce_odr @_ZTT1C = #cir.const_array<[#cir.global_view<@_ZTV1C, [0 : i32, 3 : i32]> : !cir.ptr, #cir.global_view<@_ZTC1C0_1B, [0 : i32, 3 : i32]> : !cir.ptr]> : !cir.array x 2> {alignment = 8 : i64} cir.func @bad_return_type_for_vtt_addrpoint() { // expected-error @below {{result type must be '!cir.ptr>', but provided result type is '!cir.ptr>'}} %0 = cir.vtt.address_point @_ZTT1C, offset = 1 -> !cir.ptr cir.return }