| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- // 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
- //
- // AUTOUPDATE
- // TIP: To test this file alone, run:
- // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/array/import.carbon
- // TIP: To dump output, run:
- // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/array/import.carbon
- // --- library.carbon
- library "[[@TEST_NAME]]";
- fn F() -> array(i32, 42);
- // --- user.carbon
- import library "library";
- fn G(n: i32) -> i32 {
- //@dump-sem-ir-begin
- return F()[n];
- //@dump-sem-ir-end
- }
- // CHECK:STDOUT: --- user.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
- // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
- // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
- // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
- // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
- // CHECK:STDOUT: %int_42: Core.IntLiteral = int_value 42 [concrete]
- // CHECK:STDOUT: %array_type: type = array_type %int_42, %i32 [concrete]
- // CHECK:STDOUT: %ptr.830: type = ptr_type %array_type [concrete]
- // CHECK:STDOUT: %Op.type.b8c: type = fn_type @Op.3, @Destroy.impl(%array_type) [concrete]
- // CHECK:STDOUT: %Op.552: %Op.type.b8c = struct_value () [concrete]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: imports {
- // CHECK:STDOUT: %Main.F: %F.type = import_ref Main//library, F, loaded [concrete = constants.%F]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @G(%n.param: %i32) -> %i32 {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%Main.F [concrete = constants.%F]
- // CHECK:STDOUT: %.loc6_12.1: ref %array_type = temporary_storage
- // CHECK:STDOUT: %F.call: init %array_type = call %F.ref() to %.loc6_12.1
- // CHECK:STDOUT: %n.ref: %i32 = name_ref n, %n
- // CHECK:STDOUT: %.loc6_12.2: ref %array_type = temporary %.loc6_12.1, %F.call
- // CHECK:STDOUT: %int_32.loc6: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
- // CHECK:STDOUT: %i32.loc6: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
- // CHECK:STDOUT: %.loc6_15.1: ref %i32 = array_index %.loc6_12.2, %n.ref
- // CHECK:STDOUT: %.loc6_15.2: %i32 = bind_value %.loc6_15.1
- // CHECK:STDOUT: %Op.bound: <bound method> = bound_method %.loc6_12.1, constants.%Op.552
- // CHECK:STDOUT: <elided>
- // CHECK:STDOUT: %bound_method: <bound method> = bound_method %.loc6_12.1, %Op.specific_fn
- // CHECK:STDOUT: %addr: %ptr.830 = addr_of %.loc6_12.1
- // CHECK:STDOUT: %no_op: init %empty_tuple.type = call %bound_method(%addr)
- // CHECK:STDOUT: return %.loc6_15.2
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
|