param_int16.carbon 49 KB

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