mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 07:51:05 +01:00
The self access is important; for the test `generic_class.carbon` being added to `toolchain/check/testdata/class/destroy_calls.carbon`, it was using `%T.as.Destroy` instead of `%D.as.Destroy`, indicating the default blank impl was being used instead of the type-specific version. That test is trying to focus on the issue, but the delta is visible in a couple other files in this PR, for example `toolchain/check/testdata/class/generic/init.carbon`. I'm separately working on getting rid of the default impl, which is how I noticed this.
307 lines
19 KiB
Plaintext
307 lines
19 KiB
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
|
|
// TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
|
|
// EXTRA-ARGS: --dump-sem-ir-ranges=if-present
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/compound_field.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/compound_field.carbon
|
|
|
|
base class Base {
|
|
var a: i32;
|
|
var b: i32;
|
|
var c: i32;
|
|
}
|
|
|
|
class Derived {
|
|
extend base: Base;
|
|
|
|
var d: i32;
|
|
var e: i32;
|
|
}
|
|
|
|
fn AccessDerived(d: Derived) -> i32 {
|
|
return d.(Derived.d);
|
|
}
|
|
|
|
fn AccessBase(d: Derived) -> i32 {
|
|
return d.(Base.b);
|
|
}
|
|
|
|
fn AccessDerivedIndirect(p: Derived*) -> i32* {
|
|
return &p->(Derived.d);
|
|
}
|
|
|
|
fn AccessBaseIndirect(p: Derived*) -> i32* {
|
|
return &p->(Base.b);
|
|
}
|
|
|
|
// CHECK:STDOUT: --- compound_field.carbon
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: constants {
|
|
// CHECK:STDOUT: %Base: type = class_type @Base [concrete]
|
|
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
|
|
// CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
|
|
// CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
|
|
// CHECK:STDOUT: %Base.elem: type = unbound_element_type %Base, %i32 [concrete]
|
|
// CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
|
|
// CHECK:STDOUT: %pattern_type.f6d: type = pattern_type auto [concrete]
|
|
// CHECK:STDOUT: %Destroy.impl_witness.ae4: <witness> = impl_witness @Base.%Destroy.impl_witness_table [concrete]
|
|
// CHECK:STDOUT: %ptr.11f: type = ptr_type %Base [concrete]
|
|
// CHECK:STDOUT: %pattern_type.1b9: type = pattern_type %ptr.11f [concrete]
|
|
// CHECK:STDOUT: %Base.as.Destroy.impl.Op.type: type = fn_type @Base.as.Destroy.impl.Op [concrete]
|
|
// CHECK:STDOUT: %Base.as.Destroy.impl.Op: %Base.as.Destroy.impl.Op.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %struct_type.a.b.c: type = struct_type {.a: %i32, .b: %i32, .c: %i32} [concrete]
|
|
// CHECK:STDOUT: %complete_type.ebc: <witness> = complete_type_witness %struct_type.a.b.c [concrete]
|
|
// CHECK:STDOUT: %Derived: type = class_type @Derived [concrete]
|
|
// CHECK:STDOUT: %Derived.elem.69e: type = unbound_element_type %Derived, %Base [concrete]
|
|
// CHECK:STDOUT: %Derived.elem.344: type = unbound_element_type %Derived, %i32 [concrete]
|
|
// CHECK:STDOUT: %Destroy.impl_witness.e52: <witness> = impl_witness @Derived.%Destroy.impl_witness_table [concrete]
|
|
// CHECK:STDOUT: %ptr.404: type = ptr_type %Derived [concrete]
|
|
// CHECK:STDOUT: %pattern_type.605: type = pattern_type %ptr.404 [concrete]
|
|
// CHECK:STDOUT: %Derived.as.Destroy.impl.Op.type: type = fn_type @Derived.as.Destroy.impl.Op [concrete]
|
|
// CHECK:STDOUT: %Derived.as.Destroy.impl.Op: %Derived.as.Destroy.impl.Op.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %struct_type.base.d.e.6a7: type = struct_type {.base: %Base, .d: %i32, .e: %i32} [concrete]
|
|
// CHECK:STDOUT: %complete_type.401: <witness> = complete_type_witness %struct_type.base.d.e.6a7 [concrete]
|
|
// CHECK:STDOUT: %pattern_type.fb9: type = pattern_type %Derived [concrete]
|
|
// CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
|
|
// CHECK:STDOUT: %AccessDerived.type: type = fn_type @AccessDerived [concrete]
|
|
// CHECK:STDOUT: %AccessDerived: %AccessDerived.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %AccessBase.type: type = fn_type @AccessBase [concrete]
|
|
// CHECK:STDOUT: %AccessBase: %AccessBase.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %ptr.235: type = ptr_type %i32 [concrete]
|
|
// CHECK:STDOUT: %pattern_type.fe8: type = pattern_type %ptr.235 [concrete]
|
|
// CHECK:STDOUT: %AccessDerivedIndirect.type: type = fn_type @AccessDerivedIndirect [concrete]
|
|
// CHECK:STDOUT: %AccessDerivedIndirect: %AccessDerivedIndirect.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: %AccessBaseIndirect.type: type = fn_type @AccessBaseIndirect [concrete]
|
|
// CHECK:STDOUT: %AccessBaseIndirect: %AccessBaseIndirect.type = struct_value () [concrete]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: imports {
|
|
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
|
|
// CHECK:STDOUT: .Int = %Core.Int
|
|
// CHECK:STDOUT: .Destroy = %Core.Destroy
|
|
// CHECK:STDOUT: import Core//prelude
|
|
// CHECK:STDOUT: import Core//prelude/...
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
|
|
// CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: file {
|
|
// CHECK:STDOUT: package: <namespace> = namespace [concrete] {
|
|
// CHECK:STDOUT: .Core = imports.%Core
|
|
// CHECK:STDOUT: .Base = %Base.decl
|
|
// CHECK:STDOUT: .Derived = %Derived.decl
|
|
// CHECK:STDOUT: .AccessDerived = %AccessDerived.decl
|
|
// CHECK:STDOUT: .AccessBase = %AccessBase.decl
|
|
// CHECK:STDOUT: .AccessDerivedIndirect = %AccessDerivedIndirect.decl
|
|
// CHECK:STDOUT: .AccessBaseIndirect = %AccessBaseIndirect.decl
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %Core.import = import Core
|
|
// CHECK:STDOUT: %Base.decl: type = class_decl @Base [concrete = constants.%Base] {} {}
|
|
// CHECK:STDOUT: %Derived.decl: type = class_decl @Derived [concrete = constants.%Derived] {} {}
|
|
// CHECK:STDOUT: %AccessDerived.decl: %AccessDerived.type = fn_decl @AccessDerived [concrete = constants.%AccessDerived] {
|
|
// CHECK:STDOUT: %d.patt: %pattern_type.fb9 = binding_pattern d [concrete]
|
|
// CHECK:STDOUT: %d.param_patt: %pattern_type.fb9 = value_param_pattern %d.patt, call_param0 [concrete]
|
|
// CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
|
|
// CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
|
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
|
// CHECK:STDOUT: %d.param: %Derived = value_param call_param0
|
|
// CHECK:STDOUT: %Derived.ref.loc28: type = name_ref Derived, file.%Derived.decl [concrete = constants.%Derived]
|
|
// CHECK:STDOUT: %d: %Derived = bind_name d, %d.param
|
|
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
|
|
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %AccessBase.decl: %AccessBase.type = fn_decl @AccessBase [concrete = constants.%AccessBase] {
|
|
// CHECK:STDOUT: %d.patt: %pattern_type.fb9 = binding_pattern d [concrete]
|
|
// CHECK:STDOUT: %d.param_patt: %pattern_type.fb9 = value_param_pattern %d.patt, call_param0 [concrete]
|
|
// CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern [concrete]
|
|
// CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern %return.patt, call_param1 [concrete]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
|
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
|
// CHECK:STDOUT: %d.param: %Derived = value_param call_param0
|
|
// CHECK:STDOUT: %Derived.ref: type = name_ref Derived, file.%Derived.decl [concrete = constants.%Derived]
|
|
// CHECK:STDOUT: %d: %Derived = bind_name d, %d.param
|
|
// CHECK:STDOUT: %return.param: ref %i32 = out_param call_param1
|
|
// CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %AccessDerivedIndirect.decl: %AccessDerivedIndirect.type = fn_decl @AccessDerivedIndirect [concrete = constants.%AccessDerivedIndirect] {
|
|
// CHECK:STDOUT: %p.patt: %pattern_type.605 = binding_pattern p [concrete]
|
|
// CHECK:STDOUT: %p.param_patt: %pattern_type.605 = value_param_pattern %p.patt, call_param0 [concrete]
|
|
// CHECK:STDOUT: %return.patt: %pattern_type.fe8 = return_slot_pattern [concrete]
|
|
// CHECK:STDOUT: %return.param_patt: %pattern_type.fe8 = out_param_pattern %return.patt, call_param1 [concrete]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
|
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
|
// CHECK:STDOUT: %ptr.loc36_45: type = ptr_type %i32 [concrete = constants.%ptr.235]
|
|
// CHECK:STDOUT: %p.param: %ptr.404 = value_param call_param0
|
|
// CHECK:STDOUT: %.loc36: type = splice_block %ptr.loc36_36 [concrete = constants.%ptr.404] {
|
|
// CHECK:STDOUT: %Derived.ref.loc36: type = name_ref Derived, file.%Derived.decl [concrete = constants.%Derived]
|
|
// CHECK:STDOUT: %ptr.loc36_36: type = ptr_type %Derived.ref.loc36 [concrete = constants.%ptr.404]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %p: %ptr.404 = bind_name p, %p.param
|
|
// CHECK:STDOUT: %return.param: ref %ptr.235 = out_param call_param1
|
|
// CHECK:STDOUT: %return: ref %ptr.235 = return_slot %return.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %AccessBaseIndirect.decl: %AccessBaseIndirect.type = fn_decl @AccessBaseIndirect [concrete = constants.%AccessBaseIndirect] {
|
|
// CHECK:STDOUT: %p.patt: %pattern_type.605 = binding_pattern p [concrete]
|
|
// CHECK:STDOUT: %p.param_patt: %pattern_type.605 = value_param_pattern %p.patt, call_param0 [concrete]
|
|
// CHECK:STDOUT: %return.patt: %pattern_type.fe8 = return_slot_pattern [concrete]
|
|
// CHECK:STDOUT: %return.param_patt: %pattern_type.fe8 = out_param_pattern %return.patt, call_param1 [concrete]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
|
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
|
// CHECK:STDOUT: %ptr.loc40_42: type = ptr_type %i32 [concrete = constants.%ptr.235]
|
|
// CHECK:STDOUT: %p.param: %ptr.404 = value_param call_param0
|
|
// CHECK:STDOUT: %.loc40: type = splice_block %ptr.loc40_33 [concrete = constants.%ptr.404] {
|
|
// CHECK:STDOUT: %Derived.ref: type = name_ref Derived, file.%Derived.decl [concrete = constants.%Derived]
|
|
// CHECK:STDOUT: %ptr.loc40_33: type = ptr_type %Derived.ref [concrete = constants.%ptr.404]
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: %p: %ptr.404 = bind_name p, %p.param
|
|
// CHECK:STDOUT: %return.param: ref %ptr.235 = out_param call_param1
|
|
// CHECK:STDOUT: %return: ref %ptr.235 = return_slot %return.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: impl @Base.as.Destroy.impl: @Base.%Self.ref as constants.%Destroy.type {
|
|
// CHECK:STDOUT: %Base.as.Destroy.impl.Op.decl: %Base.as.Destroy.impl.Op.type = fn_decl @Base.as.Destroy.impl.Op [concrete = constants.%Base.as.Destroy.impl.Op] {
|
|
// CHECK:STDOUT: %self.patt: %pattern_type.1b9 = binding_pattern self [concrete]
|
|
// CHECK:STDOUT: %self.param_patt: %pattern_type.1b9 = value_param_pattern %self.patt, call_param0 [concrete]
|
|
// CHECK:STDOUT: %.loc15: %pattern_type.f6d = addr_pattern %self.param_patt [concrete]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %self.param: %ptr.11f = value_param call_param0
|
|
// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Base [concrete = constants.%Base]
|
|
// CHECK:STDOUT: %self: %ptr.11f = bind_name self, %self.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Op = %Base.as.Destroy.impl.Op.decl
|
|
// CHECK:STDOUT: witness = @Base.%Destroy.impl_witness
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: impl @Derived.as.Destroy.impl: @Derived.%Self.ref as constants.%Destroy.type {
|
|
// CHECK:STDOUT: %Derived.as.Destroy.impl.Op.decl: %Derived.as.Destroy.impl.Op.type = fn_decl @Derived.as.Destroy.impl.Op [concrete = constants.%Derived.as.Destroy.impl.Op] {
|
|
// CHECK:STDOUT: %self.patt: %pattern_type.605 = binding_pattern self [concrete]
|
|
// CHECK:STDOUT: %self.param_patt: %pattern_type.605 = value_param_pattern %self.patt, call_param0 [concrete]
|
|
// CHECK:STDOUT: %.loc21: %pattern_type.f6d = addr_pattern %self.param_patt [concrete]
|
|
// CHECK:STDOUT: } {
|
|
// CHECK:STDOUT: %self.param: %ptr.404 = value_param call_param0
|
|
// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Derived [concrete = constants.%Derived]
|
|
// CHECK:STDOUT: %self: %ptr.404 = bind_name self, %self.param
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Op = %Derived.as.Destroy.impl.Op.decl
|
|
// CHECK:STDOUT: witness = @Derived.%Destroy.impl_witness
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @Base {
|
|
// CHECK:STDOUT: %int_32.loc16: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
|
// CHECK:STDOUT: %i32.loc16: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
|
// CHECK:STDOUT: %.loc16: %Base.elem = field_decl a, element0 [concrete]
|
|
// CHECK:STDOUT: %int_32.loc17: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
|
// CHECK:STDOUT: %i32.loc17: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
|
// CHECK:STDOUT: %.loc17: %Base.elem = field_decl b, element1 [concrete]
|
|
// CHECK:STDOUT: %int_32.loc18: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
|
// CHECK:STDOUT: %i32.loc18: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
|
// CHECK:STDOUT: %.loc18: %Base.elem = field_decl c, element2 [concrete]
|
|
// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Base [concrete = constants.%Base]
|
|
// CHECK:STDOUT: impl_decl @Base.as.Destroy.impl [concrete] {} {}
|
|
// CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (@Base.as.Destroy.impl.%Base.as.Destroy.impl.Op.decl), @Base.as.Destroy.impl [concrete]
|
|
// CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness %Destroy.impl_witness_table [concrete = constants.%Destroy.impl_witness.ae4]
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.a.b.c [concrete = constants.%complete_type.ebc]
|
|
// CHECK:STDOUT: complete_type_witness = %complete_type
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%Base
|
|
// CHECK:STDOUT: .a = %.loc16
|
|
// CHECK:STDOUT: .b = %.loc17
|
|
// CHECK:STDOUT: .c = %.loc18
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: class @Derived {
|
|
// CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [concrete = constants.%Base]
|
|
// CHECK:STDOUT: %.loc22: %Derived.elem.69e = base_decl %Base.ref, element0 [concrete]
|
|
// CHECK:STDOUT: %int_32.loc24: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
|
// CHECK:STDOUT: %i32.loc24: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
|
// CHECK:STDOUT: %.loc24: %Derived.elem.344 = field_decl d, element1 [concrete]
|
|
// CHECK:STDOUT: %int_32.loc25: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
|
|
// CHECK:STDOUT: %i32.loc25: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
|
|
// CHECK:STDOUT: %.loc25: %Derived.elem.344 = field_decl e, element2 [concrete]
|
|
// CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%Derived [concrete = constants.%Derived]
|
|
// CHECK:STDOUT: impl_decl @Derived.as.Destroy.impl [concrete] {} {}
|
|
// CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (@Derived.as.Destroy.impl.%Derived.as.Destroy.impl.Op.decl), @Derived.as.Destroy.impl [concrete]
|
|
// CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness %Destroy.impl_witness_table [concrete = constants.%Destroy.impl_witness.e52]
|
|
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.base.d.e.6a7 [concrete = constants.%complete_type.401]
|
|
// CHECK:STDOUT: complete_type_witness = %complete_type
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: !members:
|
|
// CHECK:STDOUT: .Self = constants.%Derived
|
|
// CHECK:STDOUT: .Base = <poisoned>
|
|
// CHECK:STDOUT: .base = %.loc22
|
|
// CHECK:STDOUT: .d = %.loc24
|
|
// CHECK:STDOUT: .e = %.loc25
|
|
// CHECK:STDOUT: extend %Base.ref
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Base.as.Destroy.impl.Op(%self.param: %ptr.11f) = "no_op";
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @Derived.as.Destroy.impl.Op(%self.param: %ptr.404) = "no_op";
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @AccessDerived(%d.param: %Derived) -> %i32 {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %d.ref.loc29_10: %Derived = name_ref d, %d
|
|
// CHECK:STDOUT: %Derived.ref.loc29: type = name_ref Derived, file.%Derived.decl [concrete = constants.%Derived]
|
|
// CHECK:STDOUT: %d.ref.loc29_20: %Derived.elem.344 = name_ref d, @Derived.%.loc24 [concrete = @Derived.%.loc24]
|
|
// CHECK:STDOUT: %.loc29_11.1: ref %i32 = class_element_access %d.ref.loc29_10, element1
|
|
// CHECK:STDOUT: %.loc29_11.2: %i32 = bind_value %.loc29_11.1
|
|
// CHECK:STDOUT: return %.loc29_11.2
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @AccessBase(%d.param: %Derived) -> %i32 {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %d.ref: %Derived = name_ref d, %d
|
|
// CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [concrete = constants.%Base]
|
|
// CHECK:STDOUT: %b.ref: %Base.elem = name_ref b, @Base.%.loc17 [concrete = @Base.%.loc17]
|
|
// CHECK:STDOUT: %.loc33_11.1: ref %Base = class_element_access %d.ref, element0
|
|
// CHECK:STDOUT: %.loc33_11.2: ref %Base = converted %d.ref, %.loc33_11.1
|
|
// CHECK:STDOUT: %.loc33_11.3: ref %i32 = class_element_access %.loc33_11.2, element1
|
|
// CHECK:STDOUT: %.loc33_11.4: %i32 = bind_value %.loc33_11.3
|
|
// CHECK:STDOUT: return %.loc33_11.4
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @AccessDerivedIndirect(%p.param: %ptr.404) -> %ptr.235 {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %p.ref: %ptr.404 = name_ref p, %p
|
|
// CHECK:STDOUT: %Derived.ref.loc37: type = name_ref Derived, file.%Derived.decl [concrete = constants.%Derived]
|
|
// CHECK:STDOUT: %d.ref: %Derived.elem.344 = name_ref d, @Derived.%.loc24 [concrete = @Derived.%.loc24]
|
|
// CHECK:STDOUT: %.loc37_12.1: ref %Derived = deref %p.ref
|
|
// CHECK:STDOUT: %.loc37_12.2: ref %i32 = class_element_access %.loc37_12.1, element1
|
|
// CHECK:STDOUT: %addr: %ptr.235 = addr_of %.loc37_12.2
|
|
// CHECK:STDOUT: return %addr
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|
|
// CHECK:STDOUT: fn @AccessBaseIndirect(%p.param: %ptr.404) -> %ptr.235 {
|
|
// CHECK:STDOUT: !entry:
|
|
// CHECK:STDOUT: %p.ref: %ptr.404 = name_ref p, %p
|
|
// CHECK:STDOUT: %Base.ref: type = name_ref Base, file.%Base.decl [concrete = constants.%Base]
|
|
// CHECK:STDOUT: %b.ref: %Base.elem = name_ref b, @Base.%.loc17 [concrete = @Base.%.loc17]
|
|
// CHECK:STDOUT: %.loc41_12.1: ref %Derived = deref %p.ref
|
|
// CHECK:STDOUT: %.loc41_12.2: ref %Base = class_element_access %.loc41_12.1, element0
|
|
// CHECK:STDOUT: %.loc41_12.3: ref %Base = converted %.loc41_12.1, %.loc41_12.2
|
|
// CHECK:STDOUT: %.loc41_12.4: ref %i32 = class_element_access %.loc41_12.3, element1
|
|
// CHECK:STDOUT: %addr: %ptr.235 = addr_of %.loc41_12.4
|
|
// CHECK:STDOUT: return %addr
|
|
// CHECK:STDOUT: }
|
|
// CHECK:STDOUT:
|