function.carbon 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  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/function/function.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/function.carbon
  12. // ============================================================================
  13. // Global
  14. // ============================================================================
  15. // --- global.h
  16. auto foo() -> void;
  17. // --- import_global.carbon
  18. library "[[@TEST_NAME]]";
  19. import Cpp library "global.h";
  20. fn MyF() {
  21. //@dump-sem-ir-begin
  22. Cpp.foo();
  23. //@dump-sem-ir-end
  24. }
  25. // --- fail_import_global_use_different_name.carbon
  26. library "[[@TEST_NAME]]";
  27. import Cpp library "global.h";
  28. fn MyF() {
  29. // CHECK:STDERR: fail_import_global_use_different_name.carbon:[[@LINE+4]]:3: error: member name `bar` not found in `Cpp` [MemberNameNotFoundInInstScope]
  30. // CHECK:STDERR: Cpp.bar();
  31. // CHECK:STDERR: ^~~~~~~
  32. // CHECK:STDERR:
  33. Cpp.bar();
  34. }
  35. // ============================================================================
  36. // Carbon keyword name
  37. // ============================================================================
  38. // --- special_name.h
  39. auto base() -> void;
  40. // --- fail_import_special_name_call_unescaped.carbon
  41. library "[[@TEST_NAME]]";
  42. import Cpp library "special_name.h";
  43. fn MyF() {
  44. // CHECK:STDERR: fail_import_special_name_call_unescaped.carbon:[[@LINE+4]]:3: error: member name `base` not found in `Cpp` [MemberNameNotFoundInInstScope]
  45. // CHECK:STDERR: Cpp.base();
  46. // CHECK:STDERR: ^~~~~~~~
  47. // CHECK:STDERR:
  48. Cpp.base();
  49. }
  50. // --- import_special_name_call_escaped.carbon
  51. library "[[@TEST_NAME]]";
  52. import Cpp library "special_name.h";
  53. fn MyF() {
  54. //@dump-sem-ir-begin
  55. Cpp.r#base();
  56. //@dump-sem-ir-end
  57. }
  58. // ============================================================================
  59. // Overloaded
  60. // ============================================================================
  61. // --- overloaded.h
  62. auto foo() -> void;
  63. auto foo(int value) -> void;
  64. // --- import_overloaded.carbon
  65. library "[[@TEST_NAME]]";
  66. import Cpp library "overloaded.h";
  67. fn F() {
  68. //@dump-sem-ir-begin
  69. Cpp.foo();
  70. //@dump-sem-ir-end
  71. }
  72. // ============================================================================
  73. // Variadic arguments
  74. // ============================================================================
  75. // --- variadic.h
  76. auto foo(int x, ...) -> void;
  77. // --- fail_todo_import_variadic.carbon
  78. library "[[@TEST_NAME]]";
  79. import Cpp library "variadic.h";
  80. fn F() {
  81. //@dump-sem-ir-begin
  82. // CHECK:STDERR: fail_todo_import_variadic.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: Variadic function` [SemanticsTodo]
  83. // CHECK:STDERR: Cpp.foo(8);
  84. // CHECK:STDERR: ^~~~~~~~~~
  85. // CHECK:STDERR: fail_todo_import_variadic.carbon:[[@LINE+4]]:3: note: in call to Cpp function here [InCallToCppFunction]
  86. // CHECK:STDERR: Cpp.foo(8);
  87. // CHECK:STDERR: ^~~~~~~~~~
  88. // CHECK:STDERR:
  89. Cpp.foo(8);
  90. //@dump-sem-ir-end
  91. }
  92. // ============================================================================
  93. // Static
  94. // ============================================================================
  95. // --- static.h
  96. static auto foo() -> void;
  97. // --- import_static.carbon
  98. library "[[@TEST_NAME]]";
  99. import Cpp library "static.h";
  100. fn F() {
  101. //@dump-sem-ir-begin
  102. // TODO: We should eventually warn or error that `Cpp.foo` has internal
  103. // linkage but is not defined.
  104. Cpp.foo();
  105. //@dump-sem-ir-end
  106. }
  107. // --- template_function.h
  108. template<typename T>
  109. auto foo(T a) -> void;
  110. template<typename T>
  111. auto bar(T a) -> T;
  112. // --- import_template_function.carbon
  113. library "[[@TEST_NAME]]";
  114. import Cpp library "template_function.h";
  115. fn F() {
  116. //@dump-sem-ir-begin
  117. Cpp.foo(1 as i32);
  118. //@dump-sem-ir-end
  119. }
  120. fn G() -> i32 {
  121. //@dump-sem-ir-begin
  122. return Cpp.bar(1 as i32);
  123. //@dump-sem-ir-end
  124. }
  125. // TODO: Add a test per unsupported param type. See https://github.com/carbon-language/carbon-lang/pull/5477/files/4321e21ed27d987fd71be182d292973fd9849df8#r2094655176
  126. // TODO: Add a test per unsupported return type. See https://github.com/carbon-language/carbon-lang/pull/5477/files/4321e21ed27d987fd71be182d292973fd9849df8#r2094655176
  127. // CHECK:STDOUT: --- import_global.carbon
  128. // CHECK:STDOUT:
  129. // CHECK:STDOUT: constants {
  130. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  131. // CHECK:STDOUT: %.c5d: type = cpp_overload_set_type @foo [concrete]
  132. // CHECK:STDOUT: %empty_struct: %.c5d = struct_value () [concrete]
  133. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  134. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  135. // CHECK:STDOUT: }
  136. // CHECK:STDOUT:
  137. // CHECK:STDOUT: imports {
  138. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  139. // CHECK:STDOUT: .foo = %.a21
  140. // CHECK:STDOUT: import Cpp//...
  141. // CHECK:STDOUT: }
  142. // CHECK:STDOUT: %.a21: %.c5d = cpp_overload_set_value @foo [concrete = constants.%empty_struct]
  143. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {} {}
  144. // CHECK:STDOUT: }
  145. // CHECK:STDOUT:
  146. // CHECK:STDOUT: fn @MyF() {
  147. // CHECK:STDOUT: !entry:
  148. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  149. // CHECK:STDOUT: %foo.ref: %.c5d = name_ref foo, imports.%.a21 [concrete = constants.%empty_struct]
  150. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call imports.%foo.decl()
  151. // CHECK:STDOUT: <elided>
  152. // CHECK:STDOUT: }
  153. // CHECK:STDOUT:
  154. // CHECK:STDOUT: --- import_special_name_call_escaped.carbon
  155. // CHECK:STDOUT:
  156. // CHECK:STDOUT: constants {
  157. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  158. // CHECK:STDOUT: %.f7d: type = cpp_overload_set_type @base [concrete]
  159. // CHECK:STDOUT: %empty_struct: %.f7d = struct_value () [concrete]
  160. // CHECK:STDOUT: %base.type: type = fn_type @base [concrete]
  161. // CHECK:STDOUT: %base: %base.type = struct_value () [concrete]
  162. // CHECK:STDOUT: }
  163. // CHECK:STDOUT:
  164. // CHECK:STDOUT: imports {
  165. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  166. // CHECK:STDOUT: .r#base = %.6f0
  167. // CHECK:STDOUT: import Cpp//...
  168. // CHECK:STDOUT: }
  169. // CHECK:STDOUT: %.6f0: %.f7d = cpp_overload_set_value @base [concrete = constants.%empty_struct]
  170. // CHECK:STDOUT: %base.decl: %base.type = fn_decl @base [concrete = constants.%base] {} {}
  171. // CHECK:STDOUT: }
  172. // CHECK:STDOUT:
  173. // CHECK:STDOUT: fn @MyF() {
  174. // CHECK:STDOUT: !entry:
  175. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  176. // CHECK:STDOUT: %base.ref: %.f7d = name_ref r#base, imports.%.6f0 [concrete = constants.%empty_struct]
  177. // CHECK:STDOUT: %base.call: init %empty_tuple.type = call imports.%base.decl()
  178. // CHECK:STDOUT: <elided>
  179. // CHECK:STDOUT: }
  180. // CHECK:STDOUT:
  181. // CHECK:STDOUT: --- import_overloaded.carbon
  182. // CHECK:STDOUT:
  183. // CHECK:STDOUT: constants {
  184. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  185. // CHECK:STDOUT: %.c5d: type = cpp_overload_set_type @foo [concrete]
  186. // CHECK:STDOUT: %empty_struct: %.c5d = struct_value () [concrete]
  187. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  188. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  189. // CHECK:STDOUT: }
  190. // CHECK:STDOUT:
  191. // CHECK:STDOUT: imports {
  192. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  193. // CHECK:STDOUT: .foo = %.a21
  194. // CHECK:STDOUT: import Cpp//...
  195. // CHECK:STDOUT: }
  196. // CHECK:STDOUT: %.a21: %.c5d = cpp_overload_set_value @foo [concrete = constants.%empty_struct]
  197. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {} {}
  198. // CHECK:STDOUT: }
  199. // CHECK:STDOUT:
  200. // CHECK:STDOUT: fn @F() {
  201. // CHECK:STDOUT: !entry:
  202. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  203. // CHECK:STDOUT: %foo.ref: %.c5d = name_ref foo, imports.%.a21 [concrete = constants.%empty_struct]
  204. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call imports.%foo.decl()
  205. // CHECK:STDOUT: <elided>
  206. // CHECK:STDOUT: }
  207. // CHECK:STDOUT:
  208. // CHECK:STDOUT: --- fail_todo_import_variadic.carbon
  209. // CHECK:STDOUT:
  210. // CHECK:STDOUT: constants {
  211. // CHECK:STDOUT: %.c5d: type = cpp_overload_set_type @<null name> [concrete]
  212. // CHECK:STDOUT: %empty_struct: %.c5d = struct_value () [concrete]
  213. // CHECK:STDOUT: %int_8: Core.IntLiteral = int_value 8 [concrete]
  214. // CHECK:STDOUT: }
  215. // CHECK:STDOUT:
  216. // CHECK:STDOUT: imports {
  217. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  218. // CHECK:STDOUT: .foo = %.a21
  219. // CHECK:STDOUT: import Cpp//...
  220. // CHECK:STDOUT: }
  221. // CHECK:STDOUT: %.a21: %.c5d = cpp_overload_set_value @<null name> [concrete = constants.%empty_struct]
  222. // CHECK:STDOUT: }
  223. // CHECK:STDOUT:
  224. // CHECK:STDOUT: fn @F() {
  225. // CHECK:STDOUT: !entry:
  226. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  227. // CHECK:STDOUT: %foo.ref: %.c5d = name_ref foo, imports.%.a21 [concrete = constants.%empty_struct]
  228. // CHECK:STDOUT: %int_8: Core.IntLiteral = int_value 8 [concrete = constants.%int_8]
  229. // CHECK:STDOUT: <elided>
  230. // CHECK:STDOUT: }
  231. // CHECK:STDOUT:
  232. // CHECK:STDOUT: --- import_static.carbon
  233. // CHECK:STDOUT:
  234. // CHECK:STDOUT: constants {
  235. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  236. // CHECK:STDOUT: %.c5d: type = cpp_overload_set_type @foo [concrete]
  237. // CHECK:STDOUT: %empty_struct: %.c5d = struct_value () [concrete]
  238. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  239. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  240. // CHECK:STDOUT: }
  241. // CHECK:STDOUT:
  242. // CHECK:STDOUT: imports {
  243. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  244. // CHECK:STDOUT: .foo = %.a21
  245. // CHECK:STDOUT: import Cpp//...
  246. // CHECK:STDOUT: }
  247. // CHECK:STDOUT: %.a21: %.c5d = cpp_overload_set_value @foo [concrete = constants.%empty_struct]
  248. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {} {}
  249. // CHECK:STDOUT: }
  250. // CHECK:STDOUT:
  251. // CHECK:STDOUT: fn @F() {
  252. // CHECK:STDOUT: !entry:
  253. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  254. // CHECK:STDOUT: %foo.ref: %.c5d = name_ref foo, imports.%.a21 [concrete = constants.%empty_struct]
  255. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call imports.%foo.decl()
  256. // CHECK:STDOUT: <elided>
  257. // CHECK:STDOUT: }
  258. // CHECK:STDOUT:
  259. // CHECK:STDOUT: --- import_template_function.carbon
  260. // CHECK:STDOUT:
  261. // CHECK:STDOUT: constants {
  262. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  263. // CHECK:STDOUT: %.c5d: type = cpp_overload_set_type @Core.IntLiteral.as.As.impl.Convert [concrete]
  264. // CHECK:STDOUT: %empty_struct.109: %.c5d = struct_value () [concrete]
  265. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  266. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  267. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  268. // CHECK:STDOUT: %As.type.dbd: type = facet_type <@As, @As(%i32)> [concrete]
  269. // CHECK:STDOUT: %As.Convert.type.99b: type = fn_type @As.Convert, @As(%i32) [concrete]
  270. // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  271. // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.565: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%To) [symbolic]
  272. // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.d2c: %Core.IntLiteral.as.As.impl.Convert.type.565 = struct_value () [symbolic]
  273. // CHECK:STDOUT: %As.impl_witness.080: <witness> = impl_witness imports.%As.impl_witness_table.5ad, @Core.IntLiteral.as.As.impl(%int_32) [concrete]
  274. // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.aaf: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%int_32) [concrete]
  275. // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.414: %Core.IntLiteral.as.As.impl.Convert.type.aaf = struct_value () [concrete]
  276. // CHECK:STDOUT: %As.facet: %As.type.dbd = facet_value Core.IntLiteral, (%As.impl_witness.080) [concrete]
  277. // CHECK:STDOUT: %.351: type = fn_type_with_self_type %As.Convert.type.99b, %As.facet [concrete]
  278. // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.bound: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.414 [concrete]
  279. // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.specific_fn: <specific function> = specific_function %Core.IntLiteral.as.As.impl.Convert.414, @Core.IntLiteral.as.As.impl.Convert(%int_32) [concrete]
  280. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.specific_fn [concrete]
  281. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  282. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  283. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  284. // CHECK:STDOUT: %.414: type = cpp_overload_set_type @Int.as.As.impl.Convert [concrete]
  285. // CHECK:STDOUT: %empty_struct.540: %.414 = struct_value () [concrete]
  286. // CHECK:STDOUT: %bar.type: type = fn_type @bar [concrete]
  287. // CHECK:STDOUT: %bar: %bar.type = struct_value () [concrete]
  288. // CHECK:STDOUT: }
  289. // CHECK:STDOUT:
  290. // CHECK:STDOUT: imports {
  291. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  292. // CHECK:STDOUT: .foo = %.a21
  293. // CHECK:STDOUT: .bar = %.146
  294. // CHECK:STDOUT: import Cpp//...
  295. // CHECK:STDOUT: }
  296. // CHECK:STDOUT: %.a21: %.c5d = cpp_overload_set_value @Core.IntLiteral.as.As.impl.Convert [concrete = constants.%empty_struct.109]
  297. // CHECK:STDOUT: %Core.import_ref.99c: @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.565) = import_ref Core//prelude/parts/int, loc32_39, loaded [symbolic = @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.d2c)]
  298. // CHECK:STDOUT: %As.impl_witness_table.5ad = impl_witness_table (%Core.import_ref.99c), @Core.IntLiteral.as.As.impl [concrete]
  299. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  300. // CHECK:STDOUT: <elided>
  301. // CHECK:STDOUT: } {
  302. // CHECK:STDOUT: <elided>
  303. // CHECK:STDOUT: }
  304. // CHECK:STDOUT: %.146: %.414 = cpp_overload_set_value @Int.as.As.impl.Convert [concrete = constants.%empty_struct.540]
  305. // CHECK:STDOUT: %bar.decl: %bar.type = fn_decl @bar [concrete = constants.%bar] {
  306. // CHECK:STDOUT: <elided>
  307. // CHECK:STDOUT: } {
  308. // CHECK:STDOUT: <elided>
  309. // CHECK:STDOUT: }
  310. // CHECK:STDOUT: }
  311. // CHECK:STDOUT:
  312. // CHECK:STDOUT: fn @F() {
  313. // CHECK:STDOUT: !entry:
  314. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  315. // CHECK:STDOUT: %foo.ref: %.c5d = name_ref foo, imports.%.a21 [concrete = constants.%empty_struct.109]
  316. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  317. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  318. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  319. // CHECK:STDOUT: %impl.elem0: %.351 = impl_witness_access constants.%As.impl_witness.080, element0 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.414]
  320. // CHECK:STDOUT: %bound_method.loc8_13.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.bound]
  321. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Core.IntLiteral.as.As.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.specific_fn]
  322. // CHECK:STDOUT: %bound_method.loc8_13.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  323. // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call: init %i32 = call %bound_method.loc8_13.2(%int_1) [concrete = constants.%int_1.5d2]
  324. // CHECK:STDOUT: %.loc8_13.1: %i32 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call [concrete = constants.%int_1.5d2]
  325. // CHECK:STDOUT: %.loc8_13.2: %i32 = converted %int_1, %.loc8_13.1 [concrete = constants.%int_1.5d2]
  326. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call imports.%foo.decl(%.loc8_13.2)
  327. // CHECK:STDOUT: <elided>
  328. // CHECK:STDOUT: }
  329. // CHECK:STDOUT:
  330. // CHECK:STDOUT: fn @G() -> %i32 {
  331. // CHECK:STDOUT: !entry:
  332. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  333. // CHECK:STDOUT: %bar.ref: %.414 = name_ref bar, imports.%.146 [concrete = constants.%empty_struct.540]
  334. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  335. // CHECK:STDOUT: %int_32.loc14: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  336. // CHECK:STDOUT: %i32.loc14: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  337. // CHECK:STDOUT: %impl.elem0: %.351 = impl_witness_access constants.%As.impl_witness.080, element0 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.414]
  338. // CHECK:STDOUT: %bound_method.loc14_20.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.bound]
  339. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Core.IntLiteral.as.As.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.specific_fn]
  340. // CHECK:STDOUT: %bound_method.loc14_20.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  341. // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call: init %i32 = call %bound_method.loc14_20.2(%int_1) [concrete = constants.%int_1.5d2]
  342. // CHECK:STDOUT: %.loc14_20.1: %i32 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call [concrete = constants.%int_1.5d2]
  343. // CHECK:STDOUT: %.loc14_20.2: %i32 = converted %int_1, %.loc14_20.1 [concrete = constants.%int_1.5d2]
  344. // CHECK:STDOUT: %bar.call: init %i32 = call imports.%bar.decl(%.loc14_20.2)
  345. // CHECK:STDOUT: return %bar.call to %return
  346. // CHECK:STDOUT: }
  347. // CHECK:STDOUT: