mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Support builtin conversions of adapter classes (#4655)
When creating a tuple or struct type object/value, we will walk each of the tuple's or struct's parts, respectively, and Convert() each of them. This allows (T, T) to convert to (U, U) and so forth. It also performs the conversion from value to initialization even for the same types, such as converting from a value of (T, T) to an object of (T, T). Classes need to define their own conversions but when the target and source types are the same, there is no conversion of types taking place. If the class adapts a tuple or struct then walk each of the tuple's or struct's parts, respectively, and Convert() each of them in order to initialize the parts of the target. For copyable types, the conversion implies a copy in the initialization, and for non-copyable types, an error is emitted. This supports copying a class value to a class object when it is an adapter of a tuple or struct. --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
co-authored by
Richard Smith
parent
72e594dfd0
commit
c59ceb1f7b
@@ -12,6 +12,7 @@
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "toolchain/base/kind_switch.h"
|
||||
#include "toolchain/check/context.h"
|
||||
#include "toolchain/check/diagnostic_helpers.h"
|
||||
#include "toolchain/check/operator.h"
|
||||
#include "toolchain/check/pattern_match.h"
|
||||
#include "toolchain/diagnostics/format_providers.h"
|
||||
@@ -722,7 +723,7 @@ static auto CanUseValueOfInitializer(const SemIR::File& sem_ir,
|
||||
}
|
||||
|
||||
// Returns the non-adapter type that is compatible with the specified type.
|
||||
static auto GetCompatibleBaseType(Context& context, SemIR::TypeId type_id)
|
||||
static auto GetTransitiveAdaptedType(Context& context, SemIR::TypeId type_id)
|
||||
-> SemIR::TypeId {
|
||||
// If the type is an adapter, its object representation type is its compatible
|
||||
// non-adapter type.
|
||||
@@ -792,14 +793,73 @@ static auto PerformBuiltinConversion(Context& context, SemIR::LocId loc_id,
|
||||
return context.AddInst<SemIR::ValueOfInitializer>(
|
||||
loc_id, {.type_id = value_type_id, .init_id = value_id});
|
||||
}
|
||||
|
||||
// PerformBuiltinConversion converts each part of a tuple or struct, even
|
||||
// when the types are the same. This is not done for classes since they have
|
||||
// to define their conversions as part of their api.
|
||||
//
|
||||
// If a class adapts a tuple or struct, we convert each of its parts when
|
||||
// there's no other conversion going on (the source and target types are the
|
||||
// same). To do so, we have to insert a conversion of the value up to the
|
||||
// foundation and back down, and a conversion of the initializing object if
|
||||
// there is one.
|
||||
//
|
||||
// Implementation note: We do the conversion through a call to
|
||||
// PerformBuiltinConversion() call rather than a Convert() call to avoid
|
||||
// extraneous `converted` semir instructions on the adapted types, and as a
|
||||
// shortcut to doing the explicit calls to walk the parts of the
|
||||
// tuple/struct which happens inside PerformBuiltinConversion().
|
||||
if (auto foundation_type_id =
|
||||
GetTransitiveAdaptedType(context, value_type_id);
|
||||
foundation_type_id != value_type_id &&
|
||||
(context.types().Is<SemIR::TupleType>(foundation_type_id) ||
|
||||
context.types().Is<SemIR::StructType>(foundation_type_id))) {
|
||||
auto foundation_value_id = context.AddInst<SemIR::AsCompatible>(
|
||||
loc_id, {.type_id = foundation_type_id, .source_id = value_id});
|
||||
|
||||
auto foundation_init_id = target.init_id;
|
||||
if (foundation_init_id != SemIR::InstId::Invalid) {
|
||||
foundation_init_id = target.init_block->AddInst<SemIR::AsCompatible>(
|
||||
loc_id,
|
||||
{.type_id = foundation_type_id, .source_id = target.init_id});
|
||||
}
|
||||
|
||||
{
|
||||
// While the types are the same, the conversion can still fail if it
|
||||
// performs a copy while converting the value to another category, and
|
||||
// the type (or some part of it) is not copyable.
|
||||
DiagnosticAnnotationScope annotate_diagnostics(
|
||||
&context.emitter(), [&](auto& builder) {
|
||||
CARBON_DIAGNOSTIC(InCopy, Note, "in copy of {0}", TypeOfInstId);
|
||||
builder.Note(value_id, InCopy, value_id);
|
||||
});
|
||||
|
||||
foundation_value_id =
|
||||
PerformBuiltinConversion(context, loc_id, foundation_value_id,
|
||||
{
|
||||
.kind = target.kind,
|
||||
.type_id = foundation_type_id,
|
||||
.init_id = foundation_init_id,
|
||||
.init_block = target.init_block,
|
||||
});
|
||||
if (foundation_value_id == SemIR::ErrorInst::SingletonInstId) {
|
||||
return SemIR::ErrorInst::SingletonInstId;
|
||||
}
|
||||
}
|
||||
|
||||
return context.AddInst<SemIR::AsCompatible>(
|
||||
loc_id,
|
||||
{.type_id = target.type_id, .source_id = foundation_value_id});
|
||||
}
|
||||
}
|
||||
|
||||
// T explicitly converts to U if T is compatible with U.
|
||||
if (target.kind == ConversionTarget::Kind::ExplicitAs &&
|
||||
target.type_id != value_type_id) {
|
||||
auto target_base_id = GetCompatibleBaseType(context, target.type_id);
|
||||
auto value_base_id = GetCompatibleBaseType(context, value_type_id);
|
||||
if (target_base_id == value_base_id) {
|
||||
auto target_foundation_id =
|
||||
GetTransitiveAdaptedType(context, target.type_id);
|
||||
auto value_foundation_id = GetTransitiveAdaptedType(context, value_type_id);
|
||||
if (target_foundation_id == value_foundation_id) {
|
||||
// For a struct or tuple literal, perform a category conversion if
|
||||
// necessary.
|
||||
if (SemIR::GetExprCategory(context.sem_ir(), value_id) ==
|
||||
|
||||
+360
-56
@@ -56,7 +56,7 @@ class D { adapt C; }
|
||||
|
||||
let d: D = {} as D;
|
||||
|
||||
// --- fail_init_class.carbon
|
||||
// --- init_class_value.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
@@ -71,17 +71,74 @@ class B {
|
||||
|
||||
let b_value: B = ({.x = 1, .y = 2} as A) as B;
|
||||
|
||||
// --- fail_init_class_variable.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
class A {
|
||||
var x: i32;
|
||||
var y: i32;
|
||||
}
|
||||
|
||||
class B {
|
||||
adapt A;
|
||||
}
|
||||
|
||||
// TODO: Here, we treat `{.x = 1, .y = 2} as A` as a value expression, not an
|
||||
// initializing expression, so `(...) as B` is a value expression too, requiring
|
||||
// a copy to perform initialization. It's not clear whether that is the right
|
||||
// behavior.
|
||||
|
||||
// CHECK:STDERR: fail_init_class.carbon:[[@LINE+4]]:17: error: cannot copy value of type `B` [CopyOfUncopyableType]
|
||||
// CHECK:STDERR: fail_init_class_variable.carbon:[[@LINE+4]]:17: error: cannot copy value of type `B` [CopyOfUncopyableType]
|
||||
// CHECK:STDERR: var b_init: B = ({.x = 1, .y = 2} as A) as B;
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
var b_init: B = ({.x = 1, .y = 2} as A) as B;
|
||||
|
||||
// --- init_tuple_value.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
class Noncopyable {
|
||||
// TODO: Ensure this remains non-copyable once we have rules for class copyability.
|
||||
}
|
||||
|
||||
class A {
|
||||
adapt (i32, Noncopyable);
|
||||
}
|
||||
|
||||
fn F(a: A) {
|
||||
let a_value: A = (a as (i32, Noncopyable)) as A;
|
||||
}
|
||||
|
||||
// --- fail_init_tuple_variable.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
class Noncopyable {
|
||||
// TODO: Ensure this remains non-copyable once we have rules for class copyability.
|
||||
}
|
||||
|
||||
class A {
|
||||
adapt (i32, Noncopyable);
|
||||
}
|
||||
|
||||
fn F(a: A) {
|
||||
// TODO: Here, we treat `a as (i32, Noncopyable)` as a value expression, not an
|
||||
// initializing expression, so `(...) as A` is a value expression too, requiring
|
||||
// a copy to perform initialization. It's not clear whether that is the right
|
||||
// behavior.
|
||||
|
||||
// CHECK:STDERR: fail_init_tuple_variable.carbon:[[@LINE+7]]:3: error: cannot copy value of type `Noncopyable` [CopyOfUncopyableType]
|
||||
// CHECK:STDERR: var a_init: A = (a as (i32, Noncopyable)) as A;
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_init_tuple_variable.carbon:[[@LINE+4]]:19: note: in copy of `A` [InCopy]
|
||||
// CHECK:STDERR: var a_init: A = (a as (i32, Noncopyable)) as A;
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR:
|
||||
var a_init: A = (a as (i32, Noncopyable)) as A;
|
||||
}
|
||||
|
||||
// --- fail_adapt_init_from_struct.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
@@ -425,7 +482,7 @@ var b: B = {.x = 1} as B;
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- fail_init_class.carbon
|
||||
// CHECK:STDOUT: --- init_class_value.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %A: type = class_type @A [template]
|
||||
@@ -466,6 +523,106 @@ var b: B = {.x = 1} as B;
|
||||
// CHECK:STDOUT: .A = %A.decl
|
||||
// CHECK:STDOUT: .B = %B.decl
|
||||
// CHECK:STDOUT: .b_value = @__global_init.%b_value
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
// CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {}
|
||||
// CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} {}
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @A {
|
||||
// CHECK:STDOUT: %.loc5: %A.elem = field_decl x, element0 [template]
|
||||
// CHECK:STDOUT: %.loc6: %A.elem = field_decl y, element1 [template]
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x.y.1 [template = constants.%complete_type.3]
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
// CHECK:STDOUT: .Self = constants.%A
|
||||
// CHECK:STDOUT: .x = %.loc5
|
||||
// CHECK:STDOUT: .y = %.loc6
|
||||
// CHECK:STDOUT: complete_type_witness = %complete_type
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @B {
|
||||
// CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A]
|
||||
// CHECK:STDOUT: adapt_decl %A.ref [template]
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x.y.1 [template = constants.%complete_type.3]
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
// CHECK:STDOUT: .Self = constants.%B
|
||||
// CHECK:STDOUT: complete_type_witness = %complete_type
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @__global_init() {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.1]
|
||||
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.1]
|
||||
// CHECK:STDOUT: %.loc13_34.1: %struct_type.x.y.2 = struct_literal (%int_1, %int_2)
|
||||
// CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A]
|
||||
// CHECK:STDOUT: %impl.elem0.loc13_34.1: %Convert.type.2 = impl_witness_access constants.%impl_witness.19, element0 [template = constants.%Convert.10]
|
||||
// CHECK:STDOUT: %Convert.bound.loc13_34.1: <bound method> = bound_method %int_1, %impl.elem0.loc13_34.1 [template = constants.%Convert.bound.1]
|
||||
// CHECK:STDOUT: %Convert.specific_fn.loc13_34.1: <specific function> = specific_function %Convert.bound.loc13_34.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.1]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc13_34.1: init %i32 = call %Convert.specific_fn.loc13_34.1(%int_1) [template = constants.%int_1.2]
|
||||
// CHECK:STDOUT: %.loc13_34.2: init %i32 = converted %int_1, %int.convert_checked.loc13_34.1 [template = constants.%int_1.2]
|
||||
// CHECK:STDOUT: %.loc13_34.3: ref %A = temporary_storage
|
||||
// CHECK:STDOUT: %.loc13_34.4: ref %i32 = class_element_access %.loc13_34.3, element0
|
||||
// CHECK:STDOUT: %.loc13_34.5: init %i32 = initialize_from %.loc13_34.2 to %.loc13_34.4 [template = constants.%int_1.2]
|
||||
// CHECK:STDOUT: %impl.elem0.loc13_34.2: %Convert.type.2 = impl_witness_access constants.%impl_witness.19, element0 [template = constants.%Convert.10]
|
||||
// CHECK:STDOUT: %Convert.bound.loc13_34.2: <bound method> = bound_method %int_2, %impl.elem0.loc13_34.2 [template = constants.%Convert.bound.2]
|
||||
// CHECK:STDOUT: %Convert.specific_fn.loc13_34.2: <specific function> = specific_function %Convert.bound.loc13_34.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.2]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc13_34.2: init %i32 = call %Convert.specific_fn.loc13_34.2(%int_2) [template = constants.%int_2.2]
|
||||
// CHECK:STDOUT: %.loc13_34.6: init %i32 = converted %int_2, %int.convert_checked.loc13_34.2 [template = constants.%int_2.2]
|
||||
// CHECK:STDOUT: %.loc13_34.7: ref %i32 = class_element_access %.loc13_34.3, element1
|
||||
// CHECK:STDOUT: %.loc13_34.8: init %i32 = initialize_from %.loc13_34.6 to %.loc13_34.7 [template = constants.%int_2.2]
|
||||
// CHECK:STDOUT: %.loc13_34.9: init %A = class_init (%.loc13_34.5, %.loc13_34.8), %.loc13_34.3 [template = constants.%A.val]
|
||||
// CHECK:STDOUT: %.loc13_34.10: ref %A = temporary %.loc13_34.3, %.loc13_34.9
|
||||
// CHECK:STDOUT: %.loc13_36: ref %A = converted %.loc13_34.1, %.loc13_34.10
|
||||
// CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [template = constants.%B]
|
||||
// CHECK:STDOUT: %.loc13_42.1: ref %B = as_compatible %.loc13_36
|
||||
// CHECK:STDOUT: %.loc13_42.2: ref %B = converted %.loc13_36, %.loc13_42.1
|
||||
// CHECK:STDOUT: %.loc13_42.3: %B = bind_value %.loc13_42.2
|
||||
// CHECK:STDOUT: %b_value: %B = bind_name b_value, %.loc13_42.3
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- fail_init_class_variable.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %A: type = class_type @A [template]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
|
||||
// CHECK:STDOUT: %A.elem: type = unbound_element_type %A, %i32 [template]
|
||||
// CHECK:STDOUT: %struct_type.x.y.1: type = struct_type {.x: %i32, .y: %i32} [template]
|
||||
// CHECK:STDOUT: %complete_type.3: <witness> = complete_type_witness %struct_type.x.y.1 [template]
|
||||
// CHECK:STDOUT: %B: type = class_type @B [template]
|
||||
// CHECK:STDOUT: %int_1.1: Core.IntLiteral = int_value 1 [template]
|
||||
// CHECK:STDOUT: %int_2.1: Core.IntLiteral = int_value 2 [template]
|
||||
// CHECK:STDOUT: %struct_type.x.y.2: type = struct_type {.x: Core.IntLiteral, .y: Core.IntLiteral} [template]
|
||||
// CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
|
||||
// CHECK:STDOUT: %impl_witness.19: <witness> = impl_witness (imports.%import_ref.14), @impl.1(%int_32) [template]
|
||||
// CHECK:STDOUT: %Convert.type.10: type = fn_type @Convert.2, @impl.1(%int_32) [template]
|
||||
// CHECK:STDOUT: %Convert.10: %Convert.type.10 = struct_value () [template]
|
||||
// CHECK:STDOUT: %Convert.bound.1: <bound method> = bound_method %int_1.1, %Convert.10 [template]
|
||||
// CHECK:STDOUT: %Convert.specific_fn.1: <specific function> = specific_function %Convert.bound.1, @Convert.2(%int_32) [template]
|
||||
// CHECK:STDOUT: %int_1.2: %i32 = int_value 1 [template]
|
||||
// CHECK:STDOUT: %Convert.bound.2: <bound method> = bound_method %int_2.1, %Convert.10 [template]
|
||||
// CHECK:STDOUT: %Convert.specific_fn.2: <specific function> = specific_function %Convert.bound.2, @Convert.2(%int_32) [template]
|
||||
// CHECK:STDOUT: %int_2.2: %i32 = int_value 2 [template]
|
||||
// CHECK:STDOUT: %A.val: %A = struct_value (%int_1.2, %int_2.2) [template]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
|
||||
// CHECK:STDOUT: .Int = %import_ref.1
|
||||
// CHECK:STDOUT: .ImplicitAs = %import_ref.5
|
||||
// CHECK:STDOUT: import Core//prelude
|
||||
// CHECK:STDOUT: import Core//prelude/...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = imports.%Core
|
||||
// CHECK:STDOUT: .A = %A.decl
|
||||
// CHECK:STDOUT: .B = %B.decl
|
||||
// CHECK:STDOUT: .b_init = %b_init
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
@@ -499,63 +656,210 @@ var b: B = {.x = 1} as B;
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @__global_init() {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %int_1.loc13: Core.IntLiteral = int_value 1 [template = constants.%int_1.1]
|
||||
// CHECK:STDOUT: %int_2.loc13: Core.IntLiteral = int_value 2 [template = constants.%int_2.1]
|
||||
// CHECK:STDOUT: %.loc13_34.1: %struct_type.x.y.2 = struct_literal (%int_1.loc13, %int_2.loc13)
|
||||
// CHECK:STDOUT: %A.ref.loc13: type = name_ref A, file.%A.decl [template = constants.%A]
|
||||
// CHECK:STDOUT: %impl.elem0.loc13_34.1: %Convert.type.2 = impl_witness_access constants.%impl_witness.19, element0 [template = constants.%Convert.10]
|
||||
// CHECK:STDOUT: %Convert.bound.loc13_34.1: <bound method> = bound_method %int_1.loc13, %impl.elem0.loc13_34.1 [template = constants.%Convert.bound.1]
|
||||
// CHECK:STDOUT: %Convert.specific_fn.loc13_34.1: <specific function> = specific_function %Convert.bound.loc13_34.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.1]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc13_34.1: init %i32 = call %Convert.specific_fn.loc13_34.1(%int_1.loc13) [template = constants.%int_1.2]
|
||||
// CHECK:STDOUT: %.loc13_34.2: init %i32 = converted %int_1.loc13, %int.convert_checked.loc13_34.1 [template = constants.%int_1.2]
|
||||
// CHECK:STDOUT: %.loc13_34.3: ref %A = temporary_storage
|
||||
// CHECK:STDOUT: %.loc13_34.4: ref %i32 = class_element_access %.loc13_34.3, element0
|
||||
// CHECK:STDOUT: %.loc13_34.5: init %i32 = initialize_from %.loc13_34.2 to %.loc13_34.4 [template = constants.%int_1.2]
|
||||
// CHECK:STDOUT: %impl.elem0.loc13_34.2: %Convert.type.2 = impl_witness_access constants.%impl_witness.19, element0 [template = constants.%Convert.10]
|
||||
// CHECK:STDOUT: %Convert.bound.loc13_34.2: <bound method> = bound_method %int_2.loc13, %impl.elem0.loc13_34.2 [template = constants.%Convert.bound.2]
|
||||
// CHECK:STDOUT: %Convert.specific_fn.loc13_34.2: <specific function> = specific_function %Convert.bound.loc13_34.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.2]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc13_34.2: init %i32 = call %Convert.specific_fn.loc13_34.2(%int_2.loc13) [template = constants.%int_2.2]
|
||||
// CHECK:STDOUT: %.loc13_34.6: init %i32 = converted %int_2.loc13, %int.convert_checked.loc13_34.2 [template = constants.%int_2.2]
|
||||
// CHECK:STDOUT: %.loc13_34.7: ref %i32 = class_element_access %.loc13_34.3, element1
|
||||
// CHECK:STDOUT: %.loc13_34.8: init %i32 = initialize_from %.loc13_34.6 to %.loc13_34.7 [template = constants.%int_2.2]
|
||||
// CHECK:STDOUT: %.loc13_34.9: init %A = class_init (%.loc13_34.5, %.loc13_34.8), %.loc13_34.3 [template = constants.%A.val]
|
||||
// CHECK:STDOUT: %.loc13_34.10: ref %A = temporary %.loc13_34.3, %.loc13_34.9
|
||||
// CHECK:STDOUT: %.loc13_36: ref %A = converted %.loc13_34.1, %.loc13_34.10
|
||||
// CHECK:STDOUT: %B.ref.loc13: type = name_ref B, file.%B.decl [template = constants.%B]
|
||||
// CHECK:STDOUT: %.loc13_42.1: ref %B = as_compatible %.loc13_36
|
||||
// CHECK:STDOUT: %.loc13_42.2: ref %B = converted %.loc13_36, %.loc13_42.1
|
||||
// CHECK:STDOUT: %.loc13_42.3: %B = bind_value %.loc13_42.2
|
||||
// CHECK:STDOUT: %b_value: %B = bind_name b_value, %.loc13_42.3
|
||||
// CHECK:STDOUT: %int_1.loc24: Core.IntLiteral = int_value 1 [template = constants.%int_1.1]
|
||||
// CHECK:STDOUT: %int_2.loc24: Core.IntLiteral = int_value 2 [template = constants.%int_2.1]
|
||||
// CHECK:STDOUT: %.loc24_33.1: %struct_type.x.y.2 = struct_literal (%int_1.loc24, %int_2.loc24)
|
||||
// CHECK:STDOUT: %A.ref.loc24: type = name_ref A, file.%A.decl [template = constants.%A]
|
||||
// CHECK:STDOUT: %impl.elem0.loc24_33.1: %Convert.type.2 = impl_witness_access constants.%impl_witness.19, element0 [template = constants.%Convert.10]
|
||||
// CHECK:STDOUT: %Convert.bound.loc24_33.1: <bound method> = bound_method %int_1.loc24, %impl.elem0.loc24_33.1 [template = constants.%Convert.bound.1]
|
||||
// CHECK:STDOUT: %Convert.specific_fn.loc24_33.1: <specific function> = specific_function %Convert.bound.loc24_33.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.1]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc24_33.1: init %i32 = call %Convert.specific_fn.loc24_33.1(%int_1.loc24) [template = constants.%int_1.2]
|
||||
// CHECK:STDOUT: %.loc24_33.2: init %i32 = converted %int_1.loc24, %int.convert_checked.loc24_33.1 [template = constants.%int_1.2]
|
||||
// CHECK:STDOUT: %.loc24_33.3: ref %A = temporary_storage
|
||||
// CHECK:STDOUT: %.loc24_33.4: ref %i32 = class_element_access %.loc24_33.3, element0
|
||||
// CHECK:STDOUT: %.loc24_33.5: init %i32 = initialize_from %.loc24_33.2 to %.loc24_33.4 [template = constants.%int_1.2]
|
||||
// CHECK:STDOUT: %impl.elem0.loc24_33.2: %Convert.type.2 = impl_witness_access constants.%impl_witness.19, element0 [template = constants.%Convert.10]
|
||||
// CHECK:STDOUT: %Convert.bound.loc24_33.2: <bound method> = bound_method %int_2.loc24, %impl.elem0.loc24_33.2 [template = constants.%Convert.bound.2]
|
||||
// CHECK:STDOUT: %Convert.specific_fn.loc24_33.2: <specific function> = specific_function %Convert.bound.loc24_33.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.2]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc24_33.2: init %i32 = call %Convert.specific_fn.loc24_33.2(%int_2.loc24) [template = constants.%int_2.2]
|
||||
// CHECK:STDOUT: %.loc24_33.6: init %i32 = converted %int_2.loc24, %int.convert_checked.loc24_33.2 [template = constants.%int_2.2]
|
||||
// CHECK:STDOUT: %.loc24_33.7: ref %i32 = class_element_access %.loc24_33.3, element1
|
||||
// CHECK:STDOUT: %.loc24_33.8: init %i32 = initialize_from %.loc24_33.6 to %.loc24_33.7 [template = constants.%int_2.2]
|
||||
// CHECK:STDOUT: %.loc24_33.9: init %A = class_init (%.loc24_33.5, %.loc24_33.8), %.loc24_33.3 [template = constants.%A.val]
|
||||
// CHECK:STDOUT: %.loc24_33.10: ref %A = temporary %.loc24_33.3, %.loc24_33.9
|
||||
// CHECK:STDOUT: %.loc24_35: ref %A = converted %.loc24_33.1, %.loc24_33.10
|
||||
// CHECK:STDOUT: %B.ref.loc24: type = name_ref B, file.%B.decl [template = constants.%B]
|
||||
// CHECK:STDOUT: %.loc24_41.1: ref %B = as_compatible %.loc24_35
|
||||
// CHECK:STDOUT: %.loc24_41.2: ref %B = converted %.loc24_35, %.loc24_41.1
|
||||
// CHECK:STDOUT: %.loc24_41.3: %B = bind_value %.loc24_41.2
|
||||
// CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [template = constants.%int_1.1]
|
||||
// CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [template = constants.%int_2.1]
|
||||
// CHECK:STDOUT: %.loc22_33.1: %struct_type.x.y.2 = struct_literal (%int_1, %int_2)
|
||||
// CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A]
|
||||
// CHECK:STDOUT: %impl.elem0.loc22_33.1: %Convert.type.2 = impl_witness_access constants.%impl_witness.19, element0 [template = constants.%Convert.10]
|
||||
// CHECK:STDOUT: %Convert.bound.loc22_33.1: <bound method> = bound_method %int_1, %impl.elem0.loc22_33.1 [template = constants.%Convert.bound.1]
|
||||
// CHECK:STDOUT: %Convert.specific_fn.loc22_33.1: <specific function> = specific_function %Convert.bound.loc22_33.1, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.1]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc22_33.1: init %i32 = call %Convert.specific_fn.loc22_33.1(%int_1) [template = constants.%int_1.2]
|
||||
// CHECK:STDOUT: %.loc22_33.2: init %i32 = converted %int_1, %int.convert_checked.loc22_33.1 [template = constants.%int_1.2]
|
||||
// CHECK:STDOUT: %.loc22_33.3: ref %A = temporary_storage
|
||||
// CHECK:STDOUT: %.loc22_33.4: ref %i32 = class_element_access %.loc22_33.3, element0
|
||||
// CHECK:STDOUT: %.loc22_33.5: init %i32 = initialize_from %.loc22_33.2 to %.loc22_33.4 [template = constants.%int_1.2]
|
||||
// CHECK:STDOUT: %impl.elem0.loc22_33.2: %Convert.type.2 = impl_witness_access constants.%impl_witness.19, element0 [template = constants.%Convert.10]
|
||||
// CHECK:STDOUT: %Convert.bound.loc22_33.2: <bound method> = bound_method %int_2, %impl.elem0.loc22_33.2 [template = constants.%Convert.bound.2]
|
||||
// CHECK:STDOUT: %Convert.specific_fn.loc22_33.2: <specific function> = specific_function %Convert.bound.loc22_33.2, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn.2]
|
||||
// CHECK:STDOUT: %int.convert_checked.loc22_33.2: init %i32 = call %Convert.specific_fn.loc22_33.2(%int_2) [template = constants.%int_2.2]
|
||||
// CHECK:STDOUT: %.loc22_33.6: init %i32 = converted %int_2, %int.convert_checked.loc22_33.2 [template = constants.%int_2.2]
|
||||
// CHECK:STDOUT: %.loc22_33.7: ref %i32 = class_element_access %.loc22_33.3, element1
|
||||
// CHECK:STDOUT: %.loc22_33.8: init %i32 = initialize_from %.loc22_33.6 to %.loc22_33.7 [template = constants.%int_2.2]
|
||||
// CHECK:STDOUT: %.loc22_33.9: init %A = class_init (%.loc22_33.5, %.loc22_33.8), %.loc22_33.3 [template = constants.%A.val]
|
||||
// CHECK:STDOUT: %.loc22_33.10: ref %A = temporary %.loc22_33.3, %.loc22_33.9
|
||||
// CHECK:STDOUT: %.loc22_35: ref %A = converted %.loc22_33.1, %.loc22_33.10
|
||||
// CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [template = constants.%B]
|
||||
// CHECK:STDOUT: %.loc22_41.1: ref %B = as_compatible %.loc22_35
|
||||
// CHECK:STDOUT: %.loc22_41.2: ref %B = converted %.loc22_35, %.loc22_41.1
|
||||
// CHECK:STDOUT: %.loc22_41.3: %B = bind_value %.loc22_41.2
|
||||
// CHECK:STDOUT: assign file.%b_init.var, <error>
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- init_tuple_value.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %Noncopyable: type = class_type @Noncopyable [template]
|
||||
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
|
||||
// CHECK:STDOUT: %complete_type.1: <witness> = complete_type_witness %empty_struct_type [template]
|
||||
// CHECK:STDOUT: %A: type = class_type @A [template]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
|
||||
// CHECK:STDOUT: %tuple.type.1: type = tuple_type (type, type) [template]
|
||||
// CHECK:STDOUT: %tuple.type.2: type = tuple_type (%i32, %Noncopyable) [template]
|
||||
// CHECK:STDOUT: %complete_type.4: <witness> = complete_type_witness %tuple.type.2 [template]
|
||||
// CHECK:STDOUT: %F.type: type = fn_type @F [template]
|
||||
// CHECK:STDOUT: %F: %F.type = struct_value () [template]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
|
||||
// CHECK:STDOUT: .Int = %import_ref.1
|
||||
// CHECK:STDOUT: import Core//prelude
|
||||
// CHECK:STDOUT: import Core//prelude/...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = imports.%Core
|
||||
// CHECK:STDOUT: .Noncopyable = %Noncopyable.decl
|
||||
// CHECK:STDOUT: .A = %A.decl
|
||||
// CHECK:STDOUT: .F = %F.decl
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
// CHECK:STDOUT: %Noncopyable.decl: type = class_decl @Noncopyable [template = constants.%Noncopyable] {} {}
|
||||
// CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {}
|
||||
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
|
||||
// CHECK:STDOUT: %a.patt: %A = binding_pattern a
|
||||
// CHECK:STDOUT: %a.param_patt: %A = value_param_pattern %a.patt, runtime_param0
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %a.param: %A = value_param runtime_param0
|
||||
// CHECK:STDOUT: %A.ref.loc12: type = name_ref A, file.%A.decl [template = constants.%A]
|
||||
// CHECK:STDOUT: %a: %A = bind_name a, %a.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @Noncopyable {
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.1]
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
// CHECK:STDOUT: .Self = constants.%Noncopyable
|
||||
// CHECK:STDOUT: complete_type_witness = %complete_type
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @A {
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
|
||||
// CHECK:STDOUT: %Noncopyable.ref: type = name_ref Noncopyable, file.%Noncopyable.decl [template = constants.%Noncopyable]
|
||||
// CHECK:STDOUT: %.loc9_26: %tuple.type.1 = tuple_literal (%i32, %Noncopyable.ref)
|
||||
// CHECK:STDOUT: %.loc9_27: type = converted %.loc9_26, constants.%tuple.type.2 [template = constants.%tuple.type.2]
|
||||
// CHECK:STDOUT: adapt_decl %.loc9_27 [template]
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %tuple.type.2 [template = constants.%complete_type.4]
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
// CHECK:STDOUT: .Self = constants.%A
|
||||
// CHECK:STDOUT: complete_type_witness = %complete_type
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @F(%a.param_patt: %A) {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %a.ref: %A = name_ref a, %a
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
|
||||
// CHECK:STDOUT: %Noncopyable.ref: type = name_ref Noncopyable, file.%Noncopyable.decl [template = constants.%Noncopyable]
|
||||
// CHECK:STDOUT: %.loc13_43.1: %tuple.type.1 = tuple_literal (%i32, %Noncopyable.ref)
|
||||
// CHECK:STDOUT: %.loc13_43.2: type = converted %.loc13_43.1, constants.%tuple.type.2 [template = constants.%tuple.type.2]
|
||||
// CHECK:STDOUT: %.loc13_23.1: %tuple.type.2 = as_compatible %a.ref
|
||||
// CHECK:STDOUT: %.loc13_23.2: %tuple.type.2 = converted %a.ref, %.loc13_23.1
|
||||
// CHECK:STDOUT: %A.ref.loc13: type = name_ref A, file.%A.decl [template = constants.%A]
|
||||
// CHECK:STDOUT: %.loc13_46.1: %A = as_compatible %.loc13_23.2
|
||||
// CHECK:STDOUT: %.loc13_46.2: %A = converted %.loc13_23.2, %.loc13_46.1
|
||||
// CHECK:STDOUT: %a_value: %A = bind_name a_value, %.loc13_46.2
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- fail_init_tuple_variable.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %Noncopyable: type = class_type @Noncopyable [template]
|
||||
// CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
|
||||
// CHECK:STDOUT: %complete_type.1: <witness> = complete_type_witness %empty_struct_type [template]
|
||||
// CHECK:STDOUT: %A: type = class_type @A [template]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
|
||||
// CHECK:STDOUT: %tuple.type.1: type = tuple_type (type, type) [template]
|
||||
// CHECK:STDOUT: %tuple.type.2: type = tuple_type (%i32, %Noncopyable) [template]
|
||||
// CHECK:STDOUT: %complete_type.4: <witness> = complete_type_witness %tuple.type.2 [template]
|
||||
// CHECK:STDOUT: %F.type: type = fn_type @F [template]
|
||||
// CHECK:STDOUT: %F: %F.type = struct_value () [template]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
|
||||
// CHECK:STDOUT: .Int = %import_ref.1
|
||||
// CHECK:STDOUT: import Core//prelude
|
||||
// CHECK:STDOUT: import Core//prelude/...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = imports.%Core
|
||||
// CHECK:STDOUT: .Noncopyable = %Noncopyable.decl
|
||||
// CHECK:STDOUT: .A = %A.decl
|
||||
// CHECK:STDOUT: .F = %F.decl
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
// CHECK:STDOUT: %Noncopyable.decl: type = class_decl @Noncopyable [template = constants.%Noncopyable] {} {}
|
||||
// CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {}
|
||||
// CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
|
||||
// CHECK:STDOUT: %a.patt: %A = binding_pattern a
|
||||
// CHECK:STDOUT: %a.param_patt: %A = value_param_pattern %a.patt, runtime_param0
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %a.param: %A = value_param runtime_param0
|
||||
// CHECK:STDOUT: %A.ref.loc12: type = name_ref A, file.%A.decl [template = constants.%A]
|
||||
// CHECK:STDOUT: %a: %A = bind_name a, %a.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @Noncopyable {
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type.1]
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
// CHECK:STDOUT: .Self = constants.%Noncopyable
|
||||
// CHECK:STDOUT: complete_type_witness = %complete_type
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @A {
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
|
||||
// CHECK:STDOUT: %Noncopyable.ref: type = name_ref Noncopyable, file.%Noncopyable.decl [template = constants.%Noncopyable]
|
||||
// CHECK:STDOUT: %.loc9_26: %tuple.type.1 = tuple_literal (%i32, %Noncopyable.ref)
|
||||
// CHECK:STDOUT: %.loc9_27: type = converted %.loc9_26, constants.%tuple.type.2 [template = constants.%tuple.type.2]
|
||||
// CHECK:STDOUT: adapt_decl %.loc9_27 [template]
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %tuple.type.2 [template = constants.%complete_type.4]
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
// CHECK:STDOUT: .Self = constants.%A
|
||||
// CHECK:STDOUT: complete_type_witness = %complete_type
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @F(%a.param_patt: %A) {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %a_init.var: ref %A = var a_init
|
||||
// CHECK:STDOUT: %a_init: ref %A = bind_name a_init, %a_init.var
|
||||
// CHECK:STDOUT: %a.ref: %A = name_ref a, %a
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
|
||||
// CHECK:STDOUT: %Noncopyable.ref: type = name_ref Noncopyable, file.%Noncopyable.decl [template = constants.%Noncopyable]
|
||||
// CHECK:STDOUT: %.loc25_42.1: %tuple.type.1 = tuple_literal (%i32, %Noncopyable.ref)
|
||||
// CHECK:STDOUT: %.loc25_42.2: type = converted %.loc25_42.1, constants.%tuple.type.2 [template = constants.%tuple.type.2]
|
||||
// CHECK:STDOUT: %.loc25_22.1: %tuple.type.2 = as_compatible %a.ref
|
||||
// CHECK:STDOUT: %.loc25_22.2: %tuple.type.2 = converted %a.ref, %.loc25_22.1
|
||||
// CHECK:STDOUT: %A.ref.loc25: type = name_ref A, file.%A.decl [template = constants.%A]
|
||||
// CHECK:STDOUT: %.loc25_45.1: %A = as_compatible %.loc25_22.2
|
||||
// CHECK:STDOUT: %.loc25_45.2: %A = converted %.loc25_22.2, %.loc25_45.1
|
||||
// CHECK:STDOUT: %.loc25_49.1: %tuple.type.2 = as_compatible %.loc25_45.2
|
||||
// CHECK:STDOUT: %tuple.elem0.loc25_49.1: %i32 = tuple_access %.loc25_49.1, element0
|
||||
// CHECK:STDOUT: %.loc25_49.2: ref %tuple.type.2 = as_compatible %a_init.var
|
||||
// CHECK:STDOUT: %tuple.elem0.loc25_49.2: ref %i32 = tuple_access %.loc25_49.2, element0
|
||||
// CHECK:STDOUT: %.loc25_49.3: init %i32 = initialize_from %tuple.elem0.loc25_49.1 to %tuple.elem0.loc25_49.2
|
||||
// CHECK:STDOUT: %tuple.elem1: %Noncopyable = tuple_access %.loc25_49.1, element1
|
||||
// CHECK:STDOUT: assign %a_init.var, <error>
|
||||
// CHECK:STDOUT: return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- fail_adapt_init_from_struct.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
|
||||
+339
-34
@@ -23,12 +23,12 @@ fn F(c: AdaptCopyable) -> AdaptCopyable {
|
||||
return d;
|
||||
}
|
||||
|
||||
fn InTuple(c: (AdaptCopyable, i32)) -> (AdaptCopyable, i32) {
|
||||
var d: (AdaptCopyable, i32) = c;
|
||||
fn InTuple(c: (AdaptCopyable, u32)) -> (AdaptCopyable, u32) {
|
||||
var d: (AdaptCopyable, u32) = c;
|
||||
return d;
|
||||
}
|
||||
|
||||
// --- fail_todo_adapt_copyable_tuple.carbon
|
||||
// --- adapt_copyable_tuple.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
@@ -36,18 +36,13 @@ class AdaptTuple {
|
||||
adapt (i32, i32);
|
||||
}
|
||||
|
||||
// TODO: Support copying in this case too, by performing the corresponding copy
|
||||
// operation for the adapted type.
|
||||
fn F(c: AdaptTuple) -> AdaptTuple {
|
||||
// CHECK:STDERR: fail_todo_adapt_copyable_tuple.carbon:[[@LINE+4]]:23: error: cannot copy value of type `AdaptTuple` [CopyOfUncopyableType]
|
||||
// CHECK:STDERR: var d: AdaptTuple = c;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
var d: AdaptTuple = c;
|
||||
// CHECK:STDERR: fail_todo_adapt_copyable_tuple.carbon:[[@LINE+4]]:10: error: cannot copy value of type `AdaptTuple` [CopyOfUncopyableType]
|
||||
// CHECK:STDERR: return d;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
return d;
|
||||
}
|
||||
|
||||
fn InTuple(c: (AdaptTuple, u32)) -> (AdaptTuple, u32) {
|
||||
var d: (AdaptTuple, u32) = c;
|
||||
return d;
|
||||
}
|
||||
|
||||
@@ -89,17 +84,41 @@ class AdaptNoncopyableIndirect {
|
||||
}
|
||||
|
||||
fn H(a: AdaptNoncopyableIndirect) -> AdaptNoncopyableIndirect {
|
||||
// CHECK:STDERR: fail_adapt_not_copyable_indirect.carbon:[[@LINE+4]]:37: error: cannot copy value of type `AdaptNoncopyableIndirect` [CopyOfUncopyableType]
|
||||
// CHECK:STDERR: fail_adapt_not_copyable_indirect.carbon:[[@LINE+7]]:3: error: cannot copy value of type `Noncopyable` [CopyOfUncopyableType]
|
||||
// CHECK:STDERR: var b: AdaptNoncopyableIndirect = a;
|
||||
// CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// CHECK:STDERR: fail_adapt_not_copyable_indirect.carbon:[[@LINE+4]]:37: note: in copy of `AdaptNoncopyableIndirect` [InCopy]
|
||||
// CHECK:STDERR: var b: AdaptNoncopyableIndirect = a;
|
||||
// CHECK:STDERR: ^
|
||||
// CHECK:STDERR:
|
||||
var b: AdaptNoncopyableIndirect = a;
|
||||
// CHECK:STDERR: fail_adapt_not_copyable_indirect.carbon:[[@LINE+3]]:10: error: cannot copy value of type `AdaptNoncopyableIndirect` [CopyOfUncopyableType]
|
||||
// CHECK:STDERR: fail_adapt_not_copyable_indirect.carbon:[[@LINE+6]]:3: error: cannot copy value of type `Noncopyable` [CopyOfUncopyableType]
|
||||
// CHECK:STDERR: return b;
|
||||
// CHECK:STDERR: ^~~~~~~~~
|
||||
// CHECK:STDERR: fail_adapt_not_copyable_indirect.carbon:[[@LINE+3]]:10: note: in copy of `AdaptNoncopyableIndirect` [InCopy]
|
||||
// CHECK:STDERR: return b;
|
||||
// CHECK:STDERR: ^
|
||||
return b;
|
||||
}
|
||||
|
||||
// --- adapt_copyable_struct.carbon
|
||||
|
||||
library "[[@TEST_NAME]]";
|
||||
|
||||
class AdaptStruct {
|
||||
adapt {.e: i32, .f: i32};
|
||||
}
|
||||
|
||||
fn I(g: AdaptStruct) -> AdaptStruct {
|
||||
var h: AdaptStruct = g;
|
||||
return h;
|
||||
}
|
||||
|
||||
fn InTuple(c: (AdaptStruct, u32)) -> (AdaptStruct, u32) {
|
||||
var d: (AdaptStruct, u32) = c;
|
||||
return d;
|
||||
}
|
||||
|
||||
// CHECK:STDOUT: --- adapt_copyable.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
@@ -110,8 +129,9 @@ fn H(a: AdaptNoncopyableIndirect) -> AdaptNoncopyableIndirect {
|
||||
// CHECK:STDOUT: %complete_type.2: <witness> = complete_type_witness %i32.builtin [template]
|
||||
// CHECK:STDOUT: %F.type: type = fn_type @F [template]
|
||||
// CHECK:STDOUT: %F: %F.type = struct_value () [template]
|
||||
// CHECK:STDOUT: %u32: type = class_type @UInt, @UInt(%int_32) [template]
|
||||
// CHECK:STDOUT: %tuple.type.1: type = tuple_type (type, type) [template]
|
||||
// CHECK:STDOUT: %tuple.type.2: type = tuple_type (%AdaptCopyable, %i32) [template]
|
||||
// CHECK:STDOUT: %tuple.type.2: type = tuple_type (%AdaptCopyable, %u32) [template]
|
||||
// CHECK:STDOUT: %InTuple.type: type = fn_type @InTuple [template]
|
||||
// CHECK:STDOUT: %InTuple: %InTuple.type = struct_value () [template]
|
||||
// CHECK:STDOUT: }
|
||||
@@ -119,6 +139,7 @@ fn H(a: AdaptNoncopyableIndirect) -> AdaptNoncopyableIndirect {
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
|
||||
// CHECK:STDOUT: .Int = %import_ref.1
|
||||
// CHECK:STDOUT: .UInt = %import_ref.5
|
||||
// CHECK:STDOUT: import Core//prelude
|
||||
// CHECK:STDOUT: import Core//prelude/...
|
||||
// CHECK:STDOUT: }
|
||||
@@ -154,15 +175,15 @@ fn H(a: AdaptNoncopyableIndirect) -> AdaptNoncopyableIndirect {
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %AdaptCopyable.ref.loc15_41: type = name_ref AdaptCopyable, file.%AdaptCopyable.decl [template = constants.%AdaptCopyable]
|
||||
// CHECK:STDOUT: %int_32.loc15_56: Core.IntLiteral = int_value 32 [template = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc15_56: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
|
||||
// CHECK:STDOUT: %.loc15_59.1: %tuple.type.1 = tuple_literal (%AdaptCopyable.ref.loc15_41, %i32.loc15_56)
|
||||
// CHECK:STDOUT: %u32.loc15_56: type = class_type @UInt, @UInt(constants.%int_32) [template = constants.%u32]
|
||||
// CHECK:STDOUT: %.loc15_59.1: %tuple.type.1 = tuple_literal (%AdaptCopyable.ref.loc15_41, %u32.loc15_56)
|
||||
// CHECK:STDOUT: %.loc15_59.2: type = converted %.loc15_59.1, constants.%tuple.type.2 [template = constants.%tuple.type.2]
|
||||
// CHECK:STDOUT: %c.param: %tuple.type.2 = value_param runtime_param0
|
||||
// CHECK:STDOUT: %.loc15_34.1: type = splice_block %.loc15_34.3 [template = constants.%tuple.type.2] {
|
||||
// CHECK:STDOUT: %AdaptCopyable.ref.loc15_16: type = name_ref AdaptCopyable, file.%AdaptCopyable.decl [template = constants.%AdaptCopyable]
|
||||
// CHECK:STDOUT: %int_32.loc15_31: Core.IntLiteral = int_value 32 [template = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc15_31: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
|
||||
// CHECK:STDOUT: %.loc15_34.2: %tuple.type.1 = tuple_literal (%AdaptCopyable.ref.loc15_16, %i32.loc15_31)
|
||||
// CHECK:STDOUT: %u32.loc15_31: type = class_type @UInt, @UInt(constants.%int_32) [template = constants.%u32]
|
||||
// CHECK:STDOUT: %.loc15_34.2: %tuple.type.1 = tuple_literal (%AdaptCopyable.ref.loc15_16, %u32.loc15_31)
|
||||
// CHECK:STDOUT: %.loc15_34.3: type = converted %.loc15_34.2, constants.%tuple.type.2 [template = constants.%tuple.type.2]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %c: %tuple.type.2 = bind_name c, %c.param
|
||||
@@ -201,9 +222,9 @@ fn H(a: AdaptNoncopyableIndirect) -> AdaptNoncopyableIndirect {
|
||||
// CHECK:STDOUT: %tuple.elem0.loc16_33.1: %AdaptCopyable = tuple_access %c.ref, element0
|
||||
// CHECK:STDOUT: %tuple.elem0.loc16_33.2: ref %AdaptCopyable = tuple_access %d.var, element0
|
||||
// CHECK:STDOUT: %.loc16_33.1: init %AdaptCopyable = initialize_from %tuple.elem0.loc16_33.1 to %tuple.elem0.loc16_33.2
|
||||
// CHECK:STDOUT: %tuple.elem1.loc16_33.1: %i32 = tuple_access %c.ref, element1
|
||||
// CHECK:STDOUT: %tuple.elem1.loc16_33.2: ref %i32 = tuple_access %d.var, element1
|
||||
// CHECK:STDOUT: %.loc16_33.2: init %i32 = initialize_from %tuple.elem1.loc16_33.1 to %tuple.elem1.loc16_33.2
|
||||
// CHECK:STDOUT: %tuple.elem1.loc16_33.1: %u32 = tuple_access %c.ref, element1
|
||||
// CHECK:STDOUT: %tuple.elem1.loc16_33.2: ref %u32 = tuple_access %d.var, element1
|
||||
// CHECK:STDOUT: %.loc16_33.2: init %u32 = initialize_from %tuple.elem1.loc16_33.1 to %tuple.elem1.loc16_33.2
|
||||
// CHECK:STDOUT: %.loc16_33.3: init %tuple.type.2 = tuple_init (%.loc16_33.1, %.loc16_33.2) to %d.var
|
||||
// CHECK:STDOUT: %.loc16_34: init %tuple.type.2 = converted %c.ref, %.loc16_33.3
|
||||
// CHECK:STDOUT: assign %d.var, %.loc16_34
|
||||
@@ -212,16 +233,16 @@ fn H(a: AdaptNoncopyableIndirect) -> AdaptNoncopyableIndirect {
|
||||
// CHECK:STDOUT: %.loc17_10.1: %AdaptCopyable = bind_value %tuple.elem0.loc17_10.1
|
||||
// CHECK:STDOUT: %tuple.elem0.loc17_10.2: ref %AdaptCopyable = tuple_access %return, element0
|
||||
// CHECK:STDOUT: %.loc17_10.2: init %AdaptCopyable = initialize_from %.loc17_10.1 to %tuple.elem0.loc17_10.2
|
||||
// CHECK:STDOUT: %tuple.elem1.loc17_10.1: ref %i32 = tuple_access %d.ref, element1
|
||||
// CHECK:STDOUT: %.loc17_10.3: %i32 = bind_value %tuple.elem1.loc17_10.1
|
||||
// CHECK:STDOUT: %tuple.elem1.loc17_10.2: ref %i32 = tuple_access %return, element1
|
||||
// CHECK:STDOUT: %.loc17_10.4: init %i32 = initialize_from %.loc17_10.3 to %tuple.elem1.loc17_10.2
|
||||
// CHECK:STDOUT: %tuple.elem1.loc17_10.1: ref %u32 = tuple_access %d.ref, element1
|
||||
// CHECK:STDOUT: %.loc17_10.3: %u32 = bind_value %tuple.elem1.loc17_10.1
|
||||
// CHECK:STDOUT: %tuple.elem1.loc17_10.2: ref %u32 = tuple_access %return, element1
|
||||
// CHECK:STDOUT: %.loc17_10.4: init %u32 = initialize_from %.loc17_10.3 to %tuple.elem1.loc17_10.2
|
||||
// CHECK:STDOUT: %.loc17_10.5: init %tuple.type.2 = tuple_init (%.loc17_10.2, %.loc17_10.4) to %return
|
||||
// CHECK:STDOUT: %.loc17_11: init %tuple.type.2 = converted %d.ref, %.loc17_10.5
|
||||
// CHECK:STDOUT: return %.loc17_11 to %return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- fail_todo_adapt_copyable_tuple.carbon
|
||||
// CHECK:STDOUT: --- adapt_copyable_tuple.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %AdaptTuple: type = class_type @AdaptTuple [template]
|
||||
@@ -232,11 +253,16 @@ fn H(a: AdaptNoncopyableIndirect) -> AdaptNoncopyableIndirect {
|
||||
// CHECK:STDOUT: %complete_type.3: <witness> = complete_type_witness %tuple.type.2 [template]
|
||||
// CHECK:STDOUT: %F.type: type = fn_type @F [template]
|
||||
// CHECK:STDOUT: %F: %F.type = struct_value () [template]
|
||||
// CHECK:STDOUT: %u32: type = class_type @UInt, @UInt(%int_32) [template]
|
||||
// CHECK:STDOUT: %tuple.type.3: type = tuple_type (%AdaptTuple, %u32) [template]
|
||||
// CHECK:STDOUT: %InTuple.type: type = fn_type @InTuple [template]
|
||||
// CHECK:STDOUT: %InTuple: %InTuple.type = struct_value () [template]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
|
||||
// CHECK:STDOUT: .Int = %import_ref.1
|
||||
// CHECK:STDOUT: .UInt = %import_ref.5
|
||||
// CHECK:STDOUT: import Core//prelude
|
||||
// CHECK:STDOUT: import Core//prelude/...
|
||||
// CHECK:STDOUT: }
|
||||
@@ -247,6 +273,7 @@ fn H(a: AdaptNoncopyableIndirect) -> AdaptNoncopyableIndirect {
|
||||
// CHECK:STDOUT: .Core = imports.%Core
|
||||
// CHECK:STDOUT: .AdaptTuple = %AdaptTuple.decl
|
||||
// CHECK:STDOUT: .F = %F.decl
|
||||
// CHECK:STDOUT: .InTuple = %InTuple.decl
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
// CHECK:STDOUT: %AdaptTuple.decl: type = class_decl @AdaptTuple [template = constants.%AdaptTuple] {} {}
|
||||
@@ -256,13 +283,36 @@ fn H(a: AdaptNoncopyableIndirect) -> AdaptNoncopyableIndirect {
|
||||
// CHECK:STDOUT: %return.patt: %AdaptTuple = return_slot_pattern
|
||||
// CHECK:STDOUT: %return.param_patt: %AdaptTuple = out_param_pattern %return.patt, runtime_param1
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %AdaptTuple.ref.loc10_24: type = name_ref AdaptTuple, file.%AdaptTuple.decl [template = constants.%AdaptTuple]
|
||||
// CHECK:STDOUT: %AdaptTuple.ref.loc8_24: type = name_ref AdaptTuple, file.%AdaptTuple.decl [template = constants.%AdaptTuple]
|
||||
// CHECK:STDOUT: %c.param: %AdaptTuple = value_param runtime_param0
|
||||
// CHECK:STDOUT: %AdaptTuple.ref.loc10_9: type = name_ref AdaptTuple, file.%AdaptTuple.decl [template = constants.%AdaptTuple]
|
||||
// CHECK:STDOUT: %AdaptTuple.ref.loc8_9: type = name_ref AdaptTuple, file.%AdaptTuple.decl [template = constants.%AdaptTuple]
|
||||
// CHECK:STDOUT: %c: %AdaptTuple = bind_name c, %c.param
|
||||
// CHECK:STDOUT: %return.param: ref %AdaptTuple = out_param runtime_param1
|
||||
// CHECK:STDOUT: %return: ref %AdaptTuple = return_slot %return.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %InTuple.decl: %InTuple.type = fn_decl @InTuple [template = constants.%InTuple] {
|
||||
// CHECK:STDOUT: %c.patt: %tuple.type.3 = binding_pattern c
|
||||
// CHECK:STDOUT: %c.param_patt: %tuple.type.3 = value_param_pattern %c.patt, runtime_param0
|
||||
// CHECK:STDOUT: %return.patt: %tuple.type.3 = return_slot_pattern
|
||||
// CHECK:STDOUT: %return.param_patt: %tuple.type.3 = out_param_pattern %return.patt, runtime_param1
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %AdaptTuple.ref.loc13_38: type = name_ref AdaptTuple, file.%AdaptTuple.decl [template = constants.%AdaptTuple]
|
||||
// CHECK:STDOUT: %int_32.loc13_50: Core.IntLiteral = int_value 32 [template = constants.%int_32]
|
||||
// CHECK:STDOUT: %u32.loc13_50: type = class_type @UInt, @UInt(constants.%int_32) [template = constants.%u32]
|
||||
// CHECK:STDOUT: %.loc13_53.1: %tuple.type.1 = tuple_literal (%AdaptTuple.ref.loc13_38, %u32.loc13_50)
|
||||
// CHECK:STDOUT: %.loc13_53.2: type = converted %.loc13_53.1, constants.%tuple.type.3 [template = constants.%tuple.type.3]
|
||||
// CHECK:STDOUT: %c.param: %tuple.type.3 = value_param runtime_param0
|
||||
// CHECK:STDOUT: %.loc13_31.1: type = splice_block %.loc13_31.3 [template = constants.%tuple.type.3] {
|
||||
// CHECK:STDOUT: %AdaptTuple.ref.loc13_16: type = name_ref AdaptTuple, file.%AdaptTuple.decl [template = constants.%AdaptTuple]
|
||||
// CHECK:STDOUT: %int_32.loc13_28: Core.IntLiteral = int_value 32 [template = constants.%int_32]
|
||||
// CHECK:STDOUT: %u32.loc13_28: type = class_type @UInt, @UInt(constants.%int_32) [template = constants.%u32]
|
||||
// CHECK:STDOUT: %.loc13_31.2: %tuple.type.1 = tuple_literal (%AdaptTuple.ref.loc13_16, %u32.loc13_28)
|
||||
// CHECK:STDOUT: %.loc13_31.3: type = converted %.loc13_31.2, constants.%tuple.type.3 [template = constants.%tuple.type.3]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %c: %tuple.type.3 = bind_name c, %c.param
|
||||
// CHECK:STDOUT: %return.param: ref %tuple.type.3 = out_param runtime_param1
|
||||
// CHECK:STDOUT: %return: ref %tuple.type.3 = return_slot %return.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @AdaptTuple {
|
||||
@@ -285,10 +335,82 @@ fn H(a: AdaptNoncopyableIndirect) -> AdaptNoncopyableIndirect {
|
||||
// CHECK:STDOUT: %d.var: ref %AdaptTuple = var d
|
||||
// CHECK:STDOUT: %d: ref %AdaptTuple = bind_name d, %d.var
|
||||
// CHECK:STDOUT: %c.ref: %AdaptTuple = name_ref c, %c
|
||||
// CHECK:STDOUT: assign %d.var, <error>
|
||||
// CHECK:STDOUT: %.loc9_24.1: %tuple.type.2 = as_compatible %c.ref
|
||||
// CHECK:STDOUT: %tuple.elem0.loc9_24.1: %i32 = tuple_access %.loc9_24.1, element0
|
||||
// CHECK:STDOUT: %.loc9_24.2: ref %tuple.type.2 = as_compatible %d.var
|
||||
// CHECK:STDOUT: %tuple.elem0.loc9_24.2: ref %i32 = tuple_access %.loc9_24.2, element0
|
||||
// CHECK:STDOUT: %.loc9_24.3: init %i32 = initialize_from %tuple.elem0.loc9_24.1 to %tuple.elem0.loc9_24.2
|
||||
// CHECK:STDOUT: %tuple.elem1.loc9_24.1: %i32 = tuple_access %.loc9_24.1, element1
|
||||
// CHECK:STDOUT: %tuple.elem1.loc9_24.2: ref %i32 = tuple_access %.loc9_24.2, element1
|
||||
// CHECK:STDOUT: %.loc9_24.4: init %i32 = initialize_from %tuple.elem1.loc9_24.1 to %tuple.elem1.loc9_24.2
|
||||
// CHECK:STDOUT: %.loc9_24.5: init %tuple.type.2 = tuple_init (%.loc9_24.3, %.loc9_24.4) to %.loc9_24.2
|
||||
// CHECK:STDOUT: %.loc9_24.6: init %AdaptTuple = as_compatible %.loc9_24.5
|
||||
// CHECK:STDOUT: %.loc9_24.7: init %AdaptTuple = converted %c.ref, %.loc9_24.6
|
||||
// CHECK:STDOUT: assign %d.var, %.loc9_24.7
|
||||
// CHECK:STDOUT: %d.ref: ref %AdaptTuple = name_ref d, %d
|
||||
// CHECK:STDOUT: %.loc20: %AdaptTuple = bind_value %d.ref
|
||||
// CHECK:STDOUT: return <error> to %return
|
||||
// CHECK:STDOUT: %.loc10_11.1: ref %tuple.type.2 = as_compatible %d.ref
|
||||
// CHECK:STDOUT: %tuple.elem0.loc10_11.1: ref %i32 = tuple_access %.loc10_11.1, element0
|
||||
// CHECK:STDOUT: %.loc10_11.2: %i32 = bind_value %tuple.elem0.loc10_11.1
|
||||
// CHECK:STDOUT: %.loc10_11.3: ref %tuple.type.2 = as_compatible %return
|
||||
// CHECK:STDOUT: %tuple.elem0.loc10_11.2: ref %i32 = tuple_access %.loc10_11.3, element0
|
||||
// CHECK:STDOUT: %.loc10_11.4: init %i32 = initialize_from %.loc10_11.2 to %tuple.elem0.loc10_11.2
|
||||
// CHECK:STDOUT: %tuple.elem1.loc10_11.1: ref %i32 = tuple_access %.loc10_11.1, element1
|
||||
// CHECK:STDOUT: %.loc10_11.5: %i32 = bind_value %tuple.elem1.loc10_11.1
|
||||
// CHECK:STDOUT: %tuple.elem1.loc10_11.2: ref %i32 = tuple_access %.loc10_11.3, element1
|
||||
// CHECK:STDOUT: %.loc10_11.6: init %i32 = initialize_from %.loc10_11.5 to %tuple.elem1.loc10_11.2
|
||||
// CHECK:STDOUT: %.loc10_11.7: init %tuple.type.2 = tuple_init (%.loc10_11.4, %.loc10_11.6) to %.loc10_11.3
|
||||
// CHECK:STDOUT: %.loc10_11.8: init %AdaptTuple = as_compatible %.loc10_11.7
|
||||
// CHECK:STDOUT: %.loc10_11.9: init %AdaptTuple = converted %d.ref, %.loc10_11.8
|
||||
// CHECK:STDOUT: return %.loc10_11.9 to %return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @InTuple(%c.param_patt: %tuple.type.3) -> %return.param_patt: %tuple.type.3 {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %d.var: ref %tuple.type.3 = var d
|
||||
// CHECK:STDOUT: %d: ref %tuple.type.3 = bind_name d, %d.var
|
||||
// CHECK:STDOUT: %c.ref: %tuple.type.3 = name_ref c, %c
|
||||
// CHECK:STDOUT: %tuple.elem0.loc14_30.1: %AdaptTuple = tuple_access %c.ref, element0
|
||||
// CHECK:STDOUT: %.loc14_30.1: %tuple.type.2 = as_compatible %tuple.elem0.loc14_30.1
|
||||
// CHECK:STDOUT: %tuple.elem0.loc14_30.2: %i32 = tuple_access %.loc14_30.1, element0
|
||||
// CHECK:STDOUT: %tuple.elem0.loc14_30.3: ref %AdaptTuple = tuple_access %d.var, element0
|
||||
// CHECK:STDOUT: %.loc14_30.2: ref %tuple.type.2 = as_compatible %tuple.elem0.loc14_30.3
|
||||
// CHECK:STDOUT: %tuple.elem0.loc14_30.4: ref %i32 = tuple_access %.loc14_30.2, element0
|
||||
// CHECK:STDOUT: %.loc14_30.3: init %i32 = initialize_from %tuple.elem0.loc14_30.2 to %tuple.elem0.loc14_30.4
|
||||
// CHECK:STDOUT: %tuple.elem1.loc14_30.1: %i32 = tuple_access %.loc14_30.1, element1
|
||||
// CHECK:STDOUT: %tuple.elem1.loc14_30.2: ref %i32 = tuple_access %.loc14_30.2, element1
|
||||
// CHECK:STDOUT: %.loc14_30.4: init %i32 = initialize_from %tuple.elem1.loc14_30.1 to %tuple.elem1.loc14_30.2
|
||||
// CHECK:STDOUT: %.loc14_30.5: init %tuple.type.2 = tuple_init (%.loc14_30.3, %.loc14_30.4) to %.loc14_30.2
|
||||
// CHECK:STDOUT: %.loc14_30.6: init %AdaptTuple = as_compatible %.loc14_30.5
|
||||
// CHECK:STDOUT: %.loc14_30.7: init %AdaptTuple = converted %tuple.elem0.loc14_30.1, %.loc14_30.6
|
||||
// CHECK:STDOUT: %tuple.elem1.loc14_30.3: %u32 = tuple_access %c.ref, element1
|
||||
// CHECK:STDOUT: %tuple.elem1.loc14_30.4: ref %u32 = tuple_access %d.var, element1
|
||||
// CHECK:STDOUT: %.loc14_30.8: init %u32 = initialize_from %tuple.elem1.loc14_30.3 to %tuple.elem1.loc14_30.4
|
||||
// CHECK:STDOUT: %.loc14_30.9: init %tuple.type.3 = tuple_init (%.loc14_30.7, %.loc14_30.8) to %d.var
|
||||
// CHECK:STDOUT: %.loc14_31: init %tuple.type.3 = converted %c.ref, %.loc14_30.9
|
||||
// CHECK:STDOUT: assign %d.var, %.loc14_31
|
||||
// CHECK:STDOUT: %d.ref: ref %tuple.type.3 = name_ref d, %d
|
||||
// CHECK:STDOUT: %tuple.elem0.loc15_10.1: ref %AdaptTuple = tuple_access %d.ref, element0
|
||||
// CHECK:STDOUT: %.loc15_10.1: ref %tuple.type.2 = as_compatible %tuple.elem0.loc15_10.1
|
||||
// CHECK:STDOUT: %tuple.elem0.loc15_10.2: ref %i32 = tuple_access %.loc15_10.1, element0
|
||||
// CHECK:STDOUT: %.loc15_10.2: %i32 = bind_value %tuple.elem0.loc15_10.2
|
||||
// CHECK:STDOUT: %tuple.elem0.loc15_10.3: ref %AdaptTuple = tuple_access %return, element0
|
||||
// CHECK:STDOUT: %.loc15_10.3: ref %tuple.type.2 = as_compatible %tuple.elem0.loc15_10.3
|
||||
// CHECK:STDOUT: %tuple.elem0.loc15_10.4: ref %i32 = tuple_access %.loc15_10.3, element0
|
||||
// CHECK:STDOUT: %.loc15_10.4: init %i32 = initialize_from %.loc15_10.2 to %tuple.elem0.loc15_10.4
|
||||
// CHECK:STDOUT: %tuple.elem1.loc15_10.1: ref %i32 = tuple_access %.loc15_10.1, element1
|
||||
// CHECK:STDOUT: %.loc15_10.5: %i32 = bind_value %tuple.elem1.loc15_10.1
|
||||
// CHECK:STDOUT: %tuple.elem1.loc15_10.2: ref %i32 = tuple_access %.loc15_10.3, element1
|
||||
// CHECK:STDOUT: %.loc15_10.6: init %i32 = initialize_from %.loc15_10.5 to %tuple.elem1.loc15_10.2
|
||||
// CHECK:STDOUT: %.loc15_10.7: init %tuple.type.2 = tuple_init (%.loc15_10.4, %.loc15_10.6) to %.loc15_10.3
|
||||
// CHECK:STDOUT: %.loc15_10.8: init %AdaptTuple = as_compatible %.loc15_10.7
|
||||
// CHECK:STDOUT: %.loc15_10.9: init %AdaptTuple = converted %tuple.elem0.loc15_10.1, %.loc15_10.8
|
||||
// CHECK:STDOUT: %tuple.elem1.loc15_10.3: ref %u32 = tuple_access %d.ref, element1
|
||||
// CHECK:STDOUT: %.loc15_10.10: %u32 = bind_value %tuple.elem1.loc15_10.3
|
||||
// CHECK:STDOUT: %tuple.elem1.loc15_10.4: ref %u32 = tuple_access %return, element1
|
||||
// CHECK:STDOUT: %.loc15_10.11: init %u32 = initialize_from %.loc15_10.10 to %tuple.elem1.loc15_10.4
|
||||
// CHECK:STDOUT: %.loc15_10.12: init %tuple.type.3 = tuple_init (%.loc15_10.9, %.loc15_10.11) to %return
|
||||
// CHECK:STDOUT: %.loc15_11: init %tuple.type.3 = converted %d.ref, %.loc15_10.12
|
||||
// CHECK:STDOUT: return %.loc15_11 to %return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- fail_adapt_not_copyable.carbon
|
||||
@@ -441,9 +563,192 @@ fn H(a: AdaptNoncopyableIndirect) -> AdaptNoncopyableIndirect {
|
||||
// CHECK:STDOUT: %b.var: ref %AdaptNoncopyableIndirect = var b
|
||||
// CHECK:STDOUT: %b: ref %AdaptNoncopyableIndirect = bind_name b, %b.var
|
||||
// CHECK:STDOUT: %a.ref: %AdaptNoncopyableIndirect = name_ref a, %a
|
||||
// CHECK:STDOUT: %.loc20_38.1: %tuple.type.2 = as_compatible %a.ref
|
||||
// CHECK:STDOUT: %tuple.elem0.loc20_38.1: %i32 = tuple_access %.loc20_38.1, element0
|
||||
// CHECK:STDOUT: %.loc20_38.2: ref %tuple.type.2 = as_compatible %b.var
|
||||
// CHECK:STDOUT: %tuple.elem0.loc20_38.2: ref %i32 = tuple_access %.loc20_38.2, element0
|
||||
// CHECK:STDOUT: %.loc20_38.3: init %i32 = initialize_from %tuple.elem0.loc20_38.1 to %tuple.elem0.loc20_38.2
|
||||
// CHECK:STDOUT: %tuple.elem1.loc20: %Noncopyable = tuple_access %.loc20_38.1, element1
|
||||
// CHECK:STDOUT: assign %b.var, <error>
|
||||
// CHECK:STDOUT: %b.ref: ref %AdaptNoncopyableIndirect = name_ref b, %b
|
||||
// CHECK:STDOUT: %.loc21: %AdaptNoncopyableIndirect = bind_value %b.ref
|
||||
// CHECK:STDOUT: %.loc27_11.1: ref %tuple.type.2 = as_compatible %b.ref
|
||||
// CHECK:STDOUT: %tuple.elem0.loc27_11.1: ref %i32 = tuple_access %.loc27_11.1, element0
|
||||
// CHECK:STDOUT: %.loc27_11.2: %i32 = bind_value %tuple.elem0.loc27_11.1
|
||||
// CHECK:STDOUT: %.loc27_11.3: ref %tuple.type.2 = as_compatible %return
|
||||
// CHECK:STDOUT: %tuple.elem0.loc27_11.2: ref %i32 = tuple_access %.loc27_11.3, element0
|
||||
// CHECK:STDOUT: %.loc27_11.4: init %i32 = initialize_from %.loc27_11.2 to %tuple.elem0.loc27_11.2
|
||||
// CHECK:STDOUT: %tuple.elem1.loc27: ref %Noncopyable = tuple_access %.loc27_11.1, element1
|
||||
// CHECK:STDOUT: %.loc27_11.5: %Noncopyable = bind_value %tuple.elem1.loc27
|
||||
// CHECK:STDOUT: return <error> to %return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: --- adapt_copyable_struct.carbon
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: constants {
|
||||
// CHECK:STDOUT: %AdaptStruct: type = class_type @AdaptStruct [template]
|
||||
// CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
|
||||
// CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
|
||||
// CHECK:STDOUT: %struct_type.e.f: type = struct_type {.e: %i32, .f: %i32} [template]
|
||||
// CHECK:STDOUT: %complete_type.3: <witness> = complete_type_witness %struct_type.e.f [template]
|
||||
// CHECK:STDOUT: %I.type: type = fn_type @I [template]
|
||||
// CHECK:STDOUT: %I: %I.type = struct_value () [template]
|
||||
// CHECK:STDOUT: %u32: type = class_type @UInt, @UInt(%int_32) [template]
|
||||
// CHECK:STDOUT: %tuple.type.1: type = tuple_type (type, type) [template]
|
||||
// CHECK:STDOUT: %tuple.type.2: type = tuple_type (%AdaptStruct, %u32) [template]
|
||||
// CHECK:STDOUT: %InTuple.type: type = fn_type @InTuple [template]
|
||||
// CHECK:STDOUT: %InTuple: %InTuple.type = struct_value () [template]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: imports {
|
||||
// CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
|
||||
// CHECK:STDOUT: .Int = %import_ref.1
|
||||
// CHECK:STDOUT: .UInt = %import_ref.5
|
||||
// CHECK:STDOUT: import Core//prelude
|
||||
// CHECK:STDOUT: import Core//prelude/...
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: file {
|
||||
// CHECK:STDOUT: package: <namespace> = namespace [template] {
|
||||
// CHECK:STDOUT: .Core = imports.%Core
|
||||
// CHECK:STDOUT: .AdaptStruct = %AdaptStruct.decl
|
||||
// CHECK:STDOUT: .I = %I.decl
|
||||
// CHECK:STDOUT: .InTuple = %InTuple.decl
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %Core.import = import Core
|
||||
// CHECK:STDOUT: %AdaptStruct.decl: type = class_decl @AdaptStruct [template = constants.%AdaptStruct] {} {}
|
||||
// CHECK:STDOUT: %I.decl: %I.type = fn_decl @I [template = constants.%I] {
|
||||
// CHECK:STDOUT: %g.patt: %AdaptStruct = binding_pattern g
|
||||
// CHECK:STDOUT: %g.param_patt: %AdaptStruct = value_param_pattern %g.patt, runtime_param0
|
||||
// CHECK:STDOUT: %return.patt: %AdaptStruct = return_slot_pattern
|
||||
// CHECK:STDOUT: %return.param_patt: %AdaptStruct = out_param_pattern %return.patt, runtime_param1
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %AdaptStruct.ref.loc8_25: type = name_ref AdaptStruct, file.%AdaptStruct.decl [template = constants.%AdaptStruct]
|
||||
// CHECK:STDOUT: %g.param: %AdaptStruct = value_param runtime_param0
|
||||
// CHECK:STDOUT: %AdaptStruct.ref.loc8_9: type = name_ref AdaptStruct, file.%AdaptStruct.decl [template = constants.%AdaptStruct]
|
||||
// CHECK:STDOUT: %g: %AdaptStruct = bind_name g, %g.param
|
||||
// CHECK:STDOUT: %return.param: ref %AdaptStruct = out_param runtime_param1
|
||||
// CHECK:STDOUT: %return: ref %AdaptStruct = return_slot %return.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %InTuple.decl: %InTuple.type = fn_decl @InTuple [template = constants.%InTuple] {
|
||||
// CHECK:STDOUT: %c.patt: %tuple.type.2 = binding_pattern c
|
||||
// CHECK:STDOUT: %c.param_patt: %tuple.type.2 = value_param_pattern %c.patt, runtime_param0
|
||||
// CHECK:STDOUT: %return.patt: %tuple.type.2 = return_slot_pattern
|
||||
// CHECK:STDOUT: %return.param_patt: %tuple.type.2 = out_param_pattern %return.patt, runtime_param1
|
||||
// CHECK:STDOUT: } {
|
||||
// CHECK:STDOUT: %AdaptStruct.ref.loc13_39: type = name_ref AdaptStruct, file.%AdaptStruct.decl [template = constants.%AdaptStruct]
|
||||
// CHECK:STDOUT: %int_32.loc13_52: Core.IntLiteral = int_value 32 [template = constants.%int_32]
|
||||
// CHECK:STDOUT: %u32.loc13_52: type = class_type @UInt, @UInt(constants.%int_32) [template = constants.%u32]
|
||||
// CHECK:STDOUT: %.loc13_55.1: %tuple.type.1 = tuple_literal (%AdaptStruct.ref.loc13_39, %u32.loc13_52)
|
||||
// CHECK:STDOUT: %.loc13_55.2: type = converted %.loc13_55.1, constants.%tuple.type.2 [template = constants.%tuple.type.2]
|
||||
// CHECK:STDOUT: %c.param: %tuple.type.2 = value_param runtime_param0
|
||||
// CHECK:STDOUT: %.loc13_32.1: type = splice_block %.loc13_32.3 [template = constants.%tuple.type.2] {
|
||||
// CHECK:STDOUT: %AdaptStruct.ref.loc13_16: type = name_ref AdaptStruct, file.%AdaptStruct.decl [template = constants.%AdaptStruct]
|
||||
// CHECK:STDOUT: %int_32.loc13_29: Core.IntLiteral = int_value 32 [template = constants.%int_32]
|
||||
// CHECK:STDOUT: %u32.loc13_29: type = class_type @UInt, @UInt(constants.%int_32) [template = constants.%u32]
|
||||
// CHECK:STDOUT: %.loc13_32.2: %tuple.type.1 = tuple_literal (%AdaptStruct.ref.loc13_16, %u32.loc13_29)
|
||||
// CHECK:STDOUT: %.loc13_32.3: type = converted %.loc13_32.2, constants.%tuple.type.2 [template = constants.%tuple.type.2]
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: %c: %tuple.type.2 = bind_name c, %c.param
|
||||
// CHECK:STDOUT: %return.param: ref %tuple.type.2 = out_param runtime_param1
|
||||
// CHECK:STDOUT: %return: ref %tuple.type.2 = return_slot %return.param
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: class @AdaptStruct {
|
||||
// CHECK:STDOUT: %int_32.loc5_14: Core.IntLiteral = int_value 32 [template = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc5_14: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
|
||||
// CHECK:STDOUT: %int_32.loc5_23: Core.IntLiteral = int_value 32 [template = constants.%int_32]
|
||||
// CHECK:STDOUT: %i32.loc5_23: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
|
||||
// CHECK:STDOUT: %struct_type.e.f: type = struct_type {.e: %i32, .f: %i32} [template = constants.%struct_type.e.f]
|
||||
// CHECK:STDOUT: adapt_decl %struct_type.e.f [template]
|
||||
// CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.e.f [template = constants.%complete_type.3]
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !members:
|
||||
// CHECK:STDOUT: .Self = constants.%AdaptStruct
|
||||
// CHECK:STDOUT: complete_type_witness = %complete_type
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @I(%g.param_patt: %AdaptStruct) -> %return.param_patt: %AdaptStruct {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %h.var: ref %AdaptStruct = var h
|
||||
// CHECK:STDOUT: %h: ref %AdaptStruct = bind_name h, %h.var
|
||||
// CHECK:STDOUT: %g.ref: %AdaptStruct = name_ref g, %g
|
||||
// CHECK:STDOUT: %.loc9_25.1: %struct_type.e.f = as_compatible %g.ref
|
||||
// CHECK:STDOUT: %.loc9_25.2: %i32 = struct_access %.loc9_25.1, element0
|
||||
// CHECK:STDOUT: %.loc9_25.3: ref %struct_type.e.f = as_compatible %h.var
|
||||
// CHECK:STDOUT: %.loc9_25.4: ref %i32 = struct_access %.loc9_25.3, element0
|
||||
// CHECK:STDOUT: %.loc9_25.5: init %i32 = initialize_from %.loc9_25.2 to %.loc9_25.4
|
||||
// CHECK:STDOUT: %.loc9_25.6: %i32 = struct_access %.loc9_25.1, element1
|
||||
// CHECK:STDOUT: %.loc9_25.7: ref %i32 = struct_access %.loc9_25.3, element1
|
||||
// CHECK:STDOUT: %.loc9_25.8: init %i32 = initialize_from %.loc9_25.6 to %.loc9_25.7
|
||||
// CHECK:STDOUT: %.loc9_25.9: init %struct_type.e.f = struct_init (%.loc9_25.5, %.loc9_25.8) to %.loc9_25.3
|
||||
// CHECK:STDOUT: %.loc9_25.10: init %AdaptStruct = as_compatible %.loc9_25.9
|
||||
// CHECK:STDOUT: %.loc9_25.11: init %AdaptStruct = converted %g.ref, %.loc9_25.10
|
||||
// CHECK:STDOUT: assign %h.var, %.loc9_25.11
|
||||
// CHECK:STDOUT: %h.ref: ref %AdaptStruct = name_ref h, %h
|
||||
// CHECK:STDOUT: %.loc10_11.1: ref %struct_type.e.f = as_compatible %h.ref
|
||||
// CHECK:STDOUT: %.loc10_11.2: ref %i32 = struct_access %.loc10_11.1, element0
|
||||
// CHECK:STDOUT: %.loc10_11.3: %i32 = bind_value %.loc10_11.2
|
||||
// CHECK:STDOUT: %.loc10_11.4: ref %struct_type.e.f = as_compatible %return
|
||||
// CHECK:STDOUT: %.loc10_11.5: ref %i32 = struct_access %.loc10_11.4, element0
|
||||
// CHECK:STDOUT: %.loc10_11.6: init %i32 = initialize_from %.loc10_11.3 to %.loc10_11.5
|
||||
// CHECK:STDOUT: %.loc10_11.7: ref %i32 = struct_access %.loc10_11.1, element1
|
||||
// CHECK:STDOUT: %.loc10_11.8: %i32 = bind_value %.loc10_11.7
|
||||
// CHECK:STDOUT: %.loc10_11.9: ref %i32 = struct_access %.loc10_11.4, element1
|
||||
// CHECK:STDOUT: %.loc10_11.10: init %i32 = initialize_from %.loc10_11.8 to %.loc10_11.9
|
||||
// CHECK:STDOUT: %.loc10_11.11: init %struct_type.e.f = struct_init (%.loc10_11.6, %.loc10_11.10) to %.loc10_11.4
|
||||
// CHECK:STDOUT: %.loc10_11.12: init %AdaptStruct = as_compatible %.loc10_11.11
|
||||
// CHECK:STDOUT: %.loc10_11.13: init %AdaptStruct = converted %h.ref, %.loc10_11.12
|
||||
// CHECK:STDOUT: return %.loc10_11.13 to %return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: fn @InTuple(%c.param_patt: %tuple.type.2) -> %return.param_patt: %tuple.type.2 {
|
||||
// CHECK:STDOUT: !entry:
|
||||
// CHECK:STDOUT: %d.var: ref %tuple.type.2 = var d
|
||||
// CHECK:STDOUT: %d: ref %tuple.type.2 = bind_name d, %d.var
|
||||
// CHECK:STDOUT: %c.ref: %tuple.type.2 = name_ref c, %c
|
||||
// CHECK:STDOUT: %tuple.elem0.loc14_31.1: %AdaptStruct = tuple_access %c.ref, element0
|
||||
// CHECK:STDOUT: %.loc14_31.1: %struct_type.e.f = as_compatible %tuple.elem0.loc14_31.1
|
||||
// CHECK:STDOUT: %.loc14_31.2: %i32 = struct_access %.loc14_31.1, element0
|
||||
// CHECK:STDOUT: %tuple.elem0.loc14_31.2: ref %AdaptStruct = tuple_access %d.var, element0
|
||||
// CHECK:STDOUT: %.loc14_31.3: ref %struct_type.e.f = as_compatible %tuple.elem0.loc14_31.2
|
||||
// CHECK:STDOUT: %.loc14_31.4: ref %i32 = struct_access %.loc14_31.3, element0
|
||||
// CHECK:STDOUT: %.loc14_31.5: init %i32 = initialize_from %.loc14_31.2 to %.loc14_31.4
|
||||
// CHECK:STDOUT: %.loc14_31.6: %i32 = struct_access %.loc14_31.1, element1
|
||||
// CHECK:STDOUT: %.loc14_31.7: ref %i32 = struct_access %.loc14_31.3, element1
|
||||
// CHECK:STDOUT: %.loc14_31.8: init %i32 = initialize_from %.loc14_31.6 to %.loc14_31.7
|
||||
// CHECK:STDOUT: %.loc14_31.9: init %struct_type.e.f = struct_init (%.loc14_31.5, %.loc14_31.8) to %.loc14_31.3
|
||||
// CHECK:STDOUT: %.loc14_31.10: init %AdaptStruct = as_compatible %.loc14_31.9
|
||||
// CHECK:STDOUT: %.loc14_31.11: init %AdaptStruct = converted %tuple.elem0.loc14_31.1, %.loc14_31.10
|
||||
// CHECK:STDOUT: %tuple.elem1.loc14_31.1: %u32 = tuple_access %c.ref, element1
|
||||
// CHECK:STDOUT: %tuple.elem1.loc14_31.2: ref %u32 = tuple_access %d.var, element1
|
||||
// CHECK:STDOUT: %.loc14_31.12: init %u32 = initialize_from %tuple.elem1.loc14_31.1 to %tuple.elem1.loc14_31.2
|
||||
// CHECK:STDOUT: %.loc14_31.13: init %tuple.type.2 = tuple_init (%.loc14_31.11, %.loc14_31.12) to %d.var
|
||||
// CHECK:STDOUT: %.loc14_32: init %tuple.type.2 = converted %c.ref, %.loc14_31.13
|
||||
// CHECK:STDOUT: assign %d.var, %.loc14_32
|
||||
// CHECK:STDOUT: %d.ref: ref %tuple.type.2 = name_ref d, %d
|
||||
// CHECK:STDOUT: %tuple.elem0.loc15_10.1: ref %AdaptStruct = tuple_access %d.ref, element0
|
||||
// CHECK:STDOUT: %.loc15_10.1: ref %struct_type.e.f = as_compatible %tuple.elem0.loc15_10.1
|
||||
// CHECK:STDOUT: %.loc15_10.2: ref %i32 = struct_access %.loc15_10.1, element0
|
||||
// CHECK:STDOUT: %.loc15_10.3: %i32 = bind_value %.loc15_10.2
|
||||
// CHECK:STDOUT: %tuple.elem0.loc15_10.2: ref %AdaptStruct = tuple_access %return, element0
|
||||
// CHECK:STDOUT: %.loc15_10.4: ref %struct_type.e.f = as_compatible %tuple.elem0.loc15_10.2
|
||||
// CHECK:STDOUT: %.loc15_10.5: ref %i32 = struct_access %.loc15_10.4, element0
|
||||
// CHECK:STDOUT: %.loc15_10.6: init %i32 = initialize_from %.loc15_10.3 to %.loc15_10.5
|
||||
// CHECK:STDOUT: %.loc15_10.7: ref %i32 = struct_access %.loc15_10.1, element1
|
||||
// CHECK:STDOUT: %.loc15_10.8: %i32 = bind_value %.loc15_10.7
|
||||
// CHECK:STDOUT: %.loc15_10.9: ref %i32 = struct_access %.loc15_10.4, element1
|
||||
// CHECK:STDOUT: %.loc15_10.10: init %i32 = initialize_from %.loc15_10.8 to %.loc15_10.9
|
||||
// CHECK:STDOUT: %.loc15_10.11: init %struct_type.e.f = struct_init (%.loc15_10.6, %.loc15_10.10) to %.loc15_10.4
|
||||
// CHECK:STDOUT: %.loc15_10.12: init %AdaptStruct = as_compatible %.loc15_10.11
|
||||
// CHECK:STDOUT: %.loc15_10.13: init %AdaptStruct = converted %tuple.elem0.loc15_10.1, %.loc15_10.12
|
||||
// CHECK:STDOUT: %tuple.elem1.loc15_10.1: ref %u32 = tuple_access %d.ref, element1
|
||||
// CHECK:STDOUT: %.loc15_10.14: %u32 = bind_value %tuple.elem1.loc15_10.1
|
||||
// CHECK:STDOUT: %tuple.elem1.loc15_10.2: ref %u32 = tuple_access %return, element1
|
||||
// CHECK:STDOUT: %.loc15_10.15: init %u32 = initialize_from %.loc15_10.14 to %tuple.elem1.loc15_10.2
|
||||
// CHECK:STDOUT: %.loc15_10.16: init %tuple.type.2 = tuple_init (%.loc15_10.13, %.loc15_10.15) to %return
|
||||
// CHECK:STDOUT: %.loc15_11: init %tuple.type.2 = converted %d.ref, %.loc15_10.16
|
||||
// CHECK:STDOUT: return %.loc15_11 to %return
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
|
||||
@@ -335,6 +335,7 @@ CARBON_DIAGNOSTIC_KIND(IncompleteTypeInLetDecl)
|
||||
CARBON_DIAGNOSTIC_KIND(IncompleteTypeInMemberAccess)
|
||||
CARBON_DIAGNOSTIC_KIND(IncompleteTypeInValueConversion)
|
||||
CARBON_DIAGNOSTIC_KIND(IncompleteTypeInVarDecl)
|
||||
CARBON_DIAGNOSTIC_KIND(InCopy)
|
||||
CARBON_DIAGNOSTIC_KIND(IntTooLargeForType)
|
||||
CARBON_DIAGNOSTIC_KIND(IntWidthNotMultipleOf8)
|
||||
CARBON_DIAGNOSTIC_KIND(IntWidthNotPositive)
|
||||
|
||||
@@ -314,12 +314,10 @@ enum class ExprCategory : int8_t {
|
||||
// object that outlives the current full expression context.
|
||||
DurableRef,
|
||||
// This instruction represents an ephemeral reference expression, that denotes
|
||||
// an
|
||||
// object that does not outlive the current full expression context.
|
||||
// an object that does not outlive the current full expression context.
|
||||
EphemeralRef,
|
||||
// This instruction represents an initializing expression, that describes how
|
||||
// to
|
||||
// initialize an object.
|
||||
// to initialize an object.
|
||||
Initializing,
|
||||
// This instruction represents a syntactic combination of expressions that are
|
||||
// permitted to have different expression categories. This is used for tuple
|
||||
|
||||
Reference in New Issue
Block a user