param_int16.carbon 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890
  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/param_int16.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/param_int16.carbon
  12. // ============================================================================
  13. // short
  14. // ============================================================================
  15. // --- short.h
  16. auto foo(short a) -> void;
  17. // --- import_short.carbon
  18. library "[[@TEST_NAME]]";
  19. import Cpp library "short.h";
  20. fn F() {
  21. //@dump-sem-ir-begin
  22. Cpp.foo(1 as i16);
  23. //@dump-sem-ir-end
  24. }
  25. // --- import_short_max.carbon
  26. library "[[@TEST_NAME]]";
  27. import Cpp library "short.h";
  28. fn F() {
  29. //@dump-sem-ir-begin
  30. Cpp.foo(0x7FFF);
  31. //@dump-sem-ir-end
  32. }
  33. // --- fail_import_short_overflow_max.carbon
  34. library "[[@TEST_NAME]]";
  35. import Cpp library "short.h";
  36. fn F() {
  37. // CHECK:STDERR: fail_import_short_overflow_max.carbon:[[@LINE+5]]:11: error: integer value 32768 too large for type `i16` [IntTooLargeForType]
  38. // CHECK:STDERR: Cpp.foo(0x8000);
  39. // CHECK:STDERR: ^~~~~~
  40. // CHECK:STDERR: fail_import_short_overflow_max.carbon: note: initializing function parameter [InCallToFunctionParam]
  41. // CHECK:STDERR:
  42. Cpp.foo(0x8000);
  43. }
  44. // --- import_short_min.carbon
  45. library "[[@TEST_NAME]]";
  46. import Cpp library "short.h";
  47. fn F() {
  48. //@dump-sem-ir-begin
  49. Cpp.foo(-0x8000);
  50. //@dump-sem-ir-end
  51. }
  52. // --- fail_import_short_overflow_min.carbon
  53. library "[[@TEST_NAME]]";
  54. import Cpp library "short.h";
  55. fn F() {
  56. // CHECK:STDERR: fail_import_short_overflow_min.carbon:[[@LINE+5]]:11: error: integer value -32769 too large for type `i16` [IntTooLargeForType]
  57. // CHECK:STDERR: Cpp.foo(-0x8001);
  58. // CHECK:STDERR: ^~~~~~~
  59. // CHECK:STDERR: fail_import_short_overflow_min.carbon: note: initializing function parameter [InCallToFunctionParam]
  60. // CHECK:STDERR:
  61. Cpp.foo(-0x8001);
  62. }
  63. // --- fail_import_short_int32_arg.carbon
  64. library "[[@TEST_NAME]]";
  65. import Cpp library "short.h";
  66. fn F() {
  67. // CHECK:STDERR: fail_import_short_int32_arg.carbon:[[@LINE+8]]:11: error: cannot implicitly convert expression of type `i32` to `i16` [ConversionFailure]
  68. // CHECK:STDERR: Cpp.foo(1 as i32);
  69. // CHECK:STDERR: ^~~~~~~~
  70. // CHECK:STDERR: fail_import_short_int32_arg.carbon:[[@LINE+5]]:11: note: type `i32` does not implement interface `Core.ImplicitAs(i16)` [MissingImplInMemberAccessNote]
  71. // CHECK:STDERR: Cpp.foo(1 as i32);
  72. // CHECK:STDERR: ^~~~~~~~
  73. // CHECK:STDERR: fail_import_short_int32_arg.carbon: note: initializing function parameter [InCallToFunctionParam]
  74. // CHECK:STDERR:
  75. Cpp.foo(1 as i32);
  76. }
  77. // ============================================================================
  78. // short int
  79. // ============================================================================
  80. // --- short_int.h
  81. auto foo(short int a) -> void;
  82. // --- import_short_int.carbon
  83. library "[[@TEST_NAME]]";
  84. import Cpp library "short_int.h";
  85. fn F() {
  86. //@dump-sem-ir-begin
  87. Cpp.foo(1 as i16);
  88. //@dump-sem-ir-end
  89. }
  90. // ============================================================================
  91. // signed short
  92. // ============================================================================
  93. // --- signed_short.h
  94. auto foo(signed short a) -> void;
  95. // --- import_signed_short.carbon
  96. library "[[@TEST_NAME]]";
  97. import Cpp library "signed_short.h";
  98. fn F() {
  99. //@dump-sem-ir-begin
  100. Cpp.foo(1 as i16);
  101. //@dump-sem-ir-end
  102. }
  103. // ============================================================================
  104. // signed short int
  105. // ============================================================================
  106. // --- signed_short_int.h
  107. auto foo(signed short int a) -> void;
  108. // --- import_signed_short_int.carbon
  109. library "[[@TEST_NAME]]";
  110. import Cpp library "signed_short_int.h";
  111. fn F() {
  112. //@dump-sem-ir-begin
  113. Cpp.foo(1 as i16);
  114. //@dump-sem-ir-end
  115. }
  116. // ============================================================================
  117. // typedef for short
  118. // ============================================================================
  119. // --- int16_t.h
  120. namespace std {
  121. // Mimicking glibc definition for int16_t: https://codebrowser.dev/glibc/glibc/posix/bits/types.h.html#__int16_t
  122. typedef signed short int int16_t;
  123. } // namespace std
  124. auto foo(std::int16_t a) -> void;
  125. // --- import_int16_t.carbon
  126. library "[[@TEST_NAME]]";
  127. import Cpp library "int16_t.h";
  128. fn F() {
  129. //@dump-sem-ir-begin
  130. Cpp.foo(1 as i16);
  131. //@dump-sem-ir-end
  132. }
  133. // ============================================================================
  134. // const short
  135. // ============================================================================
  136. // --- const_short.h
  137. auto foo(const short a) -> void;
  138. // --- import_const_short.carbon
  139. library "[[@TEST_NAME]]";
  140. import Cpp library "const_short.h";
  141. fn F() {
  142. //@dump-sem-ir-begin
  143. Cpp.foo(1 as i16);
  144. //@dump-sem-ir-end
  145. }
  146. // ============================================================================
  147. // short reference
  148. // ============================================================================
  149. // --- short_ref.h
  150. auto foo(short& a) -> void;
  151. // --- fail_todo_import_short_ref.carbon
  152. library "[[@TEST_NAME]]";
  153. import Cpp library "short_ref.h";
  154. fn F() {
  155. var a: i16 = 1;
  156. //@dump-sem-ir-begin
  157. // CHECK:STDERR: fail_todo_import_short_ref.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: short &` [SemanticsTodo]
  158. // CHECK:STDERR: Cpp.foo(a);
  159. // CHECK:STDERR: ^~~~~~~
  160. // CHECK:STDERR: fail_todo_import_short_ref.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup]
  161. // CHECK:STDERR: Cpp.foo(a);
  162. // CHECK:STDERR: ^~~~~~~
  163. // CHECK:STDERR:
  164. Cpp.foo(a);
  165. //@dump-sem-ir-end
  166. }
  167. // ============================================================================
  168. // const short reference
  169. // ============================================================================
  170. // --- const_short_ref.h
  171. auto foo(const short& a) -> void;
  172. // --- fail_todo_import_const_short_ref.carbon
  173. library "[[@TEST_NAME]]";
  174. import Cpp library "const_short_ref.h";
  175. fn F() {
  176. var a: i16 = 1;
  177. //@dump-sem-ir-begin
  178. // CHECK:STDERR: fail_todo_import_const_short_ref.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: const short &` [SemanticsTodo]
  179. // CHECK:STDERR: Cpp.foo(a);
  180. // CHECK:STDERR: ^~~~~~~
  181. // CHECK:STDERR: fail_todo_import_const_short_ref.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup]
  182. // CHECK:STDERR: Cpp.foo(a);
  183. // CHECK:STDERR: ^~~~~~~
  184. // CHECK:STDERR:
  185. Cpp.foo(a);
  186. //@dump-sem-ir-end
  187. }
  188. // ============================================================================
  189. // short pointer
  190. // ============================================================================
  191. // --- short_pointer.h
  192. auto foo(short* _Nonnull a) -> void;
  193. // --- import_short_pointer.carbon
  194. library "[[@TEST_NAME]]";
  195. import Cpp library "short_pointer.h";
  196. fn F() {
  197. var a: i16 = 1;
  198. //@dump-sem-ir-begin
  199. Cpp.foo(&a);
  200. //@dump-sem-ir-end
  201. }
  202. // ============================================================================
  203. // const short pointer
  204. // ============================================================================
  205. // --- const_short_pointer.h
  206. auto foo(const short* _Nonnull a) -> void;
  207. // --- import_const_short_pointer.carbon
  208. library "[[@TEST_NAME]]";
  209. import Cpp library "const_short_pointer.h";
  210. fn F() {
  211. var a: i16 = 1;
  212. //@dump-sem-ir-begin
  213. Cpp.foo(&a);
  214. //@dump-sem-ir-end
  215. }
  216. // CHECK:STDOUT: --- import_short.carbon
  217. // CHECK:STDOUT:
  218. // CHECK:STDOUT: constants {
  219. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  220. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  221. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  222. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  223. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  224. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  225. // CHECK:STDOUT: %As.type.a96: type = facet_type <@As, @As(%i16)> [concrete]
  226. // CHECK:STDOUT: %Convert.type.be5: type = fn_type @Convert.1, @As(%i16) [concrete]
  227. // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  228. // CHECK:STDOUT: %Convert.type.062: type = fn_type @Convert.5, @impl.686(%To) [symbolic]
  229. // CHECK:STDOUT: %Convert.527: %Convert.type.062 = struct_value () [symbolic]
  230. // CHECK:STDOUT: %As.impl_witness.0ef: <witness> = impl_witness imports.%As.impl_witness_table.eb4, @impl.686(%int_16) [concrete]
  231. // CHECK:STDOUT: %Convert.type.172: type = fn_type @Convert.5, @impl.686(%int_16) [concrete]
  232. // CHECK:STDOUT: %Convert.489: %Convert.type.172 = struct_value () [concrete]
  233. // CHECK:STDOUT: %As.facet: %As.type.a96 = facet_value Core.IntLiteral, (%As.impl_witness.0ef) [concrete]
  234. // CHECK:STDOUT: %.91d: type = fn_type_with_self_type %Convert.type.be5, %As.facet [concrete]
  235. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.489 [concrete]
  236. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.489, @Convert.5(%int_16) [concrete]
  237. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  238. // CHECK:STDOUT: %int_1.f90: %i16 = int_value 1 [concrete]
  239. // CHECK:STDOUT: }
  240. // CHECK:STDOUT:
  241. // CHECK:STDOUT: imports {
  242. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  243. // CHECK:STDOUT: .foo = %foo.decl
  244. // CHECK:STDOUT: import Cpp//...
  245. // CHECK:STDOUT: }
  246. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  247. // CHECK:STDOUT: <elided>
  248. // CHECK:STDOUT: } {
  249. // CHECK:STDOUT: <elided>
  250. // CHECK:STDOUT: }
  251. // CHECK:STDOUT: %Core.import_ref.78a: @impl.686.%Convert.type (%Convert.type.062) = import_ref Core//prelude/parts/int, loc25_39, loaded [symbolic = @impl.686.%Convert (constants.%Convert.527)]
  252. // CHECK:STDOUT: %As.impl_witness_table.eb4 = impl_witness_table (%Core.import_ref.78a), @impl.686 [concrete]
  253. // CHECK:STDOUT: }
  254. // CHECK:STDOUT:
  255. // CHECK:STDOUT: fn @F() {
  256. // CHECK:STDOUT: !entry:
  257. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  258. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  259. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  260. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  261. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  262. // CHECK:STDOUT: %impl.elem0: %.91d = impl_witness_access constants.%As.impl_witness.0ef, element0 [concrete = constants.%Convert.489]
  263. // CHECK:STDOUT: %bound_method.loc8_13.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  264. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.5(constants.%int_16) [concrete = constants.%Convert.specific_fn]
  265. // CHECK:STDOUT: %bound_method.loc8_13.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  266. // CHECK:STDOUT: %int.convert_checked: init %i16 = call %bound_method.loc8_13.2(%int_1) [concrete = constants.%int_1.f90]
  267. // CHECK:STDOUT: %.loc8_13.1: %i16 = value_of_initializer %int.convert_checked [concrete = constants.%int_1.f90]
  268. // CHECK:STDOUT: %.loc8_13.2: %i16 = converted %int_1, %.loc8_13.1 [concrete = constants.%int_1.f90]
  269. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc8_13.2)
  270. // CHECK:STDOUT: <elided>
  271. // CHECK:STDOUT: }
  272. // CHECK:STDOUT:
  273. // CHECK:STDOUT: --- import_short_max.carbon
  274. // CHECK:STDOUT:
  275. // CHECK:STDOUT: constants {
  276. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  277. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  278. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  279. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  280. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  281. // CHECK:STDOUT: %int_32767.f4b: Core.IntLiteral = int_value 32767 [concrete]
  282. // CHECK:STDOUT: %ImplicitAs.type.adb: type = facet_type <@ImplicitAs, @ImplicitAs(%i16)> [concrete]
  283. // CHECK:STDOUT: %Convert.type.fa6: type = fn_type @Convert.1, @ImplicitAs(%i16) [concrete]
  284. // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  285. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To) [symbolic]
  286. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  287. // CHECK:STDOUT: %ImplicitAs.impl_witness.97b: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_16) [concrete]
  288. // CHECK:STDOUT: %Convert.type.33c: type = fn_type @Convert.2, @impl.4f9(%int_16) [concrete]
  289. // CHECK:STDOUT: %Convert.d0a: %Convert.type.33c = struct_value () [concrete]
  290. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.adb = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.97b) [concrete]
  291. // CHECK:STDOUT: %.236: type = fn_type_with_self_type %Convert.type.fa6, %ImplicitAs.facet [concrete]
  292. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_32767.f4b, %Convert.d0a [concrete]
  293. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.d0a, @Convert.2(%int_16) [concrete]
  294. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_32767.f4b, %Convert.specific_fn [concrete]
  295. // CHECK:STDOUT: %int_32767.faa: %i16 = int_value 32767 [concrete]
  296. // CHECK:STDOUT: }
  297. // CHECK:STDOUT:
  298. // CHECK:STDOUT: imports {
  299. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  300. // CHECK:STDOUT: .foo = %foo.decl
  301. // CHECK:STDOUT: import Cpp//...
  302. // CHECK:STDOUT: }
  303. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  304. // CHECK:STDOUT: <elided>
  305. // CHECK:STDOUT: } {
  306. // CHECK:STDOUT: <elided>
  307. // CHECK:STDOUT: }
  308. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/parts/int, loc16_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  309. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  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: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  316. // CHECK:STDOUT: %int_32767: Core.IntLiteral = int_value 32767 [concrete = constants.%int_32767.f4b]
  317. // CHECK:STDOUT: %impl.elem0: %.236 = impl_witness_access constants.%ImplicitAs.impl_witness.97b, element0 [concrete = constants.%Convert.d0a]
  318. // CHECK:STDOUT: %bound_method.loc8_11.1: <bound method> = bound_method %int_32767, %impl.elem0 [concrete = constants.%Convert.bound]
  319. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_16) [concrete = constants.%Convert.specific_fn]
  320. // CHECK:STDOUT: %bound_method.loc8_11.2: <bound method> = bound_method %int_32767, %specific_fn [concrete = constants.%bound_method]
  321. // CHECK:STDOUT: %int.convert_checked: init %i16 = call %bound_method.loc8_11.2(%int_32767) [concrete = constants.%int_32767.faa]
  322. // CHECK:STDOUT: %.loc8_11.1: %i16 = value_of_initializer %int.convert_checked [concrete = constants.%int_32767.faa]
  323. // CHECK:STDOUT: %.loc8_11.2: %i16 = converted %int_32767, %.loc8_11.1 [concrete = constants.%int_32767.faa]
  324. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc8_11.2)
  325. // CHECK:STDOUT: <elided>
  326. // CHECK:STDOUT: }
  327. // CHECK:STDOUT:
  328. // CHECK:STDOUT: --- import_short_min.carbon
  329. // CHECK:STDOUT:
  330. // CHECK:STDOUT: constants {
  331. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  332. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  333. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  334. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  335. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  336. // CHECK:STDOUT: %int_32768: Core.IntLiteral = int_value 32768 [concrete]
  337. // CHECK:STDOUT: %Negate.type: type = facet_type <@Negate> [concrete]
  338. // CHECK:STDOUT: %Op.type.e42: type = fn_type @Op.1 [concrete]
  339. // CHECK:STDOUT: %Negate.impl_witness.973: <witness> = impl_witness imports.%Negate.impl_witness_table.b22 [concrete]
  340. // CHECK:STDOUT: %Negate.facet: %Negate.type = facet_value Core.IntLiteral, (%Negate.impl_witness.973) [concrete]
  341. // CHECK:STDOUT: %.d3d: type = fn_type_with_self_type %Op.type.e42, %Negate.facet [concrete]
  342. // CHECK:STDOUT: %Op.type.18a: type = fn_type @Op.2 [concrete]
  343. // CHECK:STDOUT: %Op.99f: %Op.type.18a = struct_value () [concrete]
  344. // CHECK:STDOUT: %Op.bound: <bound method> = bound_method %int_32768, %Op.99f [concrete]
  345. // CHECK:STDOUT: %int_-32768.882: Core.IntLiteral = int_value -32768 [concrete]
  346. // CHECK:STDOUT: %ImplicitAs.type.adb: type = facet_type <@ImplicitAs, @ImplicitAs(%i16)> [concrete]
  347. // CHECK:STDOUT: %Convert.type.fa6: type = fn_type @Convert.1, @ImplicitAs(%i16) [concrete]
  348. // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  349. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To) [symbolic]
  350. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  351. // CHECK:STDOUT: %ImplicitAs.impl_witness.97b: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_16) [concrete]
  352. // CHECK:STDOUT: %Convert.type.33c: type = fn_type @Convert.2, @impl.4f9(%int_16) [concrete]
  353. // CHECK:STDOUT: %Convert.d0a: %Convert.type.33c = struct_value () [concrete]
  354. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.adb = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.97b) [concrete]
  355. // CHECK:STDOUT: %.236: type = fn_type_with_self_type %Convert.type.fa6, %ImplicitAs.facet [concrete]
  356. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_-32768.882, %Convert.d0a [concrete]
  357. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.d0a, @Convert.2(%int_16) [concrete]
  358. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_-32768.882, %Convert.specific_fn [concrete]
  359. // CHECK:STDOUT: %int_-32768.7e5: %i16 = int_value -32768 [concrete]
  360. // CHECK:STDOUT: }
  361. // CHECK:STDOUT:
  362. // CHECK:STDOUT: imports {
  363. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  364. // CHECK:STDOUT: .foo = %foo.decl
  365. // CHECK:STDOUT: import Cpp//...
  366. // CHECK:STDOUT: }
  367. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  368. // CHECK:STDOUT: <elided>
  369. // CHECK:STDOUT: } {
  370. // CHECK:STDOUT: <elided>
  371. // CHECK:STDOUT: }
  372. // CHECK:STDOUT: %Core.import_ref.abd = import_ref Core//prelude/parts/int_literal, loc13_50, unloaded
  373. // CHECK:STDOUT: %Core.import_ref.5e6: %Op.type.18a = import_ref Core//prelude/parts/int_literal, loc14_31, loaded [concrete = constants.%Op.99f]
  374. // CHECK:STDOUT: %Negate.impl_witness_table.b22 = impl_witness_table (%Core.import_ref.abd, %Core.import_ref.5e6), @impl.0ef [concrete]
  375. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/parts/int, loc16_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  376. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  377. // CHECK:STDOUT: }
  378. // CHECK:STDOUT:
  379. // CHECK:STDOUT: fn @F() {
  380. // CHECK:STDOUT: !entry:
  381. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  382. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  383. // CHECK:STDOUT: %int_32768: Core.IntLiteral = int_value 32768 [concrete = constants.%int_32768]
  384. // CHECK:STDOUT: %impl.elem1: %.d3d = impl_witness_access constants.%Negate.impl_witness.973, element1 [concrete = constants.%Op.99f]
  385. // CHECK:STDOUT: %bound_method.loc8_11.1: <bound method> = bound_method %int_32768, %impl.elem1 [concrete = constants.%Op.bound]
  386. // CHECK:STDOUT: %int.snegate: init Core.IntLiteral = call %bound_method.loc8_11.1(%int_32768) [concrete = constants.%int_-32768.882]
  387. // CHECK:STDOUT: %impl.elem0: %.236 = impl_witness_access constants.%ImplicitAs.impl_witness.97b, element0 [concrete = constants.%Convert.d0a]
  388. // CHECK:STDOUT: %bound_method.loc8_11.2: <bound method> = bound_method %int.snegate, %impl.elem0 [concrete = constants.%Convert.bound]
  389. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_16) [concrete = constants.%Convert.specific_fn]
  390. // CHECK:STDOUT: %bound_method.loc8_11.3: <bound method> = bound_method %int.snegate, %specific_fn [concrete = constants.%bound_method]
  391. // CHECK:STDOUT: %.loc8_11.1: Core.IntLiteral = value_of_initializer %int.snegate [concrete = constants.%int_-32768.882]
  392. // CHECK:STDOUT: %.loc8_11.2: Core.IntLiteral = converted %int.snegate, %.loc8_11.1 [concrete = constants.%int_-32768.882]
  393. // CHECK:STDOUT: %int.convert_checked: init %i16 = call %bound_method.loc8_11.3(%.loc8_11.2) [concrete = constants.%int_-32768.7e5]
  394. // CHECK:STDOUT: %.loc8_11.3: %i16 = value_of_initializer %int.convert_checked [concrete = constants.%int_-32768.7e5]
  395. // CHECK:STDOUT: %.loc8_11.4: %i16 = converted %int.snegate, %.loc8_11.3 [concrete = constants.%int_-32768.7e5]
  396. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc8_11.4)
  397. // CHECK:STDOUT: <elided>
  398. // CHECK:STDOUT: }
  399. // CHECK:STDOUT:
  400. // CHECK:STDOUT: --- import_short_int.carbon
  401. // CHECK:STDOUT:
  402. // CHECK:STDOUT: constants {
  403. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  404. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  405. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  406. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  407. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  408. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  409. // CHECK:STDOUT: %As.type.a96: type = facet_type <@As, @As(%i16)> [concrete]
  410. // CHECK:STDOUT: %Convert.type.be5: type = fn_type @Convert.1, @As(%i16) [concrete]
  411. // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  412. // CHECK:STDOUT: %Convert.type.062: type = fn_type @Convert.5, @impl.686(%To) [symbolic]
  413. // CHECK:STDOUT: %Convert.527: %Convert.type.062 = struct_value () [symbolic]
  414. // CHECK:STDOUT: %As.impl_witness.0ef: <witness> = impl_witness imports.%As.impl_witness_table.eb4, @impl.686(%int_16) [concrete]
  415. // CHECK:STDOUT: %Convert.type.172: type = fn_type @Convert.5, @impl.686(%int_16) [concrete]
  416. // CHECK:STDOUT: %Convert.489: %Convert.type.172 = struct_value () [concrete]
  417. // CHECK:STDOUT: %As.facet: %As.type.a96 = facet_value Core.IntLiteral, (%As.impl_witness.0ef) [concrete]
  418. // CHECK:STDOUT: %.91d: type = fn_type_with_self_type %Convert.type.be5, %As.facet [concrete]
  419. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.489 [concrete]
  420. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.489, @Convert.5(%int_16) [concrete]
  421. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  422. // CHECK:STDOUT: %int_1.f90: %i16 = int_value 1 [concrete]
  423. // CHECK:STDOUT: }
  424. // CHECK:STDOUT:
  425. // CHECK:STDOUT: imports {
  426. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  427. // CHECK:STDOUT: .foo = %foo.decl
  428. // CHECK:STDOUT: import Cpp//...
  429. // CHECK:STDOUT: }
  430. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  431. // CHECK:STDOUT: <elided>
  432. // CHECK:STDOUT: } {
  433. // CHECK:STDOUT: <elided>
  434. // CHECK:STDOUT: }
  435. // CHECK:STDOUT: %Core.import_ref.78a: @impl.686.%Convert.type (%Convert.type.062) = import_ref Core//prelude/parts/int, loc25_39, loaded [symbolic = @impl.686.%Convert (constants.%Convert.527)]
  436. // CHECK:STDOUT: %As.impl_witness_table.eb4 = impl_witness_table (%Core.import_ref.78a), @impl.686 [concrete]
  437. // CHECK:STDOUT: }
  438. // CHECK:STDOUT:
  439. // CHECK:STDOUT: fn @F() {
  440. // CHECK:STDOUT: !entry:
  441. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  442. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  443. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  444. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  445. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  446. // CHECK:STDOUT: %impl.elem0: %.91d = impl_witness_access constants.%As.impl_witness.0ef, element0 [concrete = constants.%Convert.489]
  447. // CHECK:STDOUT: %bound_method.loc8_13.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  448. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.5(constants.%int_16) [concrete = constants.%Convert.specific_fn]
  449. // CHECK:STDOUT: %bound_method.loc8_13.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  450. // CHECK:STDOUT: %int.convert_checked: init %i16 = call %bound_method.loc8_13.2(%int_1) [concrete = constants.%int_1.f90]
  451. // CHECK:STDOUT: %.loc8_13.1: %i16 = value_of_initializer %int.convert_checked [concrete = constants.%int_1.f90]
  452. // CHECK:STDOUT: %.loc8_13.2: %i16 = converted %int_1, %.loc8_13.1 [concrete = constants.%int_1.f90]
  453. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc8_13.2)
  454. // CHECK:STDOUT: <elided>
  455. // CHECK:STDOUT: }
  456. // CHECK:STDOUT:
  457. // CHECK:STDOUT: --- import_signed_short.carbon
  458. // CHECK:STDOUT:
  459. // CHECK:STDOUT: constants {
  460. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  461. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  462. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  463. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  464. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  465. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  466. // CHECK:STDOUT: %As.type.a96: type = facet_type <@As, @As(%i16)> [concrete]
  467. // CHECK:STDOUT: %Convert.type.be5: type = fn_type @Convert.1, @As(%i16) [concrete]
  468. // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  469. // CHECK:STDOUT: %Convert.type.062: type = fn_type @Convert.5, @impl.686(%To) [symbolic]
  470. // CHECK:STDOUT: %Convert.527: %Convert.type.062 = struct_value () [symbolic]
  471. // CHECK:STDOUT: %As.impl_witness.0ef: <witness> = impl_witness imports.%As.impl_witness_table.eb4, @impl.686(%int_16) [concrete]
  472. // CHECK:STDOUT: %Convert.type.172: type = fn_type @Convert.5, @impl.686(%int_16) [concrete]
  473. // CHECK:STDOUT: %Convert.489: %Convert.type.172 = struct_value () [concrete]
  474. // CHECK:STDOUT: %As.facet: %As.type.a96 = facet_value Core.IntLiteral, (%As.impl_witness.0ef) [concrete]
  475. // CHECK:STDOUT: %.91d: type = fn_type_with_self_type %Convert.type.be5, %As.facet [concrete]
  476. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.489 [concrete]
  477. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.489, @Convert.5(%int_16) [concrete]
  478. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  479. // CHECK:STDOUT: %int_1.f90: %i16 = int_value 1 [concrete]
  480. // CHECK:STDOUT: }
  481. // CHECK:STDOUT:
  482. // CHECK:STDOUT: imports {
  483. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  484. // CHECK:STDOUT: .foo = %foo.decl
  485. // CHECK:STDOUT: import Cpp//...
  486. // CHECK:STDOUT: }
  487. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  488. // CHECK:STDOUT: <elided>
  489. // CHECK:STDOUT: } {
  490. // CHECK:STDOUT: <elided>
  491. // CHECK:STDOUT: }
  492. // CHECK:STDOUT: %Core.import_ref.78a: @impl.686.%Convert.type (%Convert.type.062) = import_ref Core//prelude/parts/int, loc25_39, loaded [symbolic = @impl.686.%Convert (constants.%Convert.527)]
  493. // CHECK:STDOUT: %As.impl_witness_table.eb4 = impl_witness_table (%Core.import_ref.78a), @impl.686 [concrete]
  494. // CHECK:STDOUT: }
  495. // CHECK:STDOUT:
  496. // CHECK:STDOUT: fn @F() {
  497. // CHECK:STDOUT: !entry:
  498. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  499. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  500. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  501. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  502. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  503. // CHECK:STDOUT: %impl.elem0: %.91d = impl_witness_access constants.%As.impl_witness.0ef, element0 [concrete = constants.%Convert.489]
  504. // CHECK:STDOUT: %bound_method.loc8_13.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  505. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.5(constants.%int_16) [concrete = constants.%Convert.specific_fn]
  506. // CHECK:STDOUT: %bound_method.loc8_13.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  507. // CHECK:STDOUT: %int.convert_checked: init %i16 = call %bound_method.loc8_13.2(%int_1) [concrete = constants.%int_1.f90]
  508. // CHECK:STDOUT: %.loc8_13.1: %i16 = value_of_initializer %int.convert_checked [concrete = constants.%int_1.f90]
  509. // CHECK:STDOUT: %.loc8_13.2: %i16 = converted %int_1, %.loc8_13.1 [concrete = constants.%int_1.f90]
  510. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc8_13.2)
  511. // CHECK:STDOUT: <elided>
  512. // CHECK:STDOUT: }
  513. // CHECK:STDOUT:
  514. // CHECK:STDOUT: --- import_signed_short_int.carbon
  515. // CHECK:STDOUT:
  516. // CHECK:STDOUT: constants {
  517. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  518. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  519. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  520. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  521. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  522. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  523. // CHECK:STDOUT: %As.type.a96: type = facet_type <@As, @As(%i16)> [concrete]
  524. // CHECK:STDOUT: %Convert.type.be5: type = fn_type @Convert.1, @As(%i16) [concrete]
  525. // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  526. // CHECK:STDOUT: %Convert.type.062: type = fn_type @Convert.5, @impl.686(%To) [symbolic]
  527. // CHECK:STDOUT: %Convert.527: %Convert.type.062 = struct_value () [symbolic]
  528. // CHECK:STDOUT: %As.impl_witness.0ef: <witness> = impl_witness imports.%As.impl_witness_table.eb4, @impl.686(%int_16) [concrete]
  529. // CHECK:STDOUT: %Convert.type.172: type = fn_type @Convert.5, @impl.686(%int_16) [concrete]
  530. // CHECK:STDOUT: %Convert.489: %Convert.type.172 = struct_value () [concrete]
  531. // CHECK:STDOUT: %As.facet: %As.type.a96 = facet_value Core.IntLiteral, (%As.impl_witness.0ef) [concrete]
  532. // CHECK:STDOUT: %.91d: type = fn_type_with_self_type %Convert.type.be5, %As.facet [concrete]
  533. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.489 [concrete]
  534. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.489, @Convert.5(%int_16) [concrete]
  535. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  536. // CHECK:STDOUT: %int_1.f90: %i16 = int_value 1 [concrete]
  537. // CHECK:STDOUT: }
  538. // CHECK:STDOUT:
  539. // CHECK:STDOUT: imports {
  540. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  541. // CHECK:STDOUT: .foo = %foo.decl
  542. // CHECK:STDOUT: import Cpp//...
  543. // CHECK:STDOUT: }
  544. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  545. // CHECK:STDOUT: <elided>
  546. // CHECK:STDOUT: } {
  547. // CHECK:STDOUT: <elided>
  548. // CHECK:STDOUT: }
  549. // CHECK:STDOUT: %Core.import_ref.78a: @impl.686.%Convert.type (%Convert.type.062) = import_ref Core//prelude/parts/int, loc25_39, loaded [symbolic = @impl.686.%Convert (constants.%Convert.527)]
  550. // CHECK:STDOUT: %As.impl_witness_table.eb4 = impl_witness_table (%Core.import_ref.78a), @impl.686 [concrete]
  551. // CHECK:STDOUT: }
  552. // CHECK:STDOUT:
  553. // CHECK:STDOUT: fn @F() {
  554. // CHECK:STDOUT: !entry:
  555. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  556. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  557. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  558. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  559. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  560. // CHECK:STDOUT: %impl.elem0: %.91d = impl_witness_access constants.%As.impl_witness.0ef, element0 [concrete = constants.%Convert.489]
  561. // CHECK:STDOUT: %bound_method.loc8_13.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  562. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.5(constants.%int_16) [concrete = constants.%Convert.specific_fn]
  563. // CHECK:STDOUT: %bound_method.loc8_13.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  564. // CHECK:STDOUT: %int.convert_checked: init %i16 = call %bound_method.loc8_13.2(%int_1) [concrete = constants.%int_1.f90]
  565. // CHECK:STDOUT: %.loc8_13.1: %i16 = value_of_initializer %int.convert_checked [concrete = constants.%int_1.f90]
  566. // CHECK:STDOUT: %.loc8_13.2: %i16 = converted %int_1, %.loc8_13.1 [concrete = constants.%int_1.f90]
  567. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc8_13.2)
  568. // CHECK:STDOUT: <elided>
  569. // CHECK:STDOUT: }
  570. // CHECK:STDOUT:
  571. // CHECK:STDOUT: --- import_int16_t.carbon
  572. // CHECK:STDOUT:
  573. // CHECK:STDOUT: constants {
  574. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  575. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  576. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  577. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  578. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  579. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  580. // CHECK:STDOUT: %As.type.a96: type = facet_type <@As, @As(%i16)> [concrete]
  581. // CHECK:STDOUT: %Convert.type.be5: type = fn_type @Convert.1, @As(%i16) [concrete]
  582. // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  583. // CHECK:STDOUT: %Convert.type.062: type = fn_type @Convert.5, @impl.686(%To) [symbolic]
  584. // CHECK:STDOUT: %Convert.527: %Convert.type.062 = struct_value () [symbolic]
  585. // CHECK:STDOUT: %As.impl_witness.0ef: <witness> = impl_witness imports.%As.impl_witness_table.eb4, @impl.686(%int_16) [concrete]
  586. // CHECK:STDOUT: %Convert.type.172: type = fn_type @Convert.5, @impl.686(%int_16) [concrete]
  587. // CHECK:STDOUT: %Convert.489: %Convert.type.172 = struct_value () [concrete]
  588. // CHECK:STDOUT: %As.facet: %As.type.a96 = facet_value Core.IntLiteral, (%As.impl_witness.0ef) [concrete]
  589. // CHECK:STDOUT: %.91d: type = fn_type_with_self_type %Convert.type.be5, %As.facet [concrete]
  590. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.489 [concrete]
  591. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.489, @Convert.5(%int_16) [concrete]
  592. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  593. // CHECK:STDOUT: %int_1.f90: %i16 = int_value 1 [concrete]
  594. // CHECK:STDOUT: }
  595. // CHECK:STDOUT:
  596. // CHECK:STDOUT: imports {
  597. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  598. // CHECK:STDOUT: .foo = %foo.decl
  599. // CHECK:STDOUT: import Cpp//...
  600. // CHECK:STDOUT: }
  601. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  602. // CHECK:STDOUT: <elided>
  603. // CHECK:STDOUT: } {
  604. // CHECK:STDOUT: <elided>
  605. // CHECK:STDOUT: }
  606. // CHECK:STDOUT: %Core.import_ref.78a: @impl.686.%Convert.type (%Convert.type.062) = import_ref Core//prelude/parts/int, loc25_39, loaded [symbolic = @impl.686.%Convert (constants.%Convert.527)]
  607. // CHECK:STDOUT: %As.impl_witness_table.eb4 = impl_witness_table (%Core.import_ref.78a), @impl.686 [concrete]
  608. // CHECK:STDOUT: }
  609. // CHECK:STDOUT:
  610. // CHECK:STDOUT: fn @F() {
  611. // CHECK:STDOUT: !entry:
  612. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  613. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  614. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  615. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  616. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  617. // CHECK:STDOUT: %impl.elem0: %.91d = impl_witness_access constants.%As.impl_witness.0ef, element0 [concrete = constants.%Convert.489]
  618. // CHECK:STDOUT: %bound_method.loc8_13.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  619. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.5(constants.%int_16) [concrete = constants.%Convert.specific_fn]
  620. // CHECK:STDOUT: %bound_method.loc8_13.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  621. // CHECK:STDOUT: %int.convert_checked: init %i16 = call %bound_method.loc8_13.2(%int_1) [concrete = constants.%int_1.f90]
  622. // CHECK:STDOUT: %.loc8_13.1: %i16 = value_of_initializer %int.convert_checked [concrete = constants.%int_1.f90]
  623. // CHECK:STDOUT: %.loc8_13.2: %i16 = converted %int_1, %.loc8_13.1 [concrete = constants.%int_1.f90]
  624. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc8_13.2)
  625. // CHECK:STDOUT: <elided>
  626. // CHECK:STDOUT: }
  627. // CHECK:STDOUT:
  628. // CHECK:STDOUT: --- import_const_short.carbon
  629. // CHECK:STDOUT:
  630. // CHECK:STDOUT: constants {
  631. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  632. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  633. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  634. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  635. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  636. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  637. // CHECK:STDOUT: %As.type.a96: type = facet_type <@As, @As(%i16)> [concrete]
  638. // CHECK:STDOUT: %Convert.type.be5: type = fn_type @Convert.1, @As(%i16) [concrete]
  639. // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  640. // CHECK:STDOUT: %Convert.type.062: type = fn_type @Convert.5, @impl.686(%To) [symbolic]
  641. // CHECK:STDOUT: %Convert.527: %Convert.type.062 = struct_value () [symbolic]
  642. // CHECK:STDOUT: %As.impl_witness.0ef: <witness> = impl_witness imports.%As.impl_witness_table.eb4, @impl.686(%int_16) [concrete]
  643. // CHECK:STDOUT: %Convert.type.172: type = fn_type @Convert.5, @impl.686(%int_16) [concrete]
  644. // CHECK:STDOUT: %Convert.489: %Convert.type.172 = struct_value () [concrete]
  645. // CHECK:STDOUT: %As.facet: %As.type.a96 = facet_value Core.IntLiteral, (%As.impl_witness.0ef) [concrete]
  646. // CHECK:STDOUT: %.91d: type = fn_type_with_self_type %Convert.type.be5, %As.facet [concrete]
  647. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.489 [concrete]
  648. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.489, @Convert.5(%int_16) [concrete]
  649. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  650. // CHECK:STDOUT: %int_1.f90: %i16 = int_value 1 [concrete]
  651. // CHECK:STDOUT: }
  652. // CHECK:STDOUT:
  653. // CHECK:STDOUT: imports {
  654. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  655. // CHECK:STDOUT: .foo = %foo.decl
  656. // CHECK:STDOUT: import Cpp//...
  657. // CHECK:STDOUT: }
  658. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  659. // CHECK:STDOUT: <elided>
  660. // CHECK:STDOUT: } {
  661. // CHECK:STDOUT: <elided>
  662. // CHECK:STDOUT: }
  663. // CHECK:STDOUT: %Core.import_ref.78a: @impl.686.%Convert.type (%Convert.type.062) = import_ref Core//prelude/parts/int, loc25_39, loaded [symbolic = @impl.686.%Convert (constants.%Convert.527)]
  664. // CHECK:STDOUT: %As.impl_witness_table.eb4 = impl_witness_table (%Core.import_ref.78a), @impl.686 [concrete]
  665. // CHECK:STDOUT: }
  666. // CHECK:STDOUT:
  667. // CHECK:STDOUT: fn @F() {
  668. // CHECK:STDOUT: !entry:
  669. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  670. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  671. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  672. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  673. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  674. // CHECK:STDOUT: %impl.elem0: %.91d = impl_witness_access constants.%As.impl_witness.0ef, element0 [concrete = constants.%Convert.489]
  675. // CHECK:STDOUT: %bound_method.loc8_13.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  676. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.5(constants.%int_16) [concrete = constants.%Convert.specific_fn]
  677. // CHECK:STDOUT: %bound_method.loc8_13.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  678. // CHECK:STDOUT: %int.convert_checked: init %i16 = call %bound_method.loc8_13.2(%int_1) [concrete = constants.%int_1.f90]
  679. // CHECK:STDOUT: %.loc8_13.1: %i16 = value_of_initializer %int.convert_checked [concrete = constants.%int_1.f90]
  680. // CHECK:STDOUT: %.loc8_13.2: %i16 = converted %int_1, %.loc8_13.1 [concrete = constants.%int_1.f90]
  681. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc8_13.2)
  682. // CHECK:STDOUT: <elided>
  683. // CHECK:STDOUT: }
  684. // CHECK:STDOUT:
  685. // CHECK:STDOUT: --- fail_todo_import_short_ref.carbon
  686. // CHECK:STDOUT:
  687. // CHECK:STDOUT: constants {
  688. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  689. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  690. // CHECK:STDOUT: }
  691. // CHECK:STDOUT:
  692. // CHECK:STDOUT: imports {
  693. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  694. // CHECK:STDOUT: .foo = <error>
  695. // CHECK:STDOUT: import Cpp//...
  696. // CHECK:STDOUT: }
  697. // CHECK:STDOUT: }
  698. // CHECK:STDOUT:
  699. // CHECK:STDOUT: fn @F() {
  700. // CHECK:STDOUT: !entry:
  701. // CHECK:STDOUT: <elided>
  702. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  703. // CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>]
  704. // CHECK:STDOUT: %a.ref: ref %i16 = name_ref a, %a
  705. // CHECK:STDOUT: <elided>
  706. // CHECK:STDOUT: }
  707. // CHECK:STDOUT:
  708. // CHECK:STDOUT: --- fail_todo_import_const_short_ref.carbon
  709. // CHECK:STDOUT:
  710. // CHECK:STDOUT: constants {
  711. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  712. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  713. // CHECK:STDOUT: }
  714. // CHECK:STDOUT:
  715. // CHECK:STDOUT: imports {
  716. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  717. // CHECK:STDOUT: .foo = <error>
  718. // CHECK:STDOUT: import Cpp//...
  719. // CHECK:STDOUT: }
  720. // CHECK:STDOUT: }
  721. // CHECK:STDOUT:
  722. // CHECK:STDOUT: fn @F() {
  723. // CHECK:STDOUT: !entry:
  724. // CHECK:STDOUT: <elided>
  725. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  726. // CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>]
  727. // CHECK:STDOUT: %a.ref: ref %i16 = name_ref a, %a
  728. // CHECK:STDOUT: <elided>
  729. // CHECK:STDOUT: }
  730. // CHECK:STDOUT:
  731. // CHECK:STDOUT: --- import_short_pointer.carbon
  732. // CHECK:STDOUT:
  733. // CHECK:STDOUT: constants {
  734. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  735. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  736. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  737. // CHECK:STDOUT: %ptr.251: type = ptr_type %i16 [concrete]
  738. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  739. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  740. // CHECK:STDOUT: }
  741. // CHECK:STDOUT:
  742. // CHECK:STDOUT: imports {
  743. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  744. // CHECK:STDOUT: .foo = %foo.decl
  745. // CHECK:STDOUT: import Cpp//...
  746. // CHECK:STDOUT: }
  747. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  748. // CHECK:STDOUT: <elided>
  749. // CHECK:STDOUT: } {
  750. // CHECK:STDOUT: <elided>
  751. // CHECK:STDOUT: }
  752. // CHECK:STDOUT: }
  753. // CHECK:STDOUT:
  754. // CHECK:STDOUT: fn @F() {
  755. // CHECK:STDOUT: !entry:
  756. // CHECK:STDOUT: <elided>
  757. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  758. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  759. // CHECK:STDOUT: %a.ref: ref %i16 = name_ref a, %a
  760. // CHECK:STDOUT: %addr.loc9: %ptr.251 = addr_of %a.ref
  761. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%addr.loc9)
  762. // CHECK:STDOUT: <elided>
  763. // CHECK:STDOUT: }
  764. // CHECK:STDOUT:
  765. // CHECK:STDOUT: --- import_const_short_pointer.carbon
  766. // CHECK:STDOUT:
  767. // CHECK:STDOUT: constants {
  768. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  769. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  770. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  771. // CHECK:STDOUT: %ptr.251: type = ptr_type %i16 [concrete]
  772. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  773. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  774. // CHECK:STDOUT: }
  775. // CHECK:STDOUT:
  776. // CHECK:STDOUT: imports {
  777. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  778. // CHECK:STDOUT: .foo = %foo.decl
  779. // CHECK:STDOUT: import Cpp//...
  780. // CHECK:STDOUT: }
  781. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {
  782. // CHECK:STDOUT: <elided>
  783. // CHECK:STDOUT: } {
  784. // CHECK:STDOUT: <elided>
  785. // CHECK:STDOUT: }
  786. // CHECK:STDOUT: }
  787. // CHECK:STDOUT:
  788. // CHECK:STDOUT: fn @F() {
  789. // CHECK:STDOUT: !entry:
  790. // CHECK:STDOUT: <elided>
  791. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  792. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  793. // CHECK:STDOUT: %a.ref: ref %i16 = name_ref a, %a
  794. // CHECK:STDOUT: %addr.loc9: %ptr.251 = addr_of %a.ref
  795. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%addr.loc9)
  796. // CHECK:STDOUT: <elided>
  797. // CHECK:STDOUT: }
  798. // CHECK:STDOUT: