indirect.carbon 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/primitives.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/basics/import/indirect.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/basics/import/indirect.carbon
  12. // --- shared.h
  13. namespace A {
  14. struct X {
  15. X(int);
  16. int g();
  17. int x;
  18. };
  19. template<typename T>
  20. struct Y {
  21. T y;
  22. };
  23. }
  24. // --- direct_import.carbon
  25. library "[[@TEST_NAME]]";
  26. import Cpp library "shared.h";
  27. fn F() -> Cpp.A.X { return 1; }
  28. fn G() -> Cpp.A.Y(i32);
  29. alias AX = Cpp.A.X;
  30. // --- indirect_import_via_function.carbon
  31. library "[[@TEST_NAME]]";
  32. import Cpp library "shared.h";
  33. import library "direct_import";
  34. fn Field() -> i32 {
  35. //@dump-sem-ir-begin
  36. return F().x;
  37. //@dump-sem-ir-end
  38. }
  39. fn Function() -> i32 {
  40. //@dump-sem-ir-begin
  41. return F().g();
  42. //@dump-sem-ir-end
  43. }
  44. // --- fail_todo_not_included.carbon
  45. library "[[@TEST_NAME]]";
  46. import Cpp;
  47. // CHECK:STDERR: fail_todo_not_included.carbon:[[@LINE+6]]:1: in import [InImport]
  48. // CHECK:STDERR: direct_import.carbon:4:10: in file included here [InCppInclude]
  49. // CHECK:STDERR: ./shared.h:3:10: error: semantics TODO: `use of imported C++ declaration with no corresponding local import` [SemanticsTodo]
  50. // CHECK:STDERR: struct X {
  51. // CHECK:STDERR: ^
  52. // CHECK:STDERR:
  53. import library "direct_import";
  54. fn Field() -> i32 {
  55. // TODO: This should eventually work, by importing the C++ AST from
  56. // `direct_import`.
  57. return F().x;
  58. }
  59. // --- fail_todo_no_cpp_import.carbon
  60. library "[[@TEST_NAME]]";
  61. // CHECK:STDERR: fail_todo_no_cpp_import.carbon:[[@LINE+6]]:1: in import [InImport]
  62. // CHECK:STDERR: direct_import.carbon:4:10: in file included here [InCppInclude]
  63. // CHECK:STDERR: ./shared.h:3:10: error: semantics TODO: `indirect import of C++ declaration with no direct Cpp import` [SemanticsTodo]
  64. // CHECK:STDERR: struct X {
  65. // CHECK:STDERR: ^
  66. // CHECK:STDERR:
  67. import library "direct_import";
  68. fn Field() -> i32 {
  69. // TODO: This should eventually work, by importing the C++ AST from
  70. // `direct_import`, even though we don't otherwise have any C++ imports in
  71. // this compilation.
  72. return F().x;
  73. }
  74. // --- indirect_import_via_alias.carbon
  75. library "[[@TEST_NAME]]";
  76. import Cpp library "shared.h";
  77. import library "direct_import";
  78. fn Use() -> (i32, i32) {
  79. //@dump-sem-ir-begin
  80. var ax: AX = 1;
  81. return (ax.x, ax.g());
  82. //@dump-sem-ir-end
  83. }
  84. // --- fail_todo_import_template.carbon
  85. library "[[@TEST_NAME]]";
  86. import Cpp;
  87. // CHECK:STDERR: fail_todo_import_template.carbon:[[@LINE+6]]:1: in import [InImport]
  88. // CHECK:STDERR: direct_import.carbon:4:10: in file included here [InCppInclude]
  89. // CHECK:STDERR: ./shared.h:10:10: error: semantics TODO: `use of imported C++ declaration with no corresponding local import` [SemanticsTodo]
  90. // CHECK:STDERR: struct Y {
  91. // CHECK:STDERR: ^
  92. // CHECK:STDERR:
  93. import library "direct_import";
  94. fn Use() -> i32 {
  95. //@dump-sem-ir-begin
  96. return G().y;
  97. //@dump-sem-ir-end
  98. }
  99. // CHECK:STDOUT: --- indirect_import_via_function.carbon
  100. // CHECK:STDOUT:
  101. // CHECK:STDOUT: constants {
  102. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  103. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  104. // CHECK:STDOUT: %N: Core.IntLiteral = symbolic_binding N, 0 [symbolic]
  105. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  106. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  107. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  108. // CHECK:STDOUT: %X: type = class_type @X [concrete]
  109. // CHECK:STDOUT: %pattern_type.f80: type = pattern_type %X [concrete]
  110. // CHECK:STDOUT: %X.elem: type = unbound_element_type %X, %i32 [concrete]
  111. // CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
  112. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.824: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%N) [symbolic]
  113. // CHECK:STDOUT: %Int.as.Copy.impl.Op.9b9: %Int.as.Copy.impl.Op.type.824 = struct_value () [symbolic]
  114. // CHECK:STDOUT: %Copy.impl_witness.f17: <witness> = impl_witness imports.%Copy.impl_witness_table.e76, @Int.as.Copy.impl(%int_32) [concrete]
  115. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.546: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%int_32) [concrete]
  116. // CHECK:STDOUT: %Int.as.Copy.impl.Op.664: %Int.as.Copy.impl.Op.type.546 = struct_value () [concrete]
  117. // CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %i32, (%Copy.impl_witness.f17) [concrete]
  118. // CHECK:STDOUT: %Copy.WithSelf.Op.type.081: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet) [concrete]
  119. // CHECK:STDOUT: %.8e2: type = fn_type_with_self_type %Copy.WithSelf.Op.type.081, %Copy.facet [concrete]
  120. // CHECK:STDOUT: %Int.as.Copy.impl.Op.specific_fn: <specific function> = specific_function %Int.as.Copy.impl.Op.664, @Int.as.Copy.impl.Op(%int_32) [concrete]
  121. // CHECK:STDOUT: %X.cpp_destructor.type: type = fn_type @X.cpp_destructor [concrete]
  122. // CHECK:STDOUT: %X.cpp_destructor: %X.cpp_destructor.type = struct_value () [concrete]
  123. // CHECK:STDOUT: %X.g.cpp_overload_set.type: type = cpp_overload_set_type @X.g.cpp_overload_set [concrete]
  124. // CHECK:STDOUT: %X.g.cpp_overload_set.value: %X.g.cpp_overload_set.type = cpp_overload_set_value @X.g.cpp_overload_set [concrete]
  125. // CHECK:STDOUT: %X.g.type: type = fn_type @X.g [concrete]
  126. // CHECK:STDOUT: %X.g: %X.g.type = struct_value () [concrete]
  127. // CHECK:STDOUT: }
  128. // CHECK:STDOUT:
  129. // CHECK:STDOUT: imports {
  130. // CHECK:STDOUT: %Main.F: %F.type = import_ref Main//direct_import, F, loaded [concrete = constants.%F]
  131. // CHECK:STDOUT: %Core.import_ref.18d: @Int.as.Copy.impl.%Int.as.Copy.impl.Op.type (%Int.as.Copy.impl.Op.type.824) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.Copy.impl.%Int.as.Copy.impl.Op (constants.%Int.as.Copy.impl.Op.9b9)]
  132. // CHECK:STDOUT: %Copy.impl_witness_table.e76 = impl_witness_table (%Core.import_ref.18d), @Int.as.Copy.impl [concrete]
  133. // CHECK:STDOUT: %X.g.cpp_overload_set.value: %X.g.cpp_overload_set.type = cpp_overload_set_value @X.g.cpp_overload_set [concrete = constants.%X.g.cpp_overload_set.value]
  134. // CHECK:STDOUT: %X.g.decl: %X.g.type = fn_decl @X.g [concrete = constants.%X.g] {
  135. // CHECK:STDOUT: %self.param_patt: %pattern_type.f80 = ref_param_pattern [concrete]
  136. // CHECK:STDOUT: %self.patt: %pattern_type.f80 = at_binding_pattern self, %self.param_patt [concrete]
  137. // CHECK:STDOUT: <elided>
  138. // CHECK:STDOUT: } {
  139. // CHECK:STDOUT: <elided>
  140. // CHECK:STDOUT: %self.param: ref %X = ref_param call_param0
  141. // CHECK:STDOUT: %self: ref %X = ref_binding self, %self.param
  142. // CHECK:STDOUT: <elided>
  143. // CHECK:STDOUT: }
  144. // CHECK:STDOUT: }
  145. // CHECK:STDOUT:
  146. // CHECK:STDOUT: fn @Field() -> out %return.param: %i32 {
  147. // CHECK:STDOUT: !entry:
  148. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%Main.F [concrete = constants.%F]
  149. // CHECK:STDOUT: %.loc9_12.1: ref %X = temporary_storage
  150. // CHECK:STDOUT: %F.call: init %X to %.loc9_12.1 = call %F.ref()
  151. // CHECK:STDOUT: %.loc9_12.2: ref %X = temporary %.loc9_12.1, %F.call
  152. // CHECK:STDOUT: %x.ref: %X.elem = name_ref x, @X.%.1 [concrete = @X.%.1]
  153. // CHECK:STDOUT: %.loc9_13.1: ref %i32 = class_element_access %.loc9_12.2, element0
  154. // CHECK:STDOUT: %.loc9_13.2: %i32 = acquire_value %.loc9_13.1
  155. // CHECK:STDOUT: %impl.elem0: %.8e2 = impl_witness_access constants.%Copy.impl_witness.f17, element0 [concrete = constants.%Int.as.Copy.impl.Op.664]
  156. // CHECK:STDOUT: %bound_method.loc9_13.1: <bound method> = bound_method %.loc9_13.2, %impl.elem0
  157. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
  158. // CHECK:STDOUT: %bound_method.loc9_13.2: <bound method> = bound_method %.loc9_13.2, %specific_fn
  159. // CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i32 = call %bound_method.loc9_13.2(%.loc9_13.2)
  160. // CHECK:STDOUT: %X.cpp_destructor.bound: <bound method> = bound_method %.loc9_12.2, constants.%X.cpp_destructor
  161. // CHECK:STDOUT: %X.cpp_destructor.call: init %empty_tuple.type = call %X.cpp_destructor.bound(%.loc9_12.2)
  162. // CHECK:STDOUT: return %Int.as.Copy.impl.Op.call
  163. // CHECK:STDOUT: }
  164. // CHECK:STDOUT:
  165. // CHECK:STDOUT: fn @Function() -> out %return.param: %i32 {
  166. // CHECK:STDOUT: !entry:
  167. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%Main.F [concrete = constants.%F]
  168. // CHECK:STDOUT: %.loc15_12.1: ref %X = temporary_storage
  169. // CHECK:STDOUT: %F.call: init %X to %.loc15_12.1 = call %F.ref()
  170. // CHECK:STDOUT: %.loc15_12.2: ref %X = temporary %.loc15_12.1, %F.call
  171. // CHECK:STDOUT: %g.ref: %X.g.cpp_overload_set.type = name_ref g, imports.%X.g.cpp_overload_set.value [concrete = constants.%X.g.cpp_overload_set.value]
  172. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %.loc15_12.2, %g.ref
  173. // CHECK:STDOUT: %X.g.call: init %i32 = call imports.%X.g.decl(%.loc15_12.2)
  174. // CHECK:STDOUT: %X.cpp_destructor.bound: <bound method> = bound_method %.loc15_12.2, constants.%X.cpp_destructor
  175. // CHECK:STDOUT: %X.cpp_destructor.call: init %empty_tuple.type = call %X.cpp_destructor.bound(%.loc15_12.2)
  176. // CHECK:STDOUT: return %X.g.call
  177. // CHECK:STDOUT: }
  178. // CHECK:STDOUT:
  179. // CHECK:STDOUT: --- indirect_import_via_alias.carbon
  180. // CHECK:STDOUT:
  181. // CHECK:STDOUT: constants {
  182. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  183. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  184. // CHECK:STDOUT: %N: Core.IntLiteral = symbolic_binding N, 0 [symbolic]
  185. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  186. // CHECK:STDOUT: %tuple.type.d07: type = tuple_type (%i32, %i32) [concrete]
  187. // CHECK:STDOUT: %X: type = class_type @X [concrete]
  188. // CHECK:STDOUT: %X.elem: type = unbound_element_type %X, %i32 [concrete]
  189. // CHECK:STDOUT: %pattern_type.f80: type = pattern_type %X [concrete]
  190. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  191. // CHECK:STDOUT: %ptr.611: type = ptr_type %X [concrete]
  192. // CHECK:STDOUT: %X__carbon_thunk.type: type = fn_type @X__carbon_thunk [concrete]
  193. // CHECK:STDOUT: %X__carbon_thunk: %X__carbon_thunk.type = struct_value () [concrete]
  194. // CHECK:STDOUT: %ImplicitAs.type.e8c: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  195. // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic]
  196. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.4e6: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic]
  197. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.3c2: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.4e6 = struct_value () [symbolic]
  198. // CHECK:STDOUT: %ImplicitAs.impl_witness.6bc: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.74f, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  199. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.e0d: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  200. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.e0d = struct_value () [concrete]
  201. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.e8c = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.6bc) [concrete]
  202. // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.b37: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i32, %ImplicitAs.facet) [concrete]
  203. // CHECK:STDOUT: %.545: type = fn_type_with_self_type %ImplicitAs.WithSelf.Convert.type.b37, %ImplicitAs.facet [concrete]
  204. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5 [concrete]
  205. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: <specific function> = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_32) [concrete]
  206. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  207. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  208. // CHECK:STDOUT: %X.g.cpp_overload_set.type: type = cpp_overload_set_type @X.g.cpp_overload_set [concrete]
  209. // CHECK:STDOUT: %X.g.cpp_overload_set.value: %X.g.cpp_overload_set.type = cpp_overload_set_value @X.g.cpp_overload_set [concrete]
  210. // CHECK:STDOUT: %X.g.type: type = fn_type @X.g [concrete]
  211. // CHECK:STDOUT: %X.g: %X.g.type = struct_value () [concrete]
  212. // CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
  213. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.824: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%N) [symbolic]
  214. // CHECK:STDOUT: %Int.as.Copy.impl.Op.9b9: %Int.as.Copy.impl.Op.type.824 = struct_value () [symbolic]
  215. // CHECK:STDOUT: %Copy.impl_witness.f17: <witness> = impl_witness imports.%Copy.impl_witness_table.e76, @Int.as.Copy.impl(%int_32) [concrete]
  216. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.546: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%int_32) [concrete]
  217. // CHECK:STDOUT: %Int.as.Copy.impl.Op.664: %Int.as.Copy.impl.Op.type.546 = struct_value () [concrete]
  218. // CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %i32, (%Copy.impl_witness.f17) [concrete]
  219. // CHECK:STDOUT: %Copy.WithSelf.Op.type.081: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet) [concrete]
  220. // CHECK:STDOUT: %.8e2: type = fn_type_with_self_type %Copy.WithSelf.Op.type.081, %Copy.facet [concrete]
  221. // CHECK:STDOUT: %Int.as.Copy.impl.Op.specific_fn: <specific function> = specific_function %Int.as.Copy.impl.Op.664, @Int.as.Copy.impl.Op(%int_32) [concrete]
  222. // CHECK:STDOUT: %X.cpp_destructor.type: type = fn_type @X.cpp_destructor [concrete]
  223. // CHECK:STDOUT: %X.cpp_destructor: %X.cpp_destructor.type = struct_value () [concrete]
  224. // CHECK:STDOUT: }
  225. // CHECK:STDOUT:
  226. // CHECK:STDOUT: imports {
  227. // CHECK:STDOUT: %Main.AX: type = import_ref Main//direct_import, AX, loaded [concrete = constants.%X]
  228. // CHECK:STDOUT: %X__carbon_thunk.decl: %X__carbon_thunk.type = fn_decl @X__carbon_thunk [concrete = constants.%X__carbon_thunk] {
  229. // CHECK:STDOUT: <elided>
  230. // CHECK:STDOUT: } {
  231. // CHECK:STDOUT: <elided>
  232. // CHECK:STDOUT: }
  233. // CHECK:STDOUT: %Core.import_ref.42d: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.4e6) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.3c2)]
  234. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.74f = impl_witness_table (%Core.import_ref.42d), @Core.IntLiteral.as.ImplicitAs.impl [concrete]
  235. // CHECK:STDOUT: %X.g.cpp_overload_set.value: %X.g.cpp_overload_set.type = cpp_overload_set_value @X.g.cpp_overload_set [concrete = constants.%X.g.cpp_overload_set.value]
  236. // CHECK:STDOUT: %X.g.decl: %X.g.type = fn_decl @X.g [concrete = constants.%X.g] {
  237. // CHECK:STDOUT: %self.param_patt: %pattern_type.f80 = ref_param_pattern [concrete]
  238. // CHECK:STDOUT: %self.patt: %pattern_type.f80 = at_binding_pattern self, %self.param_patt [concrete]
  239. // CHECK:STDOUT: <elided>
  240. // CHECK:STDOUT: } {
  241. // CHECK:STDOUT: <elided>
  242. // CHECK:STDOUT: %self.param: ref %X = ref_param call_param0
  243. // CHECK:STDOUT: %self: ref %X = ref_binding self, %self.param
  244. // CHECK:STDOUT: <elided>
  245. // CHECK:STDOUT: }
  246. // CHECK:STDOUT: %Core.import_ref.18d: @Int.as.Copy.impl.%Int.as.Copy.impl.Op.type (%Int.as.Copy.impl.Op.type.824) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.Copy.impl.%Int.as.Copy.impl.Op (constants.%Int.as.Copy.impl.Op.9b9)]
  247. // CHECK:STDOUT: %Copy.impl_witness_table.e76 = impl_witness_table (%Core.import_ref.18d), @Int.as.Copy.impl [concrete]
  248. // CHECK:STDOUT: }
  249. // CHECK:STDOUT:
  250. // CHECK:STDOUT: fn @Use() -> out %return.param: %tuple.type.d07 {
  251. // CHECK:STDOUT: !entry:
  252. // CHECK:STDOUT: name_binding_decl {
  253. // CHECK:STDOUT: %ax.patt: %pattern_type.f80 = ref_binding_pattern ax [concrete]
  254. // CHECK:STDOUT: %ax.var_patt: %pattern_type.f80 = var_pattern %ax.patt [concrete]
  255. // CHECK:STDOUT: }
  256. // CHECK:STDOUT: %ax.var: ref %X = var %ax.var_patt
  257. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  258. // CHECK:STDOUT: %.loc9_3.1: ref %X = splice_block %ax.var {}
  259. // CHECK:STDOUT: %impl.elem0.loc9: %.545 = impl_witness_access constants.%ImplicitAs.impl_witness.6bc, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5]
  260. // CHECK:STDOUT: %bound_method.loc9_16.1: <bound method> = bound_method %int_1, %impl.elem0.loc9 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound]
  261. // CHECK:STDOUT: %specific_fn.loc9: <specific function> = specific_function %impl.elem0.loc9, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  262. // CHECK:STDOUT: %bound_method.loc9_16.2: <bound method> = bound_method %int_1, %specific_fn.loc9 [concrete = constants.%bound_method]
  263. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i32 = call %bound_method.loc9_16.2(%int_1) [concrete = constants.%int_1.5d2]
  264. // CHECK:STDOUT: %.loc9_16.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_1.5d2]
  265. // CHECK:STDOUT: %.loc9_16.2: %i32 = converted %int_1, %.loc9_16.1 [concrete = constants.%int_1.5d2]
  266. // CHECK:STDOUT: %addr: %ptr.611 = addr_of %.loc9_3.1
  267. // CHECK:STDOUT: %X__carbon_thunk.call: init %empty_tuple.type = call imports.%X__carbon_thunk.decl(%.loc9_16.2, %addr)
  268. // CHECK:STDOUT: %.loc9_3.2: init %X to %.loc9_3.1 = mark_in_place_init %X__carbon_thunk.call
  269. // CHECK:STDOUT: %.loc9_3.3: init %X = converted %int_1, %.loc9_3.2
  270. // CHECK:STDOUT: assign %ax.var, %.loc9_3.3
  271. // CHECK:STDOUT: %AX.ref: type = name_ref AX, imports.%Main.AX [concrete = constants.%X]
  272. // CHECK:STDOUT: %ax: ref %X = ref_binding ax, %ax.var
  273. // CHECK:STDOUT: %ax.ref.loc10_11: ref %X = name_ref ax, %ax
  274. // CHECK:STDOUT: %x.ref: %X.elem = name_ref x, @X.%.1 [concrete = @X.%.1]
  275. // CHECK:STDOUT: %.loc10_13.1: ref %i32 = class_element_access %ax.ref.loc10_11, element0
  276. // CHECK:STDOUT: %ax.ref.loc10_17: ref %X = name_ref ax, %ax
  277. // CHECK:STDOUT: %g.ref: %X.g.cpp_overload_set.type = name_ref g, imports.%X.g.cpp_overload_set.value [concrete = constants.%X.g.cpp_overload_set.value]
  278. // CHECK:STDOUT: %bound_method.loc10_19: <bound method> = bound_method %ax.ref.loc10_17, %g.ref
  279. // CHECK:STDOUT: %X.g.call: init %i32 = call imports.%X.g.decl(%ax.ref.loc10_17)
  280. // CHECK:STDOUT: %.loc10_23.1: %tuple.type.d07 = tuple_literal (%.loc10_13.1, %X.g.call)
  281. // CHECK:STDOUT: %.loc10_13.2: %i32 = acquire_value %.loc10_13.1
  282. // CHECK:STDOUT: %impl.elem0.loc10: %.8e2 = impl_witness_access constants.%Copy.impl_witness.f17, element0 [concrete = constants.%Int.as.Copy.impl.Op.664]
  283. // CHECK:STDOUT: %bound_method.loc10_13.1: <bound method> = bound_method %.loc10_13.2, %impl.elem0.loc10
  284. // CHECK:STDOUT: %specific_fn.loc10: <specific function> = specific_function %impl.elem0.loc10, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
  285. // CHECK:STDOUT: %bound_method.loc10_13.2: <bound method> = bound_method %.loc10_13.2, %specific_fn.loc10
  286. // CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i32 = call %bound_method.loc10_13.2(%.loc10_13.2)
  287. // CHECK:STDOUT: %tuple.elem0: ref %i32 = tuple_access %return.param, element0
  288. // CHECK:STDOUT: %.loc10_23.2: init %i32 to %tuple.elem0 = in_place_init %Int.as.Copy.impl.Op.call
  289. // CHECK:STDOUT: %tuple.elem1: ref %i32 = tuple_access %return.param, element1
  290. // CHECK:STDOUT: %.loc10_23.3: init %i32 to %tuple.elem1 = in_place_init %X.g.call
  291. // CHECK:STDOUT: %.loc10_23.4: init %tuple.type.d07 to %return.param = tuple_init (%.loc10_23.2, %.loc10_23.3)
  292. // CHECK:STDOUT: %.loc10_24: init %tuple.type.d07 = converted %.loc10_23.1, %.loc10_23.4
  293. // CHECK:STDOUT: %X.cpp_destructor.bound: <bound method> = bound_method %ax.var, constants.%X.cpp_destructor
  294. // CHECK:STDOUT: %X.cpp_destructor.call: init %empty_tuple.type = call %X.cpp_destructor.bound(%ax.var)
  295. // CHECK:STDOUT: return %.loc10_24 to %return.param
  296. // CHECK:STDOUT: }
  297. // CHECK:STDOUT:
  298. // CHECK:STDOUT: --- fail_todo_import_template.carbon
  299. // CHECK:STDOUT:
  300. // CHECK:STDOUT: constants {
  301. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  302. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  303. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  304. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  305. // CHECK:STDOUT: }
  306. // CHECK:STDOUT:
  307. // CHECK:STDOUT: imports {
  308. // CHECK:STDOUT: %Main.G: %G.type = import_ref Main//direct_import, G, loaded [concrete = constants.%G]
  309. // CHECK:STDOUT: }
  310. // CHECK:STDOUT:
  311. // CHECK:STDOUT: fn @Use() -> out %return.param: %i32 {
  312. // CHECK:STDOUT: !entry:
  313. // CHECK:STDOUT: %G.ref: %G.type = name_ref G, imports.%Main.G [concrete = constants.%G]
  314. // CHECK:STDOUT: %G.call: <error> = call %G.ref()
  315. // CHECK:STDOUT: %y.ref: <error> = name_ref y, <error> [concrete = <error>]
  316. // CHECK:STDOUT: return <error>
  317. // CHECK:STDOUT: }
  318. // CHECK:STDOUT: