inline.carbon 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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/int.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/function/inline.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/function/inline.carbon
  12. // ============================================================================
  13. // With definition
  14. // ============================================================================
  15. // --- with_definition.h
  16. inline void foo() {}
  17. // --- import_with_definition.carbon
  18. library "[[@TEST_NAME]]";
  19. import Cpp library "with_definition.h";
  20. fn MyF() {
  21. //@dump-sem-ir-begin
  22. Cpp.foo();
  23. //@dump-sem-ir-end
  24. }
  25. // ============================================================================
  26. // Without definition
  27. // ============================================================================
  28. // --- without_definition.h
  29. inline void foo();
  30. // --- todo_fail_import_without_definition.carbon
  31. library "[[@TEST_NAME]]";
  32. // TODO: Promote this warning to an error by default.
  33. // CHECK:STDERR: todo_fail_import_without_definition.carbon:[[@LINE+4]]:10: in file included here [InCppInclude]
  34. // CHECK:STDERR: ./without_definition.h:2:13: warning: inline function 'foo' is not defined [CppInteropParseWarning]
  35. // CHECK:STDERR: 2 | inline void foo();
  36. // CHECK:STDERR: | ^
  37. import Cpp library "without_definition.h";
  38. fn MyF() {
  39. //@dump-sem-ir-begin
  40. // CHECK:STDERR: todo_fail_import_without_definition.carbon:[[@LINE+4]]:11: note: used here [CppInteropParseNote]
  41. // CHECK:STDERR: 17 | Cpp.foo();
  42. // CHECK:STDERR: | ^
  43. // CHECK:STDERR:
  44. Cpp.foo();
  45. // Don't error on repeated calls.
  46. Cpp.foo();
  47. //@dump-sem-ir-end
  48. }
  49. // ============================================================================
  50. // automatic return type
  51. // ============================================================================
  52. // --- automatic_return_type.carbon
  53. library "[[@TEST_NAME]]";
  54. import Cpp inline '''
  55. inline auto WithoutThunk(int) -> auto { return 0; }
  56. inline auto ThunkOnArg(short) -> auto { return 0; }
  57. inline auto ThunkOnReturn(int) -> auto { short x = 0; return x; }
  58. inline auto ThunkOnBoth(short) -> auto { short x = 0; return x; }
  59. ''';
  60. fn MyF() {
  61. //@dump-sem-ir-begin
  62. let r1: i32 = Cpp.WithoutThunk(1);
  63. let r2: i32 = Cpp.ThunkOnArg(1);
  64. let r3: i16 = Cpp.ThunkOnReturn(1);
  65. let r4: i16 = Cpp.ThunkOnBoth(1);
  66. //@dump-sem-ir-end
  67. }
  68. // CHECK:STDOUT: --- import_with_definition.carbon
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: constants {
  71. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  72. // CHECK:STDOUT: %.c5d: type = cpp_overload_set_type @foo [concrete]
  73. // CHECK:STDOUT: %empty_struct: %.c5d = struct_value () [concrete]
  74. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  75. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT:
  78. // CHECK:STDOUT: imports {
  79. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  80. // CHECK:STDOUT: .foo = %.a21
  81. // CHECK:STDOUT: import Cpp//...
  82. // CHECK:STDOUT: }
  83. // CHECK:STDOUT: %.a21: %.c5d = cpp_overload_set_value @foo [concrete = constants.%empty_struct]
  84. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {} {}
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT:
  87. // CHECK:STDOUT: fn @MyF() {
  88. // CHECK:STDOUT: !entry:
  89. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  90. // CHECK:STDOUT: %foo.ref: %.c5d = name_ref foo, imports.%.a21 [concrete = constants.%empty_struct]
  91. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call imports.%foo.decl()
  92. // CHECK:STDOUT: <elided>
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: --- todo_fail_import_without_definition.carbon
  96. // CHECK:STDOUT:
  97. // CHECK:STDOUT: constants {
  98. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  99. // CHECK:STDOUT: %.c5d: type = cpp_overload_set_type @foo [concrete]
  100. // CHECK:STDOUT: %empty_struct: %.c5d = struct_value () [concrete]
  101. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  102. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: imports {
  106. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  107. // CHECK:STDOUT: .foo = %.a21
  108. // CHECK:STDOUT: import Cpp//...
  109. // CHECK:STDOUT: }
  110. // CHECK:STDOUT: %.a21: %.c5d = cpp_overload_set_value @foo [concrete = constants.%empty_struct]
  111. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {} {}
  112. // CHECK:STDOUT: }
  113. // CHECK:STDOUT:
  114. // CHECK:STDOUT: fn @MyF() {
  115. // CHECK:STDOUT: !entry:
  116. // CHECK:STDOUT: %Cpp.ref.loc17: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  117. // CHECK:STDOUT: %foo.ref.loc17: %.c5d = name_ref foo, imports.%.a21 [concrete = constants.%empty_struct]
  118. // CHECK:STDOUT: %foo.call.loc17: init %empty_tuple.type = call imports.%foo.decl()
  119. // CHECK:STDOUT: %Cpp.ref.loc20: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  120. // CHECK:STDOUT: %foo.ref.loc20: %.c5d = name_ref foo, imports.%.a21 [concrete = constants.%empty_struct]
  121. // CHECK:STDOUT: %foo.call.loc20: init %empty_tuple.type = call imports.%foo.decl()
  122. // CHECK:STDOUT: <elided>
  123. // CHECK:STDOUT: }
  124. // CHECK:STDOUT:
  125. // CHECK:STDOUT: --- automatic_return_type.carbon
  126. // CHECK:STDOUT:
  127. // CHECK:STDOUT: constants {
  128. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  129. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  130. // CHECK:STDOUT: %N: Core.IntLiteral = bind_symbolic_name N, 0 [symbolic]
  131. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  132. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  133. // CHECK:STDOUT: %.fef: type = cpp_overload_set_type @Int.as.ImplicitAs.impl.Convert [concrete]
  134. // CHECK:STDOUT: %empty_struct.e92: %.fef = struct_value () [concrete]
  135. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  136. // CHECK:STDOUT: %WithoutThunk.type: type = fn_type @WithoutThunk [concrete]
  137. // CHECK:STDOUT: %WithoutThunk: %WithoutThunk.type = struct_value () [concrete]
  138. // CHECK:STDOUT: %ImplicitAs.type.d14: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  139. // CHECK:STDOUT: %ImplicitAs.Convert.type.1b6: type = fn_type @ImplicitAs.Convert, @ImplicitAs(%i32) [concrete]
  140. // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  141. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.340: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic]
  142. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.1c0: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.340 = struct_value () [symbolic]
  143. // CHECK:STDOUT: %ImplicitAs.impl_witness.204: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.9e9, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  144. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.584: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  145. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.0f0: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.584 = struct_value () [concrete]
  146. // CHECK:STDOUT: %ImplicitAs.facet.7f1: %ImplicitAs.type.d14 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.204) [concrete]
  147. // CHECK:STDOUT: %.1df: type = fn_type_with_self_type %ImplicitAs.Convert.type.1b6, %ImplicitAs.facet.7f1 [concrete]
  148. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.abf: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.0f0 [concrete]
  149. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn.a29: <specific function> = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.0f0, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_32) [concrete]
  150. // CHECK:STDOUT: %bound_method.c11: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn.a29 [concrete]
  151. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  152. // CHECK:STDOUT: %.281: type = cpp_overload_set_type @ThunkOnArg [concrete]
  153. // CHECK:STDOUT: %empty_struct.a11: %.281 = struct_value () [concrete]
  154. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  155. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  156. // CHECK:STDOUT: %pattern_type.2f8: type = pattern_type %i16 [concrete]
  157. // CHECK:STDOUT: %ptr.251: type = ptr_type %i16 [concrete]
  158. // CHECK:STDOUT: %ThunkOnArg__carbon_thunk.type: type = fn_type @ThunkOnArg__carbon_thunk [concrete]
  159. // CHECK:STDOUT: %ThunkOnArg__carbon_thunk: %ThunkOnArg__carbon_thunk.type = struct_value () [concrete]
  160. // CHECK:STDOUT: %ImplicitAs.type.527: type = facet_type <@ImplicitAs, @ImplicitAs(%i16)> [concrete]
  161. // CHECK:STDOUT: %ImplicitAs.Convert.type.fa6: type = fn_type @ImplicitAs.Convert, @ImplicitAs(%i16) [concrete]
  162. // CHECK:STDOUT: %ImplicitAs.impl_witness.ed0: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.9e9, @Core.IntLiteral.as.ImplicitAs.impl(%int_16) [concrete]
  163. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.643: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_16) [concrete]
  164. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.4eb: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.643 = struct_value () [concrete]
  165. // CHECK:STDOUT: %ImplicitAs.facet.381: %ImplicitAs.type.527 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.ed0) [concrete]
  166. // CHECK:STDOUT: %.ee2: type = fn_type_with_self_type %ImplicitAs.Convert.type.fa6, %ImplicitAs.facet.381 [concrete]
  167. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.c97: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.4eb [concrete]
  168. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn.810: <specific function> = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.4eb, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_16) [concrete]
  169. // CHECK:STDOUT: %bound_method.a9b: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn.810 [concrete]
  170. // CHECK:STDOUT: %int_1.f90: %i16 = int_value 1 [concrete]
  171. // CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
  172. // CHECK:STDOUT: %Copy.Op.type: type = fn_type @Copy.Op [concrete]
  173. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.afd: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%N) [symbolic]
  174. // CHECK:STDOUT: %Int.as.Copy.impl.Op.6cd: %Int.as.Copy.impl.Op.type.afd = struct_value () [symbolic]
  175. // CHECK:STDOUT: %Copy.impl_witness.2f8: <witness> = impl_witness imports.%Copy.impl_witness_table.1ed, @Int.as.Copy.impl(%int_16) [concrete]
  176. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.c73: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%int_16) [concrete]
  177. // CHECK:STDOUT: %Int.as.Copy.impl.Op.3dc: %Int.as.Copy.impl.Op.type.c73 = struct_value () [concrete]
  178. // CHECK:STDOUT: %Copy.facet.4bb: %Copy.type = facet_value %i16, (%Copy.impl_witness.2f8) [concrete]
  179. // CHECK:STDOUT: %.798: type = fn_type_with_self_type %Copy.Op.type, %Copy.facet.4bb [concrete]
  180. // CHECK:STDOUT: %Int.as.Copy.impl.Op.bound: <bound method> = bound_method %int_1.f90, %Int.as.Copy.impl.Op.3dc [concrete]
  181. // CHECK:STDOUT: %Int.as.Copy.impl.Op.specific_fn: <specific function> = specific_function %Int.as.Copy.impl.Op.3dc, @Int.as.Copy.impl.Op(%int_16) [concrete]
  182. // CHECK:STDOUT: %bound_method.7c2: <bound method> = bound_method %int_1.f90, %Int.as.Copy.impl.Op.specific_fn [concrete]
  183. // CHECK:STDOUT: %.3ed: type = cpp_overload_set_type @ThunkOnArg__carbon_thunk [concrete]
  184. // CHECK:STDOUT: %empty_struct.232: %.3ed = struct_value () [concrete]
  185. // CHECK:STDOUT: %ThunkOnReturn__carbon_thunk.type: type = fn_type @ThunkOnReturn__carbon_thunk [concrete]
  186. // CHECK:STDOUT: %ThunkOnReturn__carbon_thunk: %ThunkOnReturn__carbon_thunk.type = struct_value () [concrete]
  187. // CHECK:STDOUT: %.a8c: type = cpp_overload_set_type @Copy.Op [concrete]
  188. // CHECK:STDOUT: %empty_struct.258: %.a8c = struct_value () [concrete]
  189. // CHECK:STDOUT: %ThunkOnBoth__carbon_thunk.type: type = fn_type @ThunkOnBoth__carbon_thunk [concrete]
  190. // CHECK:STDOUT: %ThunkOnBoth__carbon_thunk: %ThunkOnBoth__carbon_thunk.type = struct_value () [concrete]
  191. // CHECK:STDOUT: %Int.as.Destroy.impl.Op.type.038: type = fn_type @Int.as.Destroy.impl.Op, @Int.as.Destroy.impl(%int_16) [concrete]
  192. // CHECK:STDOUT: %Int.as.Destroy.impl.Op.431: %Int.as.Destroy.impl.Op.type.038 = struct_value () [concrete]
  193. // CHECK:STDOUT: }
  194. // CHECK:STDOUT:
  195. // CHECK:STDOUT: imports {
  196. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  197. // CHECK:STDOUT: .WithoutThunk = %.1bd
  198. // CHECK:STDOUT: .ThunkOnArg = %.c9b
  199. // CHECK:STDOUT: .ThunkOnReturn = %.d87
  200. // CHECK:STDOUT: .ThunkOnBoth = %.db9
  201. // CHECK:STDOUT: import Cpp//...
  202. // CHECK:STDOUT: }
  203. // CHECK:STDOUT: %.1bd: %.fef = cpp_overload_set_value @Int.as.ImplicitAs.impl.Convert [concrete = constants.%empty_struct.e92]
  204. // CHECK:STDOUT: %WithoutThunk.decl: %WithoutThunk.type = fn_decl @WithoutThunk [concrete = constants.%WithoutThunk] {
  205. // CHECK:STDOUT: <elided>
  206. // CHECK:STDOUT: } {
  207. // CHECK:STDOUT: <elided>
  208. // CHECK:STDOUT: }
  209. // CHECK:STDOUT: %Core.import_ref.ee7: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.340) = import_ref Core//prelude/parts/int, loc23_39, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.1c0)]
  210. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.9e9 = impl_witness_table (%Core.import_ref.ee7), @Core.IntLiteral.as.ImplicitAs.impl [concrete]
  211. // CHECK:STDOUT: %.c9b: %.281 = cpp_overload_set_value @ThunkOnArg [concrete = constants.%empty_struct.a11]
  212. // CHECK:STDOUT: %ThunkOnArg__carbon_thunk.decl: %ThunkOnArg__carbon_thunk.type = fn_decl @ThunkOnArg__carbon_thunk [concrete = constants.%ThunkOnArg__carbon_thunk] {
  213. // CHECK:STDOUT: <elided>
  214. // CHECK:STDOUT: } {
  215. // CHECK:STDOUT: <elided>
  216. // CHECK:STDOUT: }
  217. // CHECK:STDOUT: %Core.import_ref.d0f6: @Int.as.Copy.impl.%Int.as.Copy.impl.Op.type (%Int.as.Copy.impl.Op.type.afd) = import_ref Core//prelude/parts/int, loc17_31, loaded [symbolic = @Int.as.Copy.impl.%Int.as.Copy.impl.Op (constants.%Int.as.Copy.impl.Op.6cd)]
  218. // CHECK:STDOUT: %Copy.impl_witness_table.1ed = impl_witness_table (%Core.import_ref.d0f6), @Int.as.Copy.impl [concrete]
  219. // CHECK:STDOUT: %.d87: %.3ed = cpp_overload_set_value @ThunkOnArg__carbon_thunk [concrete = constants.%empty_struct.232]
  220. // CHECK:STDOUT: %ThunkOnReturn__carbon_thunk.decl: %ThunkOnReturn__carbon_thunk.type = fn_decl @ThunkOnReturn__carbon_thunk [concrete = constants.%ThunkOnReturn__carbon_thunk] {
  221. // CHECK:STDOUT: <elided>
  222. // CHECK:STDOUT: } {
  223. // CHECK:STDOUT: <elided>
  224. // CHECK:STDOUT: }
  225. // CHECK:STDOUT: %.db9: %.a8c = cpp_overload_set_value @Copy.Op [concrete = constants.%empty_struct.258]
  226. // CHECK:STDOUT: %ThunkOnBoth__carbon_thunk.decl: %ThunkOnBoth__carbon_thunk.type = fn_decl @ThunkOnBoth__carbon_thunk [concrete = constants.%ThunkOnBoth__carbon_thunk] {
  227. // CHECK:STDOUT: <elided>
  228. // CHECK:STDOUT: } {
  229. // CHECK:STDOUT: <elided>
  230. // CHECK:STDOUT: }
  231. // CHECK:STDOUT: }
  232. // CHECK:STDOUT:
  233. // CHECK:STDOUT: fn @MyF() {
  234. // CHECK:STDOUT: !entry:
  235. // CHECK:STDOUT: name_binding_decl {
  236. // CHECK:STDOUT: %r1.patt: %pattern_type.7ce = binding_pattern r1 [concrete]
  237. // CHECK:STDOUT: }
  238. // CHECK:STDOUT: %Cpp.ref.loc13: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  239. // CHECK:STDOUT: %WithoutThunk.ref: %.fef = name_ref WithoutThunk, imports.%.1bd [concrete = constants.%empty_struct.e92]
  240. // CHECK:STDOUT: %int_1.loc13: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  241. // CHECK:STDOUT: %impl.elem0.loc13: %.1df = impl_witness_access constants.%ImplicitAs.impl_witness.204, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.0f0]
  242. // CHECK:STDOUT: %bound_method.loc13_34.1: <bound method> = bound_method %int_1.loc13, %impl.elem0.loc13 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.abf]
  243. // CHECK:STDOUT: %specific_fn.loc13: <specific function> = specific_function %impl.elem0.loc13, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn.a29]
  244. // CHECK:STDOUT: %bound_method.loc13_34.2: <bound method> = bound_method %int_1.loc13, %specific_fn.loc13 [concrete = constants.%bound_method.c11]
  245. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc13: init %i32 = call %bound_method.loc13_34.2(%int_1.loc13) [concrete = constants.%int_1.5d2]
  246. // CHECK:STDOUT: %.loc13_34.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc13 [concrete = constants.%int_1.5d2]
  247. // CHECK:STDOUT: %.loc13_34.2: %i32 = converted %int_1.loc13, %.loc13_34.1 [concrete = constants.%int_1.5d2]
  248. // CHECK:STDOUT: %WithoutThunk.call: init %i32 = call imports.%WithoutThunk.decl(%.loc13_34.2)
  249. // CHECK:STDOUT: %.loc13_11: type = splice_block %i32.loc13 [concrete = constants.%i32] {
  250. // CHECK:STDOUT: %int_32.loc13: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  251. // CHECK:STDOUT: %i32.loc13: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  252. // CHECK:STDOUT: }
  253. // CHECK:STDOUT: %.loc13_35.1: %i32 = value_of_initializer %WithoutThunk.call
  254. // CHECK:STDOUT: %.loc13_35.2: %i32 = converted %WithoutThunk.call, %.loc13_35.1
  255. // CHECK:STDOUT: %r1: %i32 = bind_name r1, %.loc13_35.2
  256. // CHECK:STDOUT: name_binding_decl {
  257. // CHECK:STDOUT: %r2.patt: %pattern_type.7ce = binding_pattern r2 [concrete]
  258. // CHECK:STDOUT: }
  259. // CHECK:STDOUT: %Cpp.ref.loc14: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  260. // CHECK:STDOUT: %ThunkOnArg.ref: %.281 = name_ref ThunkOnArg, imports.%.c9b [concrete = constants.%empty_struct.a11]
  261. // CHECK:STDOUT: %int_1.loc14: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  262. // CHECK:STDOUT: %impl.elem0.loc14_32.1: %.ee2 = impl_witness_access constants.%ImplicitAs.impl_witness.ed0, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.4eb]
  263. // CHECK:STDOUT: %bound_method.loc14_32.1: <bound method> = bound_method %int_1.loc14, %impl.elem0.loc14_32.1 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.c97]
  264. // CHECK:STDOUT: %specific_fn.loc14_32.1: <specific function> = specific_function %impl.elem0.loc14_32.1, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_16) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn.810]
  265. // CHECK:STDOUT: %bound_method.loc14_32.2: <bound method> = bound_method %int_1.loc14, %specific_fn.loc14_32.1 [concrete = constants.%bound_method.a9b]
  266. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc14: init %i16 = call %bound_method.loc14_32.2(%int_1.loc14) [concrete = constants.%int_1.f90]
  267. // CHECK:STDOUT: %.loc14_32.1: %i16 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc14 [concrete = constants.%int_1.f90]
  268. // CHECK:STDOUT: %.loc14_32.2: %i16 = converted %int_1.loc14, %.loc14_32.1 [concrete = constants.%int_1.f90]
  269. // CHECK:STDOUT: %.loc14_32.3: ref %i16 = temporary_storage
  270. // CHECK:STDOUT: %impl.elem0.loc14_32.2: %.798 = impl_witness_access constants.%Copy.impl_witness.2f8, element0 [concrete = constants.%Int.as.Copy.impl.Op.3dc]
  271. // CHECK:STDOUT: %bound_method.loc14_32.3: <bound method> = bound_method %.loc14_32.2, %impl.elem0.loc14_32.2 [concrete = constants.%Int.as.Copy.impl.Op.bound]
  272. // CHECK:STDOUT: %specific_fn.loc14_32.2: <specific function> = specific_function %impl.elem0.loc14_32.2, @Int.as.Copy.impl.Op(constants.%int_16) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
  273. // CHECK:STDOUT: %bound_method.loc14_32.4: <bound method> = bound_method %.loc14_32.2, %specific_fn.loc14_32.2 [concrete = constants.%bound_method.7c2]
  274. // CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc14: init %i16 = call %bound_method.loc14_32.4(%.loc14_32.2) [concrete = constants.%int_1.f90]
  275. // CHECK:STDOUT: %.loc14_32.4: ref %i16 = temporary %.loc14_32.3, %Int.as.Copy.impl.Op.call.loc14
  276. // CHECK:STDOUT: %addr.loc14_33: %ptr.251 = addr_of %.loc14_32.4
  277. // CHECK:STDOUT: %ThunkOnArg__carbon_thunk.call: init %i32 = call imports.%ThunkOnArg__carbon_thunk.decl(%addr.loc14_33)
  278. // CHECK:STDOUT: %.loc14_11: type = splice_block %i32.loc14 [concrete = constants.%i32] {
  279. // CHECK:STDOUT: %int_32.loc14: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  280. // CHECK:STDOUT: %i32.loc14: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  281. // CHECK:STDOUT: }
  282. // CHECK:STDOUT: %.loc14_33.1: %i32 = value_of_initializer %ThunkOnArg__carbon_thunk.call
  283. // CHECK:STDOUT: %.loc14_33.2: %i32 = converted %ThunkOnArg__carbon_thunk.call, %.loc14_33.1
  284. // CHECK:STDOUT: %r2: %i32 = bind_name r2, %.loc14_33.2
  285. // CHECK:STDOUT: name_binding_decl {
  286. // CHECK:STDOUT: %r3.patt: %pattern_type.2f8 = binding_pattern r3 [concrete]
  287. // CHECK:STDOUT: }
  288. // CHECK:STDOUT: %Cpp.ref.loc15: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  289. // CHECK:STDOUT: %ThunkOnReturn.ref: %.3ed = name_ref ThunkOnReturn, imports.%.d87 [concrete = constants.%empty_struct.232]
  290. // CHECK:STDOUT: %int_1.loc15: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  291. // CHECK:STDOUT: %impl.elem0.loc15: %.1df = impl_witness_access constants.%ImplicitAs.impl_witness.204, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.0f0]
  292. // CHECK:STDOUT: %bound_method.loc15_35.1: <bound method> = bound_method %int_1.loc15, %impl.elem0.loc15 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.abf]
  293. // CHECK:STDOUT: %specific_fn.loc15: <specific function> = specific_function %impl.elem0.loc15, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn.a29]
  294. // CHECK:STDOUT: %bound_method.loc15_35.2: <bound method> = bound_method %int_1.loc15, %specific_fn.loc15 [concrete = constants.%bound_method.c11]
  295. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc15: init %i32 = call %bound_method.loc15_35.2(%int_1.loc15) [concrete = constants.%int_1.5d2]
  296. // CHECK:STDOUT: %.loc15_35.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc15 [concrete = constants.%int_1.5d2]
  297. // CHECK:STDOUT: %.loc15_35.2: %i32 = converted %int_1.loc15, %.loc15_35.1 [concrete = constants.%int_1.5d2]
  298. // CHECK:STDOUT: %.loc15_36.1: ref %i16 = temporary_storage
  299. // CHECK:STDOUT: %addr.loc15: %ptr.251 = addr_of %.loc15_36.1
  300. // CHECK:STDOUT: %ThunkOnReturn__carbon_thunk.call: init %empty_tuple.type = call imports.%ThunkOnReturn__carbon_thunk.decl(%.loc15_35.2, %addr.loc15)
  301. // CHECK:STDOUT: %.loc15_36.2: init %i16 = in_place_init %ThunkOnReturn__carbon_thunk.call, %.loc15_36.1
  302. // CHECK:STDOUT: %.loc15_11: type = splice_block %i16.loc15 [concrete = constants.%i16] {
  303. // CHECK:STDOUT: %int_16.loc15: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  304. // CHECK:STDOUT: %i16.loc15: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  305. // CHECK:STDOUT: }
  306. // CHECK:STDOUT: %.loc15_36.3: %i16 = value_of_initializer %.loc15_36.2
  307. // CHECK:STDOUT: %.loc15_36.4: %i16 = converted %.loc15_36.2, %.loc15_36.3
  308. // CHECK:STDOUT: %r3: %i16 = bind_name r3, %.loc15_36.4
  309. // CHECK:STDOUT: name_binding_decl {
  310. // CHECK:STDOUT: %r4.patt: %pattern_type.2f8 = binding_pattern r4 [concrete]
  311. // CHECK:STDOUT: }
  312. // CHECK:STDOUT: %Cpp.ref.loc16: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  313. // CHECK:STDOUT: %ThunkOnBoth.ref: %.a8c = name_ref ThunkOnBoth, imports.%.db9 [concrete = constants.%empty_struct.258]
  314. // CHECK:STDOUT: %int_1.loc16: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  315. // CHECK:STDOUT: %impl.elem0.loc16_33.1: %.ee2 = impl_witness_access constants.%ImplicitAs.impl_witness.ed0, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.4eb]
  316. // CHECK:STDOUT: %bound_method.loc16_33.1: <bound method> = bound_method %int_1.loc16, %impl.elem0.loc16_33.1 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.c97]
  317. // CHECK:STDOUT: %specific_fn.loc16_33.1: <specific function> = specific_function %impl.elem0.loc16_33.1, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_16) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn.810]
  318. // CHECK:STDOUT: %bound_method.loc16_33.2: <bound method> = bound_method %int_1.loc16, %specific_fn.loc16_33.1 [concrete = constants.%bound_method.a9b]
  319. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc16: init %i16 = call %bound_method.loc16_33.2(%int_1.loc16) [concrete = constants.%int_1.f90]
  320. // CHECK:STDOUT: %.loc16_33.1: %i16 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc16 [concrete = constants.%int_1.f90]
  321. // CHECK:STDOUT: %.loc16_33.2: %i16 = converted %int_1.loc16, %.loc16_33.1 [concrete = constants.%int_1.f90]
  322. // CHECK:STDOUT: %.loc16_33.3: ref %i16 = temporary_storage
  323. // CHECK:STDOUT: %impl.elem0.loc16_33.2: %.798 = impl_witness_access constants.%Copy.impl_witness.2f8, element0 [concrete = constants.%Int.as.Copy.impl.Op.3dc]
  324. // CHECK:STDOUT: %bound_method.loc16_33.3: <bound method> = bound_method %.loc16_33.2, %impl.elem0.loc16_33.2 [concrete = constants.%Int.as.Copy.impl.Op.bound]
  325. // CHECK:STDOUT: %specific_fn.loc16_33.2: <specific function> = specific_function %impl.elem0.loc16_33.2, @Int.as.Copy.impl.Op(constants.%int_16) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
  326. // CHECK:STDOUT: %bound_method.loc16_33.4: <bound method> = bound_method %.loc16_33.2, %specific_fn.loc16_33.2 [concrete = constants.%bound_method.7c2]
  327. // CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc16: init %i16 = call %bound_method.loc16_33.4(%.loc16_33.2) [concrete = constants.%int_1.f90]
  328. // CHECK:STDOUT: %.loc16_33.4: ref %i16 = temporary %.loc16_33.3, %Int.as.Copy.impl.Op.call.loc16
  329. // CHECK:STDOUT: %addr.loc16_34.1: %ptr.251 = addr_of %.loc16_33.4
  330. // CHECK:STDOUT: %.loc16_34.1: ref %i16 = temporary_storage
  331. // CHECK:STDOUT: %addr.loc16_34.2: %ptr.251 = addr_of %.loc16_34.1
  332. // CHECK:STDOUT: %ThunkOnBoth__carbon_thunk.call: init %empty_tuple.type = call imports.%ThunkOnBoth__carbon_thunk.decl(%addr.loc16_34.1, %addr.loc16_34.2)
  333. // CHECK:STDOUT: %.loc16_34.2: init %i16 = in_place_init %ThunkOnBoth__carbon_thunk.call, %.loc16_34.1
  334. // CHECK:STDOUT: %.loc16_11: type = splice_block %i16.loc16 [concrete = constants.%i16] {
  335. // CHECK:STDOUT: %int_16.loc16: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  336. // CHECK:STDOUT: %i16.loc16: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  337. // CHECK:STDOUT: }
  338. // CHECK:STDOUT: %.loc16_34.3: %i16 = value_of_initializer %.loc16_34.2
  339. // CHECK:STDOUT: %.loc16_34.4: %i16 = converted %.loc16_34.2, %.loc16_34.3
  340. // CHECK:STDOUT: %r4: %i16 = bind_name r4, %.loc16_34.4
  341. // CHECK:STDOUT: %Int.as.Destroy.impl.Op.bound.loc16: <bound method> = bound_method %.loc16_33.4, constants.%Int.as.Destroy.impl.Op.431
  342. // CHECK:STDOUT: <elided>
  343. // CHECK:STDOUT: %bound_method.loc16_33.5: <bound method> = bound_method %.loc16_33.4, %Int.as.Destroy.impl.Op.specific_fn.1
  344. // CHECK:STDOUT: %addr.loc16_33: %ptr.251 = addr_of %.loc16_33.4
  345. // CHECK:STDOUT: %Int.as.Destroy.impl.Op.call.loc16: init %empty_tuple.type = call %bound_method.loc16_33.5(%addr.loc16_33)
  346. // CHECK:STDOUT: %Int.as.Destroy.impl.Op.bound.loc14: <bound method> = bound_method %.loc14_32.4, constants.%Int.as.Destroy.impl.Op.431
  347. // CHECK:STDOUT: <elided>
  348. // CHECK:STDOUT: %bound_method.loc14_32.5: <bound method> = bound_method %.loc14_32.4, %Int.as.Destroy.impl.Op.specific_fn.2
  349. // CHECK:STDOUT: %addr.loc14_32: %ptr.251 = addr_of %.loc14_32.4
  350. // CHECK:STDOUT: %Int.as.Destroy.impl.Op.call.loc14: init %empty_tuple.type = call %bound_method.loc14_32.5(%addr.loc14_32)
  351. // CHECK:STDOUT: <elided>
  352. // CHECK:STDOUT: }
  353. // CHECK:STDOUT: