function_param_int16.carbon 98 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601
  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. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interop/cpp/function_param_int16.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interop/cpp/function_param_int16.carbon
  13. // ============================================================================
  14. // short
  15. // ============================================================================
  16. // --- short.h
  17. auto foo(short a) -> void;
  18. // --- import_short.carbon
  19. library "[[@TEST_NAME]]";
  20. import Cpp library "short.h";
  21. fn F() {
  22. Cpp.foo(1 as i16);
  23. }
  24. // --- import_short_max.carbon
  25. library "[[@TEST_NAME]]";
  26. import Cpp library "short.h";
  27. fn F() {
  28. Cpp.foo(0x7FFF);
  29. }
  30. // --- fail_import_short_overflow_max.carbon
  31. library "[[@TEST_NAME]]";
  32. import Cpp library "short.h";
  33. fn F() {
  34. // CHECK:STDERR: fail_import_short_overflow_max.carbon:[[@LINE+5]]:11: error: integer value 32768 too large for type `i16` [IntTooLargeForType]
  35. // CHECK:STDERR: Cpp.foo(0x8000);
  36. // CHECK:STDERR: ^~~~~~
  37. // CHECK:STDERR: fail_import_short_overflow_max.carbon: note: initializing function parameter [InCallToFunctionParam]
  38. // CHECK:STDERR:
  39. Cpp.foo(0x8000);
  40. }
  41. // --- import_short_min.carbon
  42. library "[[@TEST_NAME]]";
  43. import Cpp library "short.h";
  44. fn F() {
  45. Cpp.foo(-0x8000);
  46. }
  47. // --- fail_import_short_overflow_min.carbon
  48. library "[[@TEST_NAME]]";
  49. import Cpp library "short.h";
  50. fn F() {
  51. // CHECK:STDERR: fail_import_short_overflow_min.carbon:[[@LINE+5]]:11: error: integer value -32769 too large for type `i16` [IntTooLargeForType]
  52. // CHECK:STDERR: Cpp.foo(-0x8001);
  53. // CHECK:STDERR: ^~~~~~~
  54. // CHECK:STDERR: fail_import_short_overflow_min.carbon: note: initializing function parameter [InCallToFunctionParam]
  55. // CHECK:STDERR:
  56. Cpp.foo(-0x8001);
  57. }
  58. // --- fail_import_short_int32_arg.carbon
  59. library "[[@TEST_NAME]]";
  60. import Cpp library "short.h";
  61. fn F() {
  62. // CHECK:STDERR: fail_import_short_int32_arg.carbon:[[@LINE+8]]:11: error: cannot implicitly convert expression of type `i32` to `i16` [ConversionFailure]
  63. // CHECK:STDERR: Cpp.foo(1 as i32);
  64. // CHECK:STDERR: ^~~~~~~~
  65. // CHECK:STDERR: fail_import_short_int32_arg.carbon:[[@LINE+5]]:11: note: type `i32` does not implement interface `Core.ImplicitAs(i16)` [MissingImplInMemberAccessNote]
  66. // CHECK:STDERR: Cpp.foo(1 as i32);
  67. // CHECK:STDERR: ^~~~~~~~
  68. // CHECK:STDERR: fail_import_short_int32_arg.carbon: note: initializing function parameter [InCallToFunctionParam]
  69. // CHECK:STDERR:
  70. Cpp.foo(1 as i32);
  71. }
  72. // ============================================================================
  73. // short int
  74. // ============================================================================
  75. // --- short_int.h
  76. auto foo(short int a) -> void;
  77. // --- import_short_int.carbon
  78. library "[[@TEST_NAME]]";
  79. import Cpp library "short_int.h";
  80. fn F() {
  81. Cpp.foo(1 as i16);
  82. }
  83. // ============================================================================
  84. // signed short
  85. // ============================================================================
  86. // --- signed_short.h
  87. auto foo(signed short a) -> void;
  88. // --- import_signed_short.carbon
  89. library "[[@TEST_NAME]]";
  90. import Cpp library "signed_short.h";
  91. fn F() {
  92. Cpp.foo(1 as i16);
  93. }
  94. // ============================================================================
  95. // signed short int
  96. // ============================================================================
  97. // --- signed_short_int.h
  98. auto foo(signed short int a) -> void;
  99. // --- import_signed_short_int.carbon
  100. library "[[@TEST_NAME]]";
  101. import Cpp library "signed_short_int.h";
  102. fn F() {
  103. Cpp.foo(1 as i16);
  104. }
  105. // ============================================================================
  106. // int16_t
  107. // ============================================================================
  108. // --- int16_t.h
  109. namespace std {
  110. // Mimicking glibc definition for int16_t: https://codebrowser.dev/glibc/glibc/posix/bits/types.h.html#__int16_t
  111. typedef signed short int int16_t;
  112. } // namespace std
  113. auto foo(std::int16_t a) -> void;
  114. // --- import_int16_t.carbon
  115. library "[[@TEST_NAME]]";
  116. import Cpp library "int16_t.h";
  117. fn F() {
  118. Cpp.foo(1 as i16);
  119. }
  120. // ============================================================================
  121. // const short
  122. // ============================================================================
  123. // --- const_short.h
  124. auto foo(const short a) -> void;
  125. // --- import_const_short.carbon
  126. library "[[@TEST_NAME]]";
  127. import Cpp library "const_short.h";
  128. fn F() {
  129. Cpp.foo(1 as i16);
  130. }
  131. // ============================================================================
  132. // short reference
  133. // ============================================================================
  134. // --- short_ref.h
  135. auto foo(short& a) -> void;
  136. // --- fail_todo_import_short_ref.carbon
  137. library "[[@TEST_NAME]]";
  138. import Cpp library "short_ref.h";
  139. fn F() {
  140. var a: i16 = 1;
  141. // CHECK:STDERR: fail_todo_import_short_ref.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: short &` [SemanticsTodo]
  142. // CHECK:STDERR: Cpp.foo(a);
  143. // CHECK:STDERR: ^~~~~~~
  144. // CHECK:STDERR: fail_todo_import_short_ref.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup]
  145. // CHECK:STDERR: Cpp.foo(a);
  146. // CHECK:STDERR: ^~~~~~~
  147. // CHECK:STDERR:
  148. Cpp.foo(a);
  149. }
  150. // ============================================================================
  151. // const short reference
  152. // ============================================================================
  153. // --- const_short_ref.h
  154. auto foo(const short& a) -> void;
  155. // --- fail_todo_import_const_short_ref.carbon
  156. library "[[@TEST_NAME]]";
  157. import Cpp library "const_short_ref.h";
  158. fn F() {
  159. var a: i16 = 1;
  160. // CHECK:STDERR: fail_todo_import_const_short_ref.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: const short &` [SemanticsTodo]
  161. // CHECK:STDERR: Cpp.foo(a);
  162. // CHECK:STDERR: ^~~~~~~
  163. // CHECK:STDERR: fail_todo_import_const_short_ref.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup]
  164. // CHECK:STDERR: Cpp.foo(a);
  165. // CHECK:STDERR: ^~~~~~~
  166. // CHECK:STDERR:
  167. Cpp.foo(a);
  168. }
  169. // ============================================================================
  170. // short pointer
  171. // ============================================================================
  172. // --- short_pointer.h
  173. auto foo(short* a) -> void;
  174. // --- fail_todo_import_short_pointer.carbon
  175. library "[[@TEST_NAME]]";
  176. import Cpp library "short_pointer.h";
  177. fn F() {
  178. var a: i16 = 1;
  179. // CHECK:STDERR: fail_todo_import_short_pointer.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: short *` [SemanticsTodo]
  180. // CHECK:STDERR: Cpp.foo(&a);
  181. // CHECK:STDERR: ^~~~~~~
  182. // CHECK:STDERR: fail_todo_import_short_pointer.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup]
  183. // CHECK:STDERR: Cpp.foo(&a);
  184. // CHECK:STDERR: ^~~~~~~
  185. // CHECK:STDERR:
  186. Cpp.foo(&a);
  187. }
  188. // ============================================================================
  189. // const short pointer
  190. // ============================================================================
  191. // --- const_short_pointer.h
  192. auto foo(const short* a) -> void;
  193. // --- fail_todo_import_const_short_pointer.carbon
  194. library "[[@TEST_NAME]]";
  195. import Cpp library "const_short_pointer.h";
  196. fn F() {
  197. var a: i16 = 1;
  198. // CHECK:STDERR: fail_todo_import_const_short_pointer.carbon:[[@LINE+7]]:3: error: semantics TODO: `Unsupported: parameter type: const short *` [SemanticsTodo]
  199. // CHECK:STDERR: Cpp.foo(&a);
  200. // CHECK:STDERR: ^~~~~~~
  201. // CHECK:STDERR: fail_todo_import_const_short_pointer.carbon:[[@LINE+4]]:3: note: in `Cpp` name lookup for `foo` [InCppNameLookup]
  202. // CHECK:STDERR: Cpp.foo(&a);
  203. // CHECK:STDERR: ^~~~~~~
  204. // CHECK:STDERR:
  205. Cpp.foo(&a);
  206. }
  207. // CHECK:STDOUT: --- import_short.carbon
  208. // CHECK:STDOUT:
  209. // CHECK:STDOUT: constants {
  210. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  211. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  212. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  213. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  214. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  215. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  216. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  217. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  218. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  219. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  220. // CHECK:STDOUT: %As.type.90f: type = generic_interface_type @As [concrete]
  221. // CHECK:STDOUT: %As.generic: %As.type.90f = struct_value () [concrete]
  222. // CHECK:STDOUT: %As.type.a96: type = facet_type <@As, @As(%i16)> [concrete]
  223. // CHECK:STDOUT: %Convert.type.be5: type = fn_type @Convert.1, @As(%i16) [concrete]
  224. // CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  225. // CHECK:STDOUT: %Convert.type.062: type = fn_type @Convert.5, @impl.686(%To.c80) [symbolic]
  226. // CHECK:STDOUT: %Convert.527: %Convert.type.062 = struct_value () [symbolic]
  227. // CHECK:STDOUT: %As.impl_witness.0ef: <witness> = impl_witness imports.%As.impl_witness_table.eb4, @impl.686(%int_16) [concrete]
  228. // CHECK:STDOUT: %Convert.type.172: type = fn_type @Convert.5, @impl.686(%int_16) [concrete]
  229. // CHECK:STDOUT: %Convert.489: %Convert.type.172 = struct_value () [concrete]
  230. // CHECK:STDOUT: %As.facet: %As.type.a96 = facet_value Core.IntLiteral, (%As.impl_witness.0ef) [concrete]
  231. // CHECK:STDOUT: %.91d: type = fn_type_with_self_type %Convert.type.be5, %As.facet [concrete]
  232. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.489 [concrete]
  233. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.489, @Convert.5(%int_16) [concrete]
  234. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  235. // CHECK:STDOUT: %int_1.f90: %i16 = int_value 1 [concrete]
  236. // CHECK:STDOUT: }
  237. // CHECK:STDOUT:
  238. // CHECK:STDOUT: imports {
  239. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  240. // CHECK:STDOUT: .Int = %Core.Int
  241. // CHECK:STDOUT: .As = %Core.As
  242. // CHECK:STDOUT: import Core//prelude
  243. // CHECK:STDOUT: import Core//prelude/...
  244. // CHECK:STDOUT: }
  245. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  246. // CHECK:STDOUT: .foo = %foo.decl
  247. // CHECK:STDOUT: import Cpp//...
  248. // CHECK:STDOUT: }
  249. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  250. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {} {}
  251. // CHECK:STDOUT: %Core.As: %As.type.90f = import_ref Core//prelude/operators/as, As, loaded [concrete = constants.%As.generic]
  252. // CHECK:STDOUT: %Core.import_ref.78a: @impl.686.%Convert.type (%Convert.type.062) = import_ref Core//prelude/types/int, loc28_39, loaded [symbolic = @impl.686.%Convert (constants.%Convert.527)]
  253. // CHECK:STDOUT: %As.impl_witness_table.eb4 = impl_witness_table (%Core.import_ref.78a), @impl.686 [concrete]
  254. // CHECK:STDOUT: }
  255. // CHECK:STDOUT:
  256. // CHECK:STDOUT: file {
  257. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  258. // CHECK:STDOUT: .Core = imports.%Core
  259. // CHECK:STDOUT: .Cpp = imports.%Cpp
  260. // CHECK:STDOUT: .F = %F.decl
  261. // CHECK:STDOUT: }
  262. // CHECK:STDOUT: %Core.import = import Core
  263. // CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
  264. // CHECK:STDOUT: import Cpp "short.h"
  265. // CHECK:STDOUT: }
  266. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  267. // CHECK:STDOUT: }
  268. // CHECK:STDOUT:
  269. // CHECK:STDOUT: fn @F() {
  270. // CHECK:STDOUT: !entry:
  271. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  272. // CHECK:STDOUT: %int_16.1: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  273. // CHECK:STDOUT: %i16.1: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  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.loc7: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  277. // CHECK:STDOUT: %i16.loc7: 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.loc7_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.loc7_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.loc7_13.2(%int_1) [concrete = constants.%int_1.f90]
  283. // CHECK:STDOUT: %.loc7_13.1: %i16 = value_of_initializer %int.convert_checked [concrete = constants.%int_1.f90]
  284. // CHECK:STDOUT: %.loc7_13.2: %i16 = converted %int_1, %.loc7_13.1 [concrete = constants.%int_1.f90]
  285. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc7_13.2)
  286. // CHECK:STDOUT: return
  287. // CHECK:STDOUT: }
  288. // CHECK:STDOUT:
  289. // CHECK:STDOUT: fn @foo();
  290. // CHECK:STDOUT:
  291. // CHECK:STDOUT: --- import_short_max.carbon
  292. // CHECK:STDOUT:
  293. // CHECK:STDOUT: constants {
  294. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  295. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  296. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  297. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  298. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  299. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  300. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  301. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  302. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  303. // CHECK:STDOUT: %int_32767.f4b: Core.IntLiteral = int_value 32767 [concrete]
  304. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  305. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  306. // CHECK:STDOUT: %ImplicitAs.type.adb: type = facet_type <@ImplicitAs, @ImplicitAs(%i16)> [concrete]
  307. // CHECK:STDOUT: %Convert.type.fa6: type = fn_type @Convert.1, @ImplicitAs(%i16) [concrete]
  308. // CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  309. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
  310. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  311. // CHECK:STDOUT: %ImplicitAs.impl_witness.97b: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_16) [concrete]
  312. // CHECK:STDOUT: %Convert.type.33c: type = fn_type @Convert.2, @impl.4f9(%int_16) [concrete]
  313. // CHECK:STDOUT: %Convert.d0a: %Convert.type.33c = struct_value () [concrete]
  314. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.adb = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.97b) [concrete]
  315. // CHECK:STDOUT: %.236: type = fn_type_with_self_type %Convert.type.fa6, %ImplicitAs.facet [concrete]
  316. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_32767.f4b, %Convert.d0a [concrete]
  317. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.d0a, @Convert.2(%int_16) [concrete]
  318. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_32767.f4b, %Convert.specific_fn [concrete]
  319. // CHECK:STDOUT: %int_32767.faa: %i16 = int_value 32767 [concrete]
  320. // CHECK:STDOUT: }
  321. // CHECK:STDOUT:
  322. // CHECK:STDOUT: imports {
  323. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  324. // CHECK:STDOUT: .Int = %Core.Int
  325. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  326. // CHECK:STDOUT: import Core//prelude
  327. // CHECK:STDOUT: import Core//prelude/...
  328. // CHECK:STDOUT: }
  329. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  330. // CHECK:STDOUT: .foo = %foo.decl
  331. // CHECK:STDOUT: import Cpp//...
  332. // CHECK:STDOUT: }
  333. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  334. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {} {}
  335. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  336. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  337. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  338. // CHECK:STDOUT: }
  339. // CHECK:STDOUT:
  340. // CHECK:STDOUT: file {
  341. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  342. // CHECK:STDOUT: .Core = imports.%Core
  343. // CHECK:STDOUT: .Cpp = imports.%Cpp
  344. // CHECK:STDOUT: .F = %F.decl
  345. // CHECK:STDOUT: }
  346. // CHECK:STDOUT: %Core.import = import Core
  347. // CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
  348. // CHECK:STDOUT: import Cpp "short.h"
  349. // CHECK:STDOUT: }
  350. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  351. // CHECK:STDOUT: }
  352. // CHECK:STDOUT:
  353. // CHECK:STDOUT: fn @F() {
  354. // CHECK:STDOUT: !entry:
  355. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  356. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  357. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  358. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  359. // CHECK:STDOUT: %int_32767: Core.IntLiteral = int_value 32767 [concrete = constants.%int_32767.f4b]
  360. // CHECK:STDOUT: %impl.elem0: %.236 = impl_witness_access constants.%ImplicitAs.impl_witness.97b, element0 [concrete = constants.%Convert.d0a]
  361. // CHECK:STDOUT: %bound_method.loc7_11.1: <bound method> = bound_method %int_32767, %impl.elem0 [concrete = constants.%Convert.bound]
  362. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_16) [concrete = constants.%Convert.specific_fn]
  363. // CHECK:STDOUT: %bound_method.loc7_11.2: <bound method> = bound_method %int_32767, %specific_fn [concrete = constants.%bound_method]
  364. // CHECK:STDOUT: %int.convert_checked: init %i16 = call %bound_method.loc7_11.2(%int_32767) [concrete = constants.%int_32767.faa]
  365. // CHECK:STDOUT: %.loc7_11.1: %i16 = value_of_initializer %int.convert_checked [concrete = constants.%int_32767.faa]
  366. // CHECK:STDOUT: %.loc7_11.2: %i16 = converted %int_32767, %.loc7_11.1 [concrete = constants.%int_32767.faa]
  367. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc7_11.2)
  368. // CHECK:STDOUT: return
  369. // CHECK:STDOUT: }
  370. // CHECK:STDOUT:
  371. // CHECK:STDOUT: fn @foo();
  372. // CHECK:STDOUT:
  373. // CHECK:STDOUT: --- fail_import_short_overflow_max.carbon
  374. // CHECK:STDOUT:
  375. // CHECK:STDOUT: constants {
  376. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  377. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  378. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  379. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  380. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  381. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  382. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  383. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  384. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  385. // CHECK:STDOUT: %int_32768.4d0: Core.IntLiteral = int_value 32768 [concrete]
  386. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  387. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  388. // CHECK:STDOUT: %ImplicitAs.type.adb: type = facet_type <@ImplicitAs, @ImplicitAs(%i16)> [concrete]
  389. // CHECK:STDOUT: %Convert.type.fa6: type = fn_type @Convert.1, @ImplicitAs(%i16) [concrete]
  390. // CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  391. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
  392. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  393. // CHECK:STDOUT: %ImplicitAs.impl_witness.97b: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_16) [concrete]
  394. // CHECK:STDOUT: %Convert.type.33c: type = fn_type @Convert.2, @impl.4f9(%int_16) [concrete]
  395. // CHECK:STDOUT: %Convert.d0a: %Convert.type.33c = struct_value () [concrete]
  396. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.adb = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.97b) [concrete]
  397. // CHECK:STDOUT: %.236: type = fn_type_with_self_type %Convert.type.fa6, %ImplicitAs.facet [concrete]
  398. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_32768.4d0, %Convert.d0a [concrete]
  399. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.d0a, @Convert.2(%int_16) [concrete]
  400. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_32768.4d0, %Convert.specific_fn [concrete]
  401. // CHECK:STDOUT: %int_32768.e7f: %i16 = int_value 32768 [concrete]
  402. // CHECK:STDOUT: }
  403. // CHECK:STDOUT:
  404. // CHECK:STDOUT: imports {
  405. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  406. // CHECK:STDOUT: .Int = %Core.Int
  407. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  408. // CHECK:STDOUT: import Core//prelude
  409. // CHECK:STDOUT: import Core//prelude/...
  410. // CHECK:STDOUT: }
  411. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  412. // CHECK:STDOUT: .foo = %foo.decl
  413. // CHECK:STDOUT: import Cpp//...
  414. // CHECK:STDOUT: }
  415. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  416. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {} {}
  417. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  418. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  419. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  420. // CHECK:STDOUT: }
  421. // CHECK:STDOUT:
  422. // CHECK:STDOUT: file {
  423. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  424. // CHECK:STDOUT: .Core = imports.%Core
  425. // CHECK:STDOUT: .Cpp = imports.%Cpp
  426. // CHECK:STDOUT: .F = %F.decl
  427. // CHECK:STDOUT: }
  428. // CHECK:STDOUT: %Core.import = import Core
  429. // CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
  430. // CHECK:STDOUT: import Cpp "short.h"
  431. // CHECK:STDOUT: }
  432. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  433. // CHECK:STDOUT: }
  434. // CHECK:STDOUT:
  435. // CHECK:STDOUT: fn @F() {
  436. // CHECK:STDOUT: !entry:
  437. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  438. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  439. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  440. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  441. // CHECK:STDOUT: %int_32768: Core.IntLiteral = int_value 32768 [concrete = constants.%int_32768.4d0]
  442. // CHECK:STDOUT: %impl.elem0: %.236 = impl_witness_access constants.%ImplicitAs.impl_witness.97b, element0 [concrete = constants.%Convert.d0a]
  443. // CHECK:STDOUT: %bound_method.loc12_11.1: <bound method> = bound_method %int_32768, %impl.elem0 [concrete = constants.%Convert.bound]
  444. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_16) [concrete = constants.%Convert.specific_fn]
  445. // CHECK:STDOUT: %bound_method.loc12_11.2: <bound method> = bound_method %int_32768, %specific_fn [concrete = constants.%bound_method]
  446. // CHECK:STDOUT: %int.convert_checked: init %i16 = call %bound_method.loc12_11.2(%int_32768) [concrete = constants.%int_32768.e7f]
  447. // CHECK:STDOUT: %.loc12_11.1: %i16 = value_of_initializer %int.convert_checked [concrete = constants.%int_32768.e7f]
  448. // CHECK:STDOUT: %.loc12_11.2: %i16 = converted %int_32768, %.loc12_11.1 [concrete = constants.%int_32768.e7f]
  449. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc12_11.2)
  450. // CHECK:STDOUT: return
  451. // CHECK:STDOUT: }
  452. // CHECK:STDOUT:
  453. // CHECK:STDOUT: fn @foo();
  454. // CHECK:STDOUT:
  455. // CHECK:STDOUT: --- import_short_min.carbon
  456. // CHECK:STDOUT:
  457. // CHECK:STDOUT: constants {
  458. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  459. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  460. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  461. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  462. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  463. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  464. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  465. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  466. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  467. // CHECK:STDOUT: %int_32768: Core.IntLiteral = int_value 32768 [concrete]
  468. // CHECK:STDOUT: %Negate.type: type = facet_type <@Negate> [concrete]
  469. // CHECK:STDOUT: %Op.type.e42: type = fn_type @Op.1 [concrete]
  470. // CHECK:STDOUT: %Negate.impl_witness.561: <witness> = impl_witness imports.%Negate.impl_witness_table.e09 [concrete]
  471. // CHECK:STDOUT: %Negate.facet: %Negate.type = facet_value Core.IntLiteral, (%Negate.impl_witness.561) [concrete]
  472. // CHECK:STDOUT: %.63a: type = fn_type_with_self_type %Op.type.e42, %Negate.facet [concrete]
  473. // CHECK:STDOUT: %Op.type.1be: type = fn_type @Op.2 [concrete]
  474. // CHECK:STDOUT: %Op.bba: %Op.type.1be = struct_value () [concrete]
  475. // CHECK:STDOUT: %Op.bound: <bound method> = bound_method %int_32768, %Op.bba [concrete]
  476. // CHECK:STDOUT: %int_-32768.882: Core.IntLiteral = int_value -32768 [concrete]
  477. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  478. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  479. // CHECK:STDOUT: %ImplicitAs.type.adb: type = facet_type <@ImplicitAs, @ImplicitAs(%i16)> [concrete]
  480. // CHECK:STDOUT: %Convert.type.fa6: type = fn_type @Convert.1, @ImplicitAs(%i16) [concrete]
  481. // CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  482. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
  483. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  484. // CHECK:STDOUT: %ImplicitAs.impl_witness.97b: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_16) [concrete]
  485. // CHECK:STDOUT: %Convert.type.33c: type = fn_type @Convert.2, @impl.4f9(%int_16) [concrete]
  486. // CHECK:STDOUT: %Convert.d0a: %Convert.type.33c = struct_value () [concrete]
  487. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.adb = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.97b) [concrete]
  488. // CHECK:STDOUT: %.236: type = fn_type_with_self_type %Convert.type.fa6, %ImplicitAs.facet [concrete]
  489. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_-32768.882, %Convert.d0a [concrete]
  490. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.d0a, @Convert.2(%int_16) [concrete]
  491. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_-32768.882, %Convert.specific_fn [concrete]
  492. // CHECK:STDOUT: %int_-32768.7e5: %i16 = int_value -32768 [concrete]
  493. // CHECK:STDOUT: }
  494. // CHECK:STDOUT:
  495. // CHECK:STDOUT: imports {
  496. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  497. // CHECK:STDOUT: .Int = %Core.Int
  498. // CHECK:STDOUT: .Negate = %Core.Negate
  499. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  500. // CHECK:STDOUT: import Core//prelude
  501. // CHECK:STDOUT: import Core//prelude/...
  502. // CHECK:STDOUT: }
  503. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  504. // CHECK:STDOUT: .foo = %foo.decl
  505. // CHECK:STDOUT: import Cpp//...
  506. // CHECK:STDOUT: }
  507. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  508. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {} {}
  509. // CHECK:STDOUT: %Core.Negate: type = import_ref Core//prelude/operators/arithmetic, Negate, loaded [concrete = constants.%Negate.type]
  510. // CHECK:STDOUT: %Core.import_ref.c15: %Op.type.1be = import_ref Core//prelude/operators/arithmetic, loc94_31, loaded [concrete = constants.%Op.bba]
  511. // CHECK:STDOUT: %Negate.impl_witness_table.e09 = impl_witness_table (%Core.import_ref.c15), @impl.8cb [concrete]
  512. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  513. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  514. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  515. // CHECK:STDOUT: }
  516. // CHECK:STDOUT:
  517. // CHECK:STDOUT: file {
  518. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  519. // CHECK:STDOUT: .Core = imports.%Core
  520. // CHECK:STDOUT: .Cpp = imports.%Cpp
  521. // CHECK:STDOUT: .F = %F.decl
  522. // CHECK:STDOUT: }
  523. // CHECK:STDOUT: %Core.import = import Core
  524. // CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
  525. // CHECK:STDOUT: import Cpp "short.h"
  526. // CHECK:STDOUT: }
  527. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  528. // CHECK:STDOUT: }
  529. // CHECK:STDOUT:
  530. // CHECK:STDOUT: fn @F() {
  531. // CHECK:STDOUT: !entry:
  532. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  533. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  534. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  535. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  536. // CHECK:STDOUT: %int_32768: Core.IntLiteral = int_value 32768 [concrete = constants.%int_32768]
  537. // CHECK:STDOUT: %impl.elem0.loc7_11.1: %.63a = impl_witness_access constants.%Negate.impl_witness.561, element0 [concrete = constants.%Op.bba]
  538. // CHECK:STDOUT: %bound_method.loc7_11.1: <bound method> = bound_method %int_32768, %impl.elem0.loc7_11.1 [concrete = constants.%Op.bound]
  539. // CHECK:STDOUT: %int.snegate: init Core.IntLiteral = call %bound_method.loc7_11.1(%int_32768) [concrete = constants.%int_-32768.882]
  540. // CHECK:STDOUT: %impl.elem0.loc7_11.2: %.236 = impl_witness_access constants.%ImplicitAs.impl_witness.97b, element0 [concrete = constants.%Convert.d0a]
  541. // CHECK:STDOUT: %bound_method.loc7_11.2: <bound method> = bound_method %int.snegate, %impl.elem0.loc7_11.2 [concrete = constants.%Convert.bound]
  542. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0.loc7_11.2, @Convert.2(constants.%int_16) [concrete = constants.%Convert.specific_fn]
  543. // CHECK:STDOUT: %bound_method.loc7_11.3: <bound method> = bound_method %int.snegate, %specific_fn [concrete = constants.%bound_method]
  544. // CHECK:STDOUT: %.loc7_11.1: Core.IntLiteral = value_of_initializer %int.snegate [concrete = constants.%int_-32768.882]
  545. // CHECK:STDOUT: %.loc7_11.2: Core.IntLiteral = converted %int.snegate, %.loc7_11.1 [concrete = constants.%int_-32768.882]
  546. // CHECK:STDOUT: %int.convert_checked: init %i16 = call %bound_method.loc7_11.3(%.loc7_11.2) [concrete = constants.%int_-32768.7e5]
  547. // CHECK:STDOUT: %.loc7_11.3: %i16 = value_of_initializer %int.convert_checked [concrete = constants.%int_-32768.7e5]
  548. // CHECK:STDOUT: %.loc7_11.4: %i16 = converted %int.snegate, %.loc7_11.3 [concrete = constants.%int_-32768.7e5]
  549. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc7_11.4)
  550. // CHECK:STDOUT: return
  551. // CHECK:STDOUT: }
  552. // CHECK:STDOUT:
  553. // CHECK:STDOUT: fn @foo();
  554. // CHECK:STDOUT:
  555. // CHECK:STDOUT: --- fail_import_short_overflow_min.carbon
  556. // CHECK:STDOUT:
  557. // CHECK:STDOUT: constants {
  558. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  559. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  560. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  561. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  562. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  563. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  564. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  565. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  566. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  567. // CHECK:STDOUT: %int_32769: Core.IntLiteral = int_value 32769 [concrete]
  568. // CHECK:STDOUT: %Negate.type: type = facet_type <@Negate> [concrete]
  569. // CHECK:STDOUT: %Op.type.e42: type = fn_type @Op.1 [concrete]
  570. // CHECK:STDOUT: %Negate.impl_witness.561: <witness> = impl_witness imports.%Negate.impl_witness_table.e09 [concrete]
  571. // CHECK:STDOUT: %Negate.facet: %Negate.type = facet_value Core.IntLiteral, (%Negate.impl_witness.561) [concrete]
  572. // CHECK:STDOUT: %.63a: type = fn_type_with_self_type %Op.type.e42, %Negate.facet [concrete]
  573. // CHECK:STDOUT: %Op.type.1be: type = fn_type @Op.2 [concrete]
  574. // CHECK:STDOUT: %Op.bba: %Op.type.1be = struct_value () [concrete]
  575. // CHECK:STDOUT: %Op.bound: <bound method> = bound_method %int_32769, %Op.bba [concrete]
  576. // CHECK:STDOUT: %int_-32769.5a5: Core.IntLiteral = int_value -32769 [concrete]
  577. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  578. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  579. // CHECK:STDOUT: %ImplicitAs.type.adb: type = facet_type <@ImplicitAs, @ImplicitAs(%i16)> [concrete]
  580. // CHECK:STDOUT: %Convert.type.fa6: type = fn_type @Convert.1, @ImplicitAs(%i16) [concrete]
  581. // CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  582. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
  583. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  584. // CHECK:STDOUT: %ImplicitAs.impl_witness.97b: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_16) [concrete]
  585. // CHECK:STDOUT: %Convert.type.33c: type = fn_type @Convert.2, @impl.4f9(%int_16) [concrete]
  586. // CHECK:STDOUT: %Convert.d0a: %Convert.type.33c = struct_value () [concrete]
  587. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.adb = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.97b) [concrete]
  588. // CHECK:STDOUT: %.236: type = fn_type_with_self_type %Convert.type.fa6, %ImplicitAs.facet [concrete]
  589. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_-32769.5a5, %Convert.d0a [concrete]
  590. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.d0a, @Convert.2(%int_16) [concrete]
  591. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_-32769.5a5, %Convert.specific_fn [concrete]
  592. // CHECK:STDOUT: %int_-32769.883: %i16 = int_value -32769 [concrete]
  593. // CHECK:STDOUT: }
  594. // CHECK:STDOUT:
  595. // CHECK:STDOUT: imports {
  596. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  597. // CHECK:STDOUT: .Int = %Core.Int
  598. // CHECK:STDOUT: .Negate = %Core.Negate
  599. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  600. // CHECK:STDOUT: import Core//prelude
  601. // CHECK:STDOUT: import Core//prelude/...
  602. // CHECK:STDOUT: }
  603. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  604. // CHECK:STDOUT: .foo = %foo.decl
  605. // CHECK:STDOUT: import Cpp//...
  606. // CHECK:STDOUT: }
  607. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  608. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {} {}
  609. // CHECK:STDOUT: %Core.Negate: type = import_ref Core//prelude/operators/arithmetic, Negate, loaded [concrete = constants.%Negate.type]
  610. // CHECK:STDOUT: %Core.import_ref.c15: %Op.type.1be = import_ref Core//prelude/operators/arithmetic, loc94_31, loaded [concrete = constants.%Op.bba]
  611. // CHECK:STDOUT: %Negate.impl_witness_table.e09 = impl_witness_table (%Core.import_ref.c15), @impl.8cb [concrete]
  612. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  613. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  614. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  615. // CHECK:STDOUT: }
  616. // CHECK:STDOUT:
  617. // CHECK:STDOUT: file {
  618. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  619. // CHECK:STDOUT: .Core = imports.%Core
  620. // CHECK:STDOUT: .Cpp = imports.%Cpp
  621. // CHECK:STDOUT: .F = %F.decl
  622. // CHECK:STDOUT: }
  623. // CHECK:STDOUT: %Core.import = import Core
  624. // CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
  625. // CHECK:STDOUT: import Cpp "short.h"
  626. // CHECK:STDOUT: }
  627. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  628. // CHECK:STDOUT: }
  629. // CHECK:STDOUT:
  630. // CHECK:STDOUT: fn @F() {
  631. // CHECK:STDOUT: !entry:
  632. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  633. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  634. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  635. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  636. // CHECK:STDOUT: %int_32769: Core.IntLiteral = int_value 32769 [concrete = constants.%int_32769]
  637. // CHECK:STDOUT: %impl.elem0.loc12_11.1: %.63a = impl_witness_access constants.%Negate.impl_witness.561, element0 [concrete = constants.%Op.bba]
  638. // CHECK:STDOUT: %bound_method.loc12_11.1: <bound method> = bound_method %int_32769, %impl.elem0.loc12_11.1 [concrete = constants.%Op.bound]
  639. // CHECK:STDOUT: %int.snegate: init Core.IntLiteral = call %bound_method.loc12_11.1(%int_32769) [concrete = constants.%int_-32769.5a5]
  640. // CHECK:STDOUT: %impl.elem0.loc12_11.2: %.236 = impl_witness_access constants.%ImplicitAs.impl_witness.97b, element0 [concrete = constants.%Convert.d0a]
  641. // CHECK:STDOUT: %bound_method.loc12_11.2: <bound method> = bound_method %int.snegate, %impl.elem0.loc12_11.2 [concrete = constants.%Convert.bound]
  642. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0.loc12_11.2, @Convert.2(constants.%int_16) [concrete = constants.%Convert.specific_fn]
  643. // CHECK:STDOUT: %bound_method.loc12_11.3: <bound method> = bound_method %int.snegate, %specific_fn [concrete = constants.%bound_method]
  644. // CHECK:STDOUT: %.loc12_11.1: Core.IntLiteral = value_of_initializer %int.snegate [concrete = constants.%int_-32769.5a5]
  645. // CHECK:STDOUT: %.loc12_11.2: Core.IntLiteral = converted %int.snegate, %.loc12_11.1 [concrete = constants.%int_-32769.5a5]
  646. // CHECK:STDOUT: %int.convert_checked: init %i16 = call %bound_method.loc12_11.3(%.loc12_11.2) [concrete = constants.%int_-32769.883]
  647. // CHECK:STDOUT: %.loc12_11.3: %i16 = value_of_initializer %int.convert_checked [concrete = constants.%int_-32769.883]
  648. // CHECK:STDOUT: %.loc12_11.4: %i16 = converted %int.snegate, %.loc12_11.3 [concrete = constants.%int_-32769.883]
  649. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc12_11.4)
  650. // CHECK:STDOUT: return
  651. // CHECK:STDOUT: }
  652. // CHECK:STDOUT:
  653. // CHECK:STDOUT: fn @foo();
  654. // CHECK:STDOUT:
  655. // CHECK:STDOUT: --- fail_import_short_int32_arg.carbon
  656. // CHECK:STDOUT:
  657. // CHECK:STDOUT: constants {
  658. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  659. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  660. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  661. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  662. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  663. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  664. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  665. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  666. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  667. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  668. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  669. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  670. // CHECK:STDOUT: %As.type.90f: type = generic_interface_type @As [concrete]
  671. // CHECK:STDOUT: %As.generic: %As.type.90f = struct_value () [concrete]
  672. // CHECK:STDOUT: %As.type.fd4: type = facet_type <@As, @As(%i32)> [concrete]
  673. // CHECK:STDOUT: %Convert.type.99b: type = fn_type @Convert.1, @As(%i32) [concrete]
  674. // CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  675. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  676. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  677. // CHECK:STDOUT: %Convert.type.062: type = fn_type @Convert.5, @impl.686(%To.c80) [symbolic]
  678. // CHECK:STDOUT: %Convert.527: %Convert.type.062 = struct_value () [symbolic]
  679. // CHECK:STDOUT: %As.impl_witness.6b4: <witness> = impl_witness imports.%As.impl_witness_table.eb4, @impl.686(%int_32) [concrete]
  680. // CHECK:STDOUT: %Convert.type.4fd: type = fn_type @Convert.5, @impl.686(%int_32) [concrete]
  681. // CHECK:STDOUT: %Convert.197: %Convert.type.4fd = struct_value () [concrete]
  682. // CHECK:STDOUT: %As.facet: %As.type.fd4 = facet_value Core.IntLiteral, (%As.impl_witness.6b4) [concrete]
  683. // CHECK:STDOUT: %.982: type = fn_type_with_self_type %Convert.type.99b, %As.facet [concrete]
  684. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.197 [concrete]
  685. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.197, @Convert.5(%int_32) [concrete]
  686. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  687. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  688. // CHECK:STDOUT: }
  689. // CHECK:STDOUT:
  690. // CHECK:STDOUT: imports {
  691. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  692. // CHECK:STDOUT: .Int = %Core.Int
  693. // CHECK:STDOUT: .As = %Core.As
  694. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  695. // CHECK:STDOUT: import Core//prelude
  696. // CHECK:STDOUT: import Core//prelude/...
  697. // CHECK:STDOUT: }
  698. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  699. // CHECK:STDOUT: .foo = %foo.decl
  700. // CHECK:STDOUT: import Cpp//...
  701. // CHECK:STDOUT: }
  702. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  703. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {} {}
  704. // CHECK:STDOUT: %Core.As: %As.type.90f = import_ref Core//prelude/operators/as, As, loaded [concrete = constants.%As.generic]
  705. // CHECK:STDOUT: %Core.import_ref.78a: @impl.686.%Convert.type (%Convert.type.062) = import_ref Core//prelude/types/int, loc28_39, loaded [symbolic = @impl.686.%Convert (constants.%Convert.527)]
  706. // CHECK:STDOUT: %As.impl_witness_table.eb4 = impl_witness_table (%Core.import_ref.78a), @impl.686 [concrete]
  707. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  708. // CHECK:STDOUT: }
  709. // CHECK:STDOUT:
  710. // CHECK:STDOUT: file {
  711. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  712. // CHECK:STDOUT: .Core = imports.%Core
  713. // CHECK:STDOUT: .Cpp = imports.%Cpp
  714. // CHECK:STDOUT: .F = %F.decl
  715. // CHECK:STDOUT: }
  716. // CHECK:STDOUT: %Core.import = import Core
  717. // CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
  718. // CHECK:STDOUT: import Cpp "short.h"
  719. // CHECK:STDOUT: }
  720. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  721. // CHECK:STDOUT: }
  722. // CHECK:STDOUT:
  723. // CHECK:STDOUT: fn @F() {
  724. // CHECK:STDOUT: !entry:
  725. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  726. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  727. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  728. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  729. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  730. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  731. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  732. // CHECK:STDOUT: %impl.elem0: %.982 = impl_witness_access constants.%As.impl_witness.6b4, element0 [concrete = constants.%Convert.197]
  733. // CHECK:STDOUT: %bound_method.loc15_13.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  734. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.5(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  735. // CHECK:STDOUT: %bound_method.loc15_13.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  736. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %bound_method.loc15_13.2(%int_1) [concrete = constants.%int_1.5d2]
  737. // CHECK:STDOUT: %.loc15_13.1: %i32 = value_of_initializer %int.convert_checked [concrete = constants.%int_1.5d2]
  738. // CHECK:STDOUT: %.loc15_13.2: %i32 = converted %int_1, %.loc15_13.1 [concrete = constants.%int_1.5d2]
  739. // CHECK:STDOUT: %.loc15_13.3: %i16 = converted %.loc15_13.2, <error> [concrete = <error>]
  740. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(<error>)
  741. // CHECK:STDOUT: return
  742. // CHECK:STDOUT: }
  743. // CHECK:STDOUT:
  744. // CHECK:STDOUT: fn @foo();
  745. // CHECK:STDOUT:
  746. // CHECK:STDOUT: --- import_short_int.carbon
  747. // CHECK:STDOUT:
  748. // CHECK:STDOUT: constants {
  749. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  750. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  751. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  752. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  753. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  754. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  755. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  756. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  757. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  758. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  759. // CHECK:STDOUT: %As.type.90f: type = generic_interface_type @As [concrete]
  760. // CHECK:STDOUT: %As.generic: %As.type.90f = struct_value () [concrete]
  761. // CHECK:STDOUT: %As.type.a96: type = facet_type <@As, @As(%i16)> [concrete]
  762. // CHECK:STDOUT: %Convert.type.be5: type = fn_type @Convert.1, @As(%i16) [concrete]
  763. // CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  764. // CHECK:STDOUT: %Convert.type.062: type = fn_type @Convert.5, @impl.686(%To.c80) [symbolic]
  765. // CHECK:STDOUT: %Convert.527: %Convert.type.062 = struct_value () [symbolic]
  766. // CHECK:STDOUT: %As.impl_witness.0ef: <witness> = impl_witness imports.%As.impl_witness_table.eb4, @impl.686(%int_16) [concrete]
  767. // CHECK:STDOUT: %Convert.type.172: type = fn_type @Convert.5, @impl.686(%int_16) [concrete]
  768. // CHECK:STDOUT: %Convert.489: %Convert.type.172 = struct_value () [concrete]
  769. // CHECK:STDOUT: %As.facet: %As.type.a96 = facet_value Core.IntLiteral, (%As.impl_witness.0ef) [concrete]
  770. // CHECK:STDOUT: %.91d: type = fn_type_with_self_type %Convert.type.be5, %As.facet [concrete]
  771. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.489 [concrete]
  772. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.489, @Convert.5(%int_16) [concrete]
  773. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  774. // CHECK:STDOUT: %int_1.f90: %i16 = int_value 1 [concrete]
  775. // CHECK:STDOUT: }
  776. // CHECK:STDOUT:
  777. // CHECK:STDOUT: imports {
  778. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  779. // CHECK:STDOUT: .Int = %Core.Int
  780. // CHECK:STDOUT: .As = %Core.As
  781. // CHECK:STDOUT: import Core//prelude
  782. // CHECK:STDOUT: import Core//prelude/...
  783. // CHECK:STDOUT: }
  784. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  785. // CHECK:STDOUT: .foo = %foo.decl
  786. // CHECK:STDOUT: import Cpp//...
  787. // CHECK:STDOUT: }
  788. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  789. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {} {}
  790. // CHECK:STDOUT: %Core.As: %As.type.90f = import_ref Core//prelude/operators/as, As, loaded [concrete = constants.%As.generic]
  791. // CHECK:STDOUT: %Core.import_ref.78a: @impl.686.%Convert.type (%Convert.type.062) = import_ref Core//prelude/types/int, loc28_39, loaded [symbolic = @impl.686.%Convert (constants.%Convert.527)]
  792. // CHECK:STDOUT: %As.impl_witness_table.eb4 = impl_witness_table (%Core.import_ref.78a), @impl.686 [concrete]
  793. // CHECK:STDOUT: }
  794. // CHECK:STDOUT:
  795. // CHECK:STDOUT: file {
  796. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  797. // CHECK:STDOUT: .Core = imports.%Core
  798. // CHECK:STDOUT: .Cpp = imports.%Cpp
  799. // CHECK:STDOUT: .F = %F.decl
  800. // CHECK:STDOUT: }
  801. // CHECK:STDOUT: %Core.import = import Core
  802. // CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
  803. // CHECK:STDOUT: import Cpp "short_int.h"
  804. // CHECK:STDOUT: }
  805. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  806. // CHECK:STDOUT: }
  807. // CHECK:STDOUT:
  808. // CHECK:STDOUT: fn @F() {
  809. // CHECK:STDOUT: !entry:
  810. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  811. // CHECK:STDOUT: %int_16.1: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  812. // CHECK:STDOUT: %i16.1: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  813. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  814. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  815. // CHECK:STDOUT: %int_16.loc7: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  816. // CHECK:STDOUT: %i16.loc7: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  817. // CHECK:STDOUT: %impl.elem0: %.91d = impl_witness_access constants.%As.impl_witness.0ef, element0 [concrete = constants.%Convert.489]
  818. // CHECK:STDOUT: %bound_method.loc7_13.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  819. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.5(constants.%int_16) [concrete = constants.%Convert.specific_fn]
  820. // CHECK:STDOUT: %bound_method.loc7_13.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  821. // CHECK:STDOUT: %int.convert_checked: init %i16 = call %bound_method.loc7_13.2(%int_1) [concrete = constants.%int_1.f90]
  822. // CHECK:STDOUT: %.loc7_13.1: %i16 = value_of_initializer %int.convert_checked [concrete = constants.%int_1.f90]
  823. // CHECK:STDOUT: %.loc7_13.2: %i16 = converted %int_1, %.loc7_13.1 [concrete = constants.%int_1.f90]
  824. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc7_13.2)
  825. // CHECK:STDOUT: return
  826. // CHECK:STDOUT: }
  827. // CHECK:STDOUT:
  828. // CHECK:STDOUT: fn @foo();
  829. // CHECK:STDOUT:
  830. // CHECK:STDOUT: --- import_signed_short.carbon
  831. // CHECK:STDOUT:
  832. // CHECK:STDOUT: constants {
  833. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  834. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  835. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  836. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  837. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  838. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  839. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  840. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  841. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  842. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  843. // CHECK:STDOUT: %As.type.90f: type = generic_interface_type @As [concrete]
  844. // CHECK:STDOUT: %As.generic: %As.type.90f = struct_value () [concrete]
  845. // CHECK:STDOUT: %As.type.a96: type = facet_type <@As, @As(%i16)> [concrete]
  846. // CHECK:STDOUT: %Convert.type.be5: type = fn_type @Convert.1, @As(%i16) [concrete]
  847. // CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  848. // CHECK:STDOUT: %Convert.type.062: type = fn_type @Convert.5, @impl.686(%To.c80) [symbolic]
  849. // CHECK:STDOUT: %Convert.527: %Convert.type.062 = struct_value () [symbolic]
  850. // CHECK:STDOUT: %As.impl_witness.0ef: <witness> = impl_witness imports.%As.impl_witness_table.eb4, @impl.686(%int_16) [concrete]
  851. // CHECK:STDOUT: %Convert.type.172: type = fn_type @Convert.5, @impl.686(%int_16) [concrete]
  852. // CHECK:STDOUT: %Convert.489: %Convert.type.172 = struct_value () [concrete]
  853. // CHECK:STDOUT: %As.facet: %As.type.a96 = facet_value Core.IntLiteral, (%As.impl_witness.0ef) [concrete]
  854. // CHECK:STDOUT: %.91d: type = fn_type_with_self_type %Convert.type.be5, %As.facet [concrete]
  855. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.489 [concrete]
  856. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.489, @Convert.5(%int_16) [concrete]
  857. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  858. // CHECK:STDOUT: %int_1.f90: %i16 = int_value 1 [concrete]
  859. // CHECK:STDOUT: }
  860. // CHECK:STDOUT:
  861. // CHECK:STDOUT: imports {
  862. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  863. // CHECK:STDOUT: .Int = %Core.Int
  864. // CHECK:STDOUT: .As = %Core.As
  865. // CHECK:STDOUT: import Core//prelude
  866. // CHECK:STDOUT: import Core//prelude/...
  867. // CHECK:STDOUT: }
  868. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  869. // CHECK:STDOUT: .foo = %foo.decl
  870. // CHECK:STDOUT: import Cpp//...
  871. // CHECK:STDOUT: }
  872. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  873. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {} {}
  874. // CHECK:STDOUT: %Core.As: %As.type.90f = import_ref Core//prelude/operators/as, As, loaded [concrete = constants.%As.generic]
  875. // CHECK:STDOUT: %Core.import_ref.78a: @impl.686.%Convert.type (%Convert.type.062) = import_ref Core//prelude/types/int, loc28_39, loaded [symbolic = @impl.686.%Convert (constants.%Convert.527)]
  876. // CHECK:STDOUT: %As.impl_witness_table.eb4 = impl_witness_table (%Core.import_ref.78a), @impl.686 [concrete]
  877. // CHECK:STDOUT: }
  878. // CHECK:STDOUT:
  879. // CHECK:STDOUT: file {
  880. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  881. // CHECK:STDOUT: .Core = imports.%Core
  882. // CHECK:STDOUT: .Cpp = imports.%Cpp
  883. // CHECK:STDOUT: .F = %F.decl
  884. // CHECK:STDOUT: }
  885. // CHECK:STDOUT: %Core.import = import Core
  886. // CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
  887. // CHECK:STDOUT: import Cpp "signed_short.h"
  888. // CHECK:STDOUT: }
  889. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  890. // CHECK:STDOUT: }
  891. // CHECK:STDOUT:
  892. // CHECK:STDOUT: fn @F() {
  893. // CHECK:STDOUT: !entry:
  894. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  895. // CHECK:STDOUT: %int_16.1: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  896. // CHECK:STDOUT: %i16.1: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  897. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  898. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  899. // CHECK:STDOUT: %int_16.loc7: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  900. // CHECK:STDOUT: %i16.loc7: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  901. // CHECK:STDOUT: %impl.elem0: %.91d = impl_witness_access constants.%As.impl_witness.0ef, element0 [concrete = constants.%Convert.489]
  902. // CHECK:STDOUT: %bound_method.loc7_13.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  903. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.5(constants.%int_16) [concrete = constants.%Convert.specific_fn]
  904. // CHECK:STDOUT: %bound_method.loc7_13.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  905. // CHECK:STDOUT: %int.convert_checked: init %i16 = call %bound_method.loc7_13.2(%int_1) [concrete = constants.%int_1.f90]
  906. // CHECK:STDOUT: %.loc7_13.1: %i16 = value_of_initializer %int.convert_checked [concrete = constants.%int_1.f90]
  907. // CHECK:STDOUT: %.loc7_13.2: %i16 = converted %int_1, %.loc7_13.1 [concrete = constants.%int_1.f90]
  908. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc7_13.2)
  909. // CHECK:STDOUT: return
  910. // CHECK:STDOUT: }
  911. // CHECK:STDOUT:
  912. // CHECK:STDOUT: fn @foo();
  913. // CHECK:STDOUT:
  914. // CHECK:STDOUT: --- import_signed_short_int.carbon
  915. // CHECK:STDOUT:
  916. // CHECK:STDOUT: constants {
  917. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  918. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  919. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  920. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  921. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  922. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  923. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  924. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  925. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  926. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  927. // CHECK:STDOUT: %As.type.90f: type = generic_interface_type @As [concrete]
  928. // CHECK:STDOUT: %As.generic: %As.type.90f = struct_value () [concrete]
  929. // CHECK:STDOUT: %As.type.a96: type = facet_type <@As, @As(%i16)> [concrete]
  930. // CHECK:STDOUT: %Convert.type.be5: type = fn_type @Convert.1, @As(%i16) [concrete]
  931. // CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  932. // CHECK:STDOUT: %Convert.type.062: type = fn_type @Convert.5, @impl.686(%To.c80) [symbolic]
  933. // CHECK:STDOUT: %Convert.527: %Convert.type.062 = struct_value () [symbolic]
  934. // CHECK:STDOUT: %As.impl_witness.0ef: <witness> = impl_witness imports.%As.impl_witness_table.eb4, @impl.686(%int_16) [concrete]
  935. // CHECK:STDOUT: %Convert.type.172: type = fn_type @Convert.5, @impl.686(%int_16) [concrete]
  936. // CHECK:STDOUT: %Convert.489: %Convert.type.172 = struct_value () [concrete]
  937. // CHECK:STDOUT: %As.facet: %As.type.a96 = facet_value Core.IntLiteral, (%As.impl_witness.0ef) [concrete]
  938. // CHECK:STDOUT: %.91d: type = fn_type_with_self_type %Convert.type.be5, %As.facet [concrete]
  939. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.489 [concrete]
  940. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.489, @Convert.5(%int_16) [concrete]
  941. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  942. // CHECK:STDOUT: %int_1.f90: %i16 = int_value 1 [concrete]
  943. // CHECK:STDOUT: }
  944. // CHECK:STDOUT:
  945. // CHECK:STDOUT: imports {
  946. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  947. // CHECK:STDOUT: .Int = %Core.Int
  948. // CHECK:STDOUT: .As = %Core.As
  949. // CHECK:STDOUT: import Core//prelude
  950. // CHECK:STDOUT: import Core//prelude/...
  951. // CHECK:STDOUT: }
  952. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  953. // CHECK:STDOUT: .foo = %foo.decl
  954. // CHECK:STDOUT: import Cpp//...
  955. // CHECK:STDOUT: }
  956. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  957. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {} {}
  958. // CHECK:STDOUT: %Core.As: %As.type.90f = import_ref Core//prelude/operators/as, As, loaded [concrete = constants.%As.generic]
  959. // CHECK:STDOUT: %Core.import_ref.78a: @impl.686.%Convert.type (%Convert.type.062) = import_ref Core//prelude/types/int, loc28_39, loaded [symbolic = @impl.686.%Convert (constants.%Convert.527)]
  960. // CHECK:STDOUT: %As.impl_witness_table.eb4 = impl_witness_table (%Core.import_ref.78a), @impl.686 [concrete]
  961. // CHECK:STDOUT: }
  962. // CHECK:STDOUT:
  963. // CHECK:STDOUT: file {
  964. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  965. // CHECK:STDOUT: .Core = imports.%Core
  966. // CHECK:STDOUT: .Cpp = imports.%Cpp
  967. // CHECK:STDOUT: .F = %F.decl
  968. // CHECK:STDOUT: }
  969. // CHECK:STDOUT: %Core.import = import Core
  970. // CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
  971. // CHECK:STDOUT: import Cpp "signed_short_int.h"
  972. // CHECK:STDOUT: }
  973. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  974. // CHECK:STDOUT: }
  975. // CHECK:STDOUT:
  976. // CHECK:STDOUT: fn @F() {
  977. // CHECK:STDOUT: !entry:
  978. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  979. // CHECK:STDOUT: %int_16.1: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  980. // CHECK:STDOUT: %i16.1: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  981. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  982. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  983. // CHECK:STDOUT: %int_16.loc7: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  984. // CHECK:STDOUT: %i16.loc7: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  985. // CHECK:STDOUT: %impl.elem0: %.91d = impl_witness_access constants.%As.impl_witness.0ef, element0 [concrete = constants.%Convert.489]
  986. // CHECK:STDOUT: %bound_method.loc7_13.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  987. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.5(constants.%int_16) [concrete = constants.%Convert.specific_fn]
  988. // CHECK:STDOUT: %bound_method.loc7_13.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  989. // CHECK:STDOUT: %int.convert_checked: init %i16 = call %bound_method.loc7_13.2(%int_1) [concrete = constants.%int_1.f90]
  990. // CHECK:STDOUT: %.loc7_13.1: %i16 = value_of_initializer %int.convert_checked [concrete = constants.%int_1.f90]
  991. // CHECK:STDOUT: %.loc7_13.2: %i16 = converted %int_1, %.loc7_13.1 [concrete = constants.%int_1.f90]
  992. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc7_13.2)
  993. // CHECK:STDOUT: return
  994. // CHECK:STDOUT: }
  995. // CHECK:STDOUT:
  996. // CHECK:STDOUT: fn @foo();
  997. // CHECK:STDOUT:
  998. // CHECK:STDOUT: --- import_int16_t.carbon
  999. // CHECK:STDOUT:
  1000. // CHECK:STDOUT: constants {
  1001. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  1002. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  1003. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  1004. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  1005. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  1006. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  1007. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  1008. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  1009. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  1010. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  1011. // CHECK:STDOUT: %As.type.90f: type = generic_interface_type @As [concrete]
  1012. // CHECK:STDOUT: %As.generic: %As.type.90f = struct_value () [concrete]
  1013. // CHECK:STDOUT: %As.type.a96: type = facet_type <@As, @As(%i16)> [concrete]
  1014. // CHECK:STDOUT: %Convert.type.be5: type = fn_type @Convert.1, @As(%i16) [concrete]
  1015. // CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  1016. // CHECK:STDOUT: %Convert.type.062: type = fn_type @Convert.5, @impl.686(%To.c80) [symbolic]
  1017. // CHECK:STDOUT: %Convert.527: %Convert.type.062 = struct_value () [symbolic]
  1018. // CHECK:STDOUT: %As.impl_witness.0ef: <witness> = impl_witness imports.%As.impl_witness_table.eb4, @impl.686(%int_16) [concrete]
  1019. // CHECK:STDOUT: %Convert.type.172: type = fn_type @Convert.5, @impl.686(%int_16) [concrete]
  1020. // CHECK:STDOUT: %Convert.489: %Convert.type.172 = struct_value () [concrete]
  1021. // CHECK:STDOUT: %As.facet: %As.type.a96 = facet_value Core.IntLiteral, (%As.impl_witness.0ef) [concrete]
  1022. // CHECK:STDOUT: %.91d: type = fn_type_with_self_type %Convert.type.be5, %As.facet [concrete]
  1023. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.489 [concrete]
  1024. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.489, @Convert.5(%int_16) [concrete]
  1025. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  1026. // CHECK:STDOUT: %int_1.f90: %i16 = int_value 1 [concrete]
  1027. // CHECK:STDOUT: }
  1028. // CHECK:STDOUT:
  1029. // CHECK:STDOUT: imports {
  1030. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  1031. // CHECK:STDOUT: .Int = %Core.Int
  1032. // CHECK:STDOUT: .As = %Core.As
  1033. // CHECK:STDOUT: import Core//prelude
  1034. // CHECK:STDOUT: import Core//prelude/...
  1035. // CHECK:STDOUT: }
  1036. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  1037. // CHECK:STDOUT: .foo = %foo.decl
  1038. // CHECK:STDOUT: import Cpp//...
  1039. // CHECK:STDOUT: }
  1040. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  1041. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {} {}
  1042. // CHECK:STDOUT: %Core.As: %As.type.90f = import_ref Core//prelude/operators/as, As, loaded [concrete = constants.%As.generic]
  1043. // CHECK:STDOUT: %Core.import_ref.78a: @impl.686.%Convert.type (%Convert.type.062) = import_ref Core//prelude/types/int, loc28_39, loaded [symbolic = @impl.686.%Convert (constants.%Convert.527)]
  1044. // CHECK:STDOUT: %As.impl_witness_table.eb4 = impl_witness_table (%Core.import_ref.78a), @impl.686 [concrete]
  1045. // CHECK:STDOUT: }
  1046. // CHECK:STDOUT:
  1047. // CHECK:STDOUT: file {
  1048. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  1049. // CHECK:STDOUT: .Core = imports.%Core
  1050. // CHECK:STDOUT: .Cpp = imports.%Cpp
  1051. // CHECK:STDOUT: .F = %F.decl
  1052. // CHECK:STDOUT: }
  1053. // CHECK:STDOUT: %Core.import = import Core
  1054. // CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
  1055. // CHECK:STDOUT: import Cpp "int16_t.h"
  1056. // CHECK:STDOUT: }
  1057. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  1058. // CHECK:STDOUT: }
  1059. // CHECK:STDOUT:
  1060. // CHECK:STDOUT: fn @F() {
  1061. // CHECK:STDOUT: !entry:
  1062. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  1063. // CHECK:STDOUT: %int_16.1: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  1064. // CHECK:STDOUT: %i16.1: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  1065. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  1066. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  1067. // CHECK:STDOUT: %int_16.loc7: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  1068. // CHECK:STDOUT: %i16.loc7: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  1069. // CHECK:STDOUT: %impl.elem0: %.91d = impl_witness_access constants.%As.impl_witness.0ef, element0 [concrete = constants.%Convert.489]
  1070. // CHECK:STDOUT: %bound_method.loc7_13.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  1071. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.5(constants.%int_16) [concrete = constants.%Convert.specific_fn]
  1072. // CHECK:STDOUT: %bound_method.loc7_13.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  1073. // CHECK:STDOUT: %int.convert_checked: init %i16 = call %bound_method.loc7_13.2(%int_1) [concrete = constants.%int_1.f90]
  1074. // CHECK:STDOUT: %.loc7_13.1: %i16 = value_of_initializer %int.convert_checked [concrete = constants.%int_1.f90]
  1075. // CHECK:STDOUT: %.loc7_13.2: %i16 = converted %int_1, %.loc7_13.1 [concrete = constants.%int_1.f90]
  1076. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc7_13.2)
  1077. // CHECK:STDOUT: return
  1078. // CHECK:STDOUT: }
  1079. // CHECK:STDOUT:
  1080. // CHECK:STDOUT: fn @foo();
  1081. // CHECK:STDOUT:
  1082. // CHECK:STDOUT: --- import_const_short.carbon
  1083. // CHECK:STDOUT:
  1084. // CHECK:STDOUT: constants {
  1085. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  1086. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  1087. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  1088. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  1089. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  1090. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  1091. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  1092. // CHECK:STDOUT: %foo.type: type = fn_type @foo [concrete]
  1093. // CHECK:STDOUT: %foo: %foo.type = struct_value () [concrete]
  1094. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  1095. // CHECK:STDOUT: %As.type.90f: type = generic_interface_type @As [concrete]
  1096. // CHECK:STDOUT: %As.generic: %As.type.90f = struct_value () [concrete]
  1097. // CHECK:STDOUT: %As.type.a96: type = facet_type <@As, @As(%i16)> [concrete]
  1098. // CHECK:STDOUT: %Convert.type.be5: type = fn_type @Convert.1, @As(%i16) [concrete]
  1099. // CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  1100. // CHECK:STDOUT: %Convert.type.062: type = fn_type @Convert.5, @impl.686(%To.c80) [symbolic]
  1101. // CHECK:STDOUT: %Convert.527: %Convert.type.062 = struct_value () [symbolic]
  1102. // CHECK:STDOUT: %As.impl_witness.0ef: <witness> = impl_witness imports.%As.impl_witness_table.eb4, @impl.686(%int_16) [concrete]
  1103. // CHECK:STDOUT: %Convert.type.172: type = fn_type @Convert.5, @impl.686(%int_16) [concrete]
  1104. // CHECK:STDOUT: %Convert.489: %Convert.type.172 = struct_value () [concrete]
  1105. // CHECK:STDOUT: %As.facet: %As.type.a96 = facet_value Core.IntLiteral, (%As.impl_witness.0ef) [concrete]
  1106. // CHECK:STDOUT: %.91d: type = fn_type_with_self_type %Convert.type.be5, %As.facet [concrete]
  1107. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.489 [concrete]
  1108. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.489, @Convert.5(%int_16) [concrete]
  1109. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  1110. // CHECK:STDOUT: %int_1.f90: %i16 = int_value 1 [concrete]
  1111. // CHECK:STDOUT: }
  1112. // CHECK:STDOUT:
  1113. // CHECK:STDOUT: imports {
  1114. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  1115. // CHECK:STDOUT: .Int = %Core.Int
  1116. // CHECK:STDOUT: .As = %Core.As
  1117. // CHECK:STDOUT: import Core//prelude
  1118. // CHECK:STDOUT: import Core//prelude/...
  1119. // CHECK:STDOUT: }
  1120. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  1121. // CHECK:STDOUT: .foo = %foo.decl
  1122. // CHECK:STDOUT: import Cpp//...
  1123. // CHECK:STDOUT: }
  1124. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  1125. // CHECK:STDOUT: %foo.decl: %foo.type = fn_decl @foo [concrete = constants.%foo] {} {}
  1126. // CHECK:STDOUT: %Core.As: %As.type.90f = import_ref Core//prelude/operators/as, As, loaded [concrete = constants.%As.generic]
  1127. // CHECK:STDOUT: %Core.import_ref.78a: @impl.686.%Convert.type (%Convert.type.062) = import_ref Core//prelude/types/int, loc28_39, loaded [symbolic = @impl.686.%Convert (constants.%Convert.527)]
  1128. // CHECK:STDOUT: %As.impl_witness_table.eb4 = impl_witness_table (%Core.import_ref.78a), @impl.686 [concrete]
  1129. // CHECK:STDOUT: }
  1130. // CHECK:STDOUT:
  1131. // CHECK:STDOUT: file {
  1132. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  1133. // CHECK:STDOUT: .Core = imports.%Core
  1134. // CHECK:STDOUT: .Cpp = imports.%Cpp
  1135. // CHECK:STDOUT: .F = %F.decl
  1136. // CHECK:STDOUT: }
  1137. // CHECK:STDOUT: %Core.import = import Core
  1138. // CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
  1139. // CHECK:STDOUT: import Cpp "const_short.h"
  1140. // CHECK:STDOUT: }
  1141. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  1142. // CHECK:STDOUT: }
  1143. // CHECK:STDOUT:
  1144. // CHECK:STDOUT: fn @F() {
  1145. // CHECK:STDOUT: !entry:
  1146. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  1147. // CHECK:STDOUT: %int_16.1: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  1148. // CHECK:STDOUT: %i16.1: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  1149. // CHECK:STDOUT: %foo.ref: %foo.type = name_ref foo, imports.%foo.decl [concrete = constants.%foo]
  1150. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  1151. // CHECK:STDOUT: %int_16.loc7: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  1152. // CHECK:STDOUT: %i16.loc7: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  1153. // CHECK:STDOUT: %impl.elem0: %.91d = impl_witness_access constants.%As.impl_witness.0ef, element0 [concrete = constants.%Convert.489]
  1154. // CHECK:STDOUT: %bound_method.loc7_13.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  1155. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.5(constants.%int_16) [concrete = constants.%Convert.specific_fn]
  1156. // CHECK:STDOUT: %bound_method.loc7_13.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  1157. // CHECK:STDOUT: %int.convert_checked: init %i16 = call %bound_method.loc7_13.2(%int_1) [concrete = constants.%int_1.f90]
  1158. // CHECK:STDOUT: %.loc7_13.1: %i16 = value_of_initializer %int.convert_checked [concrete = constants.%int_1.f90]
  1159. // CHECK:STDOUT: %.loc7_13.2: %i16 = converted %int_1, %.loc7_13.1 [concrete = constants.%int_1.f90]
  1160. // CHECK:STDOUT: %foo.call: init %empty_tuple.type = call %foo.ref(%.loc7_13.2)
  1161. // CHECK:STDOUT: return
  1162. // CHECK:STDOUT: }
  1163. // CHECK:STDOUT:
  1164. // CHECK:STDOUT: fn @foo();
  1165. // CHECK:STDOUT:
  1166. // CHECK:STDOUT: --- fail_todo_import_short_ref.carbon
  1167. // CHECK:STDOUT:
  1168. // CHECK:STDOUT: constants {
  1169. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  1170. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  1171. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  1172. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  1173. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  1174. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  1175. // CHECK:STDOUT: %pattern_type.2f8: type = pattern_type %i16 [concrete]
  1176. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  1177. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  1178. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  1179. // CHECK:STDOUT: %ImplicitAs.type.adb: type = facet_type <@ImplicitAs, @ImplicitAs(%i16)> [concrete]
  1180. // CHECK:STDOUT: %Convert.type.fa6: type = fn_type @Convert.1, @ImplicitAs(%i16) [concrete]
  1181. // CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  1182. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
  1183. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  1184. // CHECK:STDOUT: %ImplicitAs.impl_witness.97b: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_16) [concrete]
  1185. // CHECK:STDOUT: %Convert.type.33c: type = fn_type @Convert.2, @impl.4f9(%int_16) [concrete]
  1186. // CHECK:STDOUT: %Convert.d0a: %Convert.type.33c = struct_value () [concrete]
  1187. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.adb = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.97b) [concrete]
  1188. // CHECK:STDOUT: %.236: type = fn_type_with_self_type %Convert.type.fa6, %ImplicitAs.facet [concrete]
  1189. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.d0a [concrete]
  1190. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.d0a, @Convert.2(%int_16) [concrete]
  1191. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  1192. // CHECK:STDOUT: %int_1.f90: %i16 = int_value 1 [concrete]
  1193. // CHECK:STDOUT: }
  1194. // CHECK:STDOUT:
  1195. // CHECK:STDOUT: imports {
  1196. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  1197. // CHECK:STDOUT: .Int = %Core.Int
  1198. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  1199. // CHECK:STDOUT: import Core//prelude
  1200. // CHECK:STDOUT: import Core//prelude/...
  1201. // CHECK:STDOUT: }
  1202. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  1203. // CHECK:STDOUT: .foo = <error>
  1204. // CHECK:STDOUT: import Cpp//...
  1205. // CHECK:STDOUT: }
  1206. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  1207. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  1208. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  1209. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  1210. // CHECK:STDOUT: }
  1211. // CHECK:STDOUT:
  1212. // CHECK:STDOUT: file {
  1213. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  1214. // CHECK:STDOUT: .Core = imports.%Core
  1215. // CHECK:STDOUT: .Cpp = imports.%Cpp
  1216. // CHECK:STDOUT: .F = %F.decl
  1217. // CHECK:STDOUT: }
  1218. // CHECK:STDOUT: %Core.import = import Core
  1219. // CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
  1220. // CHECK:STDOUT: import Cpp "short_ref.h"
  1221. // CHECK:STDOUT: }
  1222. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  1223. // CHECK:STDOUT: }
  1224. // CHECK:STDOUT:
  1225. // CHECK:STDOUT: fn @F() {
  1226. // CHECK:STDOUT: !entry:
  1227. // CHECK:STDOUT: name_binding_decl {
  1228. // CHECK:STDOUT: %a.patt: %pattern_type.2f8 = binding_pattern a [concrete]
  1229. // CHECK:STDOUT: %a.var_patt: %pattern_type.2f8 = var_pattern %a.patt [concrete]
  1230. // CHECK:STDOUT: }
  1231. // CHECK:STDOUT: %a.var: ref %i16 = var %a.var_patt
  1232. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  1233. // CHECK:STDOUT: %impl.elem0: %.236 = impl_witness_access constants.%ImplicitAs.impl_witness.97b, element0 [concrete = constants.%Convert.d0a]
  1234. // CHECK:STDOUT: %bound_method.loc7_3.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  1235. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_16) [concrete = constants.%Convert.specific_fn]
  1236. // CHECK:STDOUT: %bound_method.loc7_3.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  1237. // CHECK:STDOUT: %int.convert_checked: init %i16 = call %bound_method.loc7_3.2(%int_1) [concrete = constants.%int_1.f90]
  1238. // CHECK:STDOUT: %.loc7_3: init %i16 = converted %int_1, %int.convert_checked [concrete = constants.%int_1.f90]
  1239. // CHECK:STDOUT: assign %a.var, %.loc7_3
  1240. // CHECK:STDOUT: %.loc7_10: type = splice_block %i16 [concrete = constants.%i16] {
  1241. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  1242. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  1243. // CHECK:STDOUT: }
  1244. // CHECK:STDOUT: %a: ref %i16 = bind_name a, %a.var
  1245. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  1246. // CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>]
  1247. // CHECK:STDOUT: %a.ref: ref %i16 = name_ref a, %a
  1248. // CHECK:STDOUT: return
  1249. // CHECK:STDOUT: }
  1250. // CHECK:STDOUT:
  1251. // CHECK:STDOUT: --- fail_todo_import_const_short_ref.carbon
  1252. // CHECK:STDOUT:
  1253. // CHECK:STDOUT: constants {
  1254. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  1255. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  1256. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  1257. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  1258. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  1259. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  1260. // CHECK:STDOUT: %pattern_type.2f8: type = pattern_type %i16 [concrete]
  1261. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  1262. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  1263. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  1264. // CHECK:STDOUT: %ImplicitAs.type.adb: type = facet_type <@ImplicitAs, @ImplicitAs(%i16)> [concrete]
  1265. // CHECK:STDOUT: %Convert.type.fa6: type = fn_type @Convert.1, @ImplicitAs(%i16) [concrete]
  1266. // CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  1267. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
  1268. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  1269. // CHECK:STDOUT: %ImplicitAs.impl_witness.97b: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_16) [concrete]
  1270. // CHECK:STDOUT: %Convert.type.33c: type = fn_type @Convert.2, @impl.4f9(%int_16) [concrete]
  1271. // CHECK:STDOUT: %Convert.d0a: %Convert.type.33c = struct_value () [concrete]
  1272. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.adb = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.97b) [concrete]
  1273. // CHECK:STDOUT: %.236: type = fn_type_with_self_type %Convert.type.fa6, %ImplicitAs.facet [concrete]
  1274. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.d0a [concrete]
  1275. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.d0a, @Convert.2(%int_16) [concrete]
  1276. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  1277. // CHECK:STDOUT: %int_1.f90: %i16 = int_value 1 [concrete]
  1278. // CHECK:STDOUT: }
  1279. // CHECK:STDOUT:
  1280. // CHECK:STDOUT: imports {
  1281. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  1282. // CHECK:STDOUT: .Int = %Core.Int
  1283. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  1284. // CHECK:STDOUT: import Core//prelude
  1285. // CHECK:STDOUT: import Core//prelude/...
  1286. // CHECK:STDOUT: }
  1287. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  1288. // CHECK:STDOUT: .foo = <error>
  1289. // CHECK:STDOUT: import Cpp//...
  1290. // CHECK:STDOUT: }
  1291. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  1292. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  1293. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  1294. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  1295. // CHECK:STDOUT: }
  1296. // CHECK:STDOUT:
  1297. // CHECK:STDOUT: file {
  1298. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  1299. // CHECK:STDOUT: .Core = imports.%Core
  1300. // CHECK:STDOUT: .Cpp = imports.%Cpp
  1301. // CHECK:STDOUT: .F = %F.decl
  1302. // CHECK:STDOUT: }
  1303. // CHECK:STDOUT: %Core.import = import Core
  1304. // CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
  1305. // CHECK:STDOUT: import Cpp "const_short_ref.h"
  1306. // CHECK:STDOUT: }
  1307. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  1308. // CHECK:STDOUT: }
  1309. // CHECK:STDOUT:
  1310. // CHECK:STDOUT: fn @F() {
  1311. // CHECK:STDOUT: !entry:
  1312. // CHECK:STDOUT: name_binding_decl {
  1313. // CHECK:STDOUT: %a.patt: %pattern_type.2f8 = binding_pattern a [concrete]
  1314. // CHECK:STDOUT: %a.var_patt: %pattern_type.2f8 = var_pattern %a.patt [concrete]
  1315. // CHECK:STDOUT: }
  1316. // CHECK:STDOUT: %a.var: ref %i16 = var %a.var_patt
  1317. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  1318. // CHECK:STDOUT: %impl.elem0: %.236 = impl_witness_access constants.%ImplicitAs.impl_witness.97b, element0 [concrete = constants.%Convert.d0a]
  1319. // CHECK:STDOUT: %bound_method.loc7_3.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  1320. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_16) [concrete = constants.%Convert.specific_fn]
  1321. // CHECK:STDOUT: %bound_method.loc7_3.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  1322. // CHECK:STDOUT: %int.convert_checked: init %i16 = call %bound_method.loc7_3.2(%int_1) [concrete = constants.%int_1.f90]
  1323. // CHECK:STDOUT: %.loc7_3: init %i16 = converted %int_1, %int.convert_checked [concrete = constants.%int_1.f90]
  1324. // CHECK:STDOUT: assign %a.var, %.loc7_3
  1325. // CHECK:STDOUT: %.loc7_10: type = splice_block %i16 [concrete = constants.%i16] {
  1326. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  1327. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  1328. // CHECK:STDOUT: }
  1329. // CHECK:STDOUT: %a: ref %i16 = bind_name a, %a.var
  1330. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  1331. // CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>]
  1332. // CHECK:STDOUT: %a.ref: ref %i16 = name_ref a, %a
  1333. // CHECK:STDOUT: return
  1334. // CHECK:STDOUT: }
  1335. // CHECK:STDOUT:
  1336. // CHECK:STDOUT: --- fail_todo_import_short_pointer.carbon
  1337. // CHECK:STDOUT:
  1338. // CHECK:STDOUT: constants {
  1339. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  1340. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  1341. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  1342. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  1343. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  1344. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  1345. // CHECK:STDOUT: %pattern_type.2f8: type = pattern_type %i16 [concrete]
  1346. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  1347. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  1348. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  1349. // CHECK:STDOUT: %ImplicitAs.type.adb: type = facet_type <@ImplicitAs, @ImplicitAs(%i16)> [concrete]
  1350. // CHECK:STDOUT: %Convert.type.fa6: type = fn_type @Convert.1, @ImplicitAs(%i16) [concrete]
  1351. // CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  1352. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
  1353. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  1354. // CHECK:STDOUT: %ImplicitAs.impl_witness.97b: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_16) [concrete]
  1355. // CHECK:STDOUT: %Convert.type.33c: type = fn_type @Convert.2, @impl.4f9(%int_16) [concrete]
  1356. // CHECK:STDOUT: %Convert.d0a: %Convert.type.33c = struct_value () [concrete]
  1357. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.adb = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.97b) [concrete]
  1358. // CHECK:STDOUT: %.236: type = fn_type_with_self_type %Convert.type.fa6, %ImplicitAs.facet [concrete]
  1359. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.d0a [concrete]
  1360. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.d0a, @Convert.2(%int_16) [concrete]
  1361. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  1362. // CHECK:STDOUT: %int_1.f90: %i16 = int_value 1 [concrete]
  1363. // CHECK:STDOUT: %ptr.251: type = ptr_type %i16 [concrete]
  1364. // CHECK:STDOUT: }
  1365. // CHECK:STDOUT:
  1366. // CHECK:STDOUT: imports {
  1367. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  1368. // CHECK:STDOUT: .Int = %Core.Int
  1369. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  1370. // CHECK:STDOUT: import Core//prelude
  1371. // CHECK:STDOUT: import Core//prelude/...
  1372. // CHECK:STDOUT: }
  1373. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  1374. // CHECK:STDOUT: .foo = <error>
  1375. // CHECK:STDOUT: import Cpp//...
  1376. // CHECK:STDOUT: }
  1377. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  1378. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  1379. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  1380. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  1381. // CHECK:STDOUT: }
  1382. // CHECK:STDOUT:
  1383. // CHECK:STDOUT: file {
  1384. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  1385. // CHECK:STDOUT: .Core = imports.%Core
  1386. // CHECK:STDOUT: .Cpp = imports.%Cpp
  1387. // CHECK:STDOUT: .F = %F.decl
  1388. // CHECK:STDOUT: }
  1389. // CHECK:STDOUT: %Core.import = import Core
  1390. // CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
  1391. // CHECK:STDOUT: import Cpp "short_pointer.h"
  1392. // CHECK:STDOUT: }
  1393. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  1394. // CHECK:STDOUT: }
  1395. // CHECK:STDOUT:
  1396. // CHECK:STDOUT: fn @F() {
  1397. // CHECK:STDOUT: !entry:
  1398. // CHECK:STDOUT: name_binding_decl {
  1399. // CHECK:STDOUT: %a.patt: %pattern_type.2f8 = binding_pattern a [concrete]
  1400. // CHECK:STDOUT: %a.var_patt: %pattern_type.2f8 = var_pattern %a.patt [concrete]
  1401. // CHECK:STDOUT: }
  1402. // CHECK:STDOUT: %a.var: ref %i16 = var %a.var_patt
  1403. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  1404. // CHECK:STDOUT: %impl.elem0: %.236 = impl_witness_access constants.%ImplicitAs.impl_witness.97b, element0 [concrete = constants.%Convert.d0a]
  1405. // CHECK:STDOUT: %bound_method.loc7_3.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  1406. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_16) [concrete = constants.%Convert.specific_fn]
  1407. // CHECK:STDOUT: %bound_method.loc7_3.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  1408. // CHECK:STDOUT: %int.convert_checked: init %i16 = call %bound_method.loc7_3.2(%int_1) [concrete = constants.%int_1.f90]
  1409. // CHECK:STDOUT: %.loc7_3: init %i16 = converted %int_1, %int.convert_checked [concrete = constants.%int_1.f90]
  1410. // CHECK:STDOUT: assign %a.var, %.loc7_3
  1411. // CHECK:STDOUT: %.loc7_10: type = splice_block %i16 [concrete = constants.%i16] {
  1412. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  1413. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  1414. // CHECK:STDOUT: }
  1415. // CHECK:STDOUT: %a: ref %i16 = bind_name a, %a.var
  1416. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  1417. // CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>]
  1418. // CHECK:STDOUT: %a.ref: ref %i16 = name_ref a, %a
  1419. // CHECK:STDOUT: %addr: %ptr.251 = addr_of %a.ref
  1420. // CHECK:STDOUT: return
  1421. // CHECK:STDOUT: }
  1422. // CHECK:STDOUT:
  1423. // CHECK:STDOUT: --- fail_todo_import_const_short_pointer.carbon
  1424. // CHECK:STDOUT:
  1425. // CHECK:STDOUT: constants {
  1426. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  1427. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  1428. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete]
  1429. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  1430. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  1431. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(%int_16) [concrete]
  1432. // CHECK:STDOUT: %pattern_type.2f8: type = pattern_type %i16 [concrete]
  1433. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  1434. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  1435. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  1436. // CHECK:STDOUT: %ImplicitAs.type.adb: type = facet_type <@ImplicitAs, @ImplicitAs(%i16)> [concrete]
  1437. // CHECK:STDOUT: %Convert.type.fa6: type = fn_type @Convert.1, @ImplicitAs(%i16) [concrete]
  1438. // CHECK:STDOUT: %To.c80: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  1439. // CHECK:STDOUT: %Convert.type.0f9: type = fn_type @Convert.2, @impl.4f9(%To.c80) [symbolic]
  1440. // CHECK:STDOUT: %Convert.f06: %Convert.type.0f9 = struct_value () [symbolic]
  1441. // CHECK:STDOUT: %ImplicitAs.impl_witness.97b: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @impl.4f9(%int_16) [concrete]
  1442. // CHECK:STDOUT: %Convert.type.33c: type = fn_type @Convert.2, @impl.4f9(%int_16) [concrete]
  1443. // CHECK:STDOUT: %Convert.d0a: %Convert.type.33c = struct_value () [concrete]
  1444. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.adb = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.97b) [concrete]
  1445. // CHECK:STDOUT: %.236: type = fn_type_with_self_type %Convert.type.fa6, %ImplicitAs.facet [concrete]
  1446. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.5b8, %Convert.d0a [concrete]
  1447. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.d0a, @Convert.2(%int_16) [concrete]
  1448. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1.5b8, %Convert.specific_fn [concrete]
  1449. // CHECK:STDOUT: %int_1.f90: %i16 = int_value 1 [concrete]
  1450. // CHECK:STDOUT: %ptr.251: type = ptr_type %i16 [concrete]
  1451. // CHECK:STDOUT: }
  1452. // CHECK:STDOUT:
  1453. // CHECK:STDOUT: imports {
  1454. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  1455. // CHECK:STDOUT: .Int = %Core.Int
  1456. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  1457. // CHECK:STDOUT: import Core//prelude
  1458. // CHECK:STDOUT: import Core//prelude/...
  1459. // CHECK:STDOUT: }
  1460. // CHECK:STDOUT: %Cpp: <namespace> = namespace file.%Cpp.import_cpp, [concrete] {
  1461. // CHECK:STDOUT: .foo = <error>
  1462. // CHECK:STDOUT: import Cpp//...
  1463. // CHECK:STDOUT: }
  1464. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/types/int, Int, loaded [concrete = constants.%Int.generic]
  1465. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/operators/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  1466. // CHECK:STDOUT: %Core.import_ref.a5b: @impl.4f9.%Convert.type (%Convert.type.0f9) = import_ref Core//prelude/types/int, loc19_39, loaded [symbolic = @impl.4f9.%Convert (constants.%Convert.f06)]
  1467. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @impl.4f9 [concrete]
  1468. // CHECK:STDOUT: }
  1469. // CHECK:STDOUT:
  1470. // CHECK:STDOUT: file {
  1471. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  1472. // CHECK:STDOUT: .Core = imports.%Core
  1473. // CHECK:STDOUT: .Cpp = imports.%Cpp
  1474. // CHECK:STDOUT: .F = %F.decl
  1475. // CHECK:STDOUT: }
  1476. // CHECK:STDOUT: %Core.import = import Core
  1477. // CHECK:STDOUT: %Cpp.import_cpp = import_cpp {
  1478. // CHECK:STDOUT: import Cpp "const_short_pointer.h"
  1479. // CHECK:STDOUT: }
  1480. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  1481. // CHECK:STDOUT: }
  1482. // CHECK:STDOUT:
  1483. // CHECK:STDOUT: fn @F() {
  1484. // CHECK:STDOUT: !entry:
  1485. // CHECK:STDOUT: name_binding_decl {
  1486. // CHECK:STDOUT: %a.patt: %pattern_type.2f8 = binding_pattern a [concrete]
  1487. // CHECK:STDOUT: %a.var_patt: %pattern_type.2f8 = var_pattern %a.patt [concrete]
  1488. // CHECK:STDOUT: }
  1489. // CHECK:STDOUT: %a.var: ref %i16 = var %a.var_patt
  1490. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  1491. // CHECK:STDOUT: %impl.elem0: %.236 = impl_witness_access constants.%ImplicitAs.impl_witness.97b, element0 [concrete = constants.%Convert.d0a]
  1492. // CHECK:STDOUT: %bound_method.loc7_3.1: <bound method> = bound_method %int_1, %impl.elem0 [concrete = constants.%Convert.bound]
  1493. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_16) [concrete = constants.%Convert.specific_fn]
  1494. // CHECK:STDOUT: %bound_method.loc7_3.2: <bound method> = bound_method %int_1, %specific_fn [concrete = constants.%bound_method]
  1495. // CHECK:STDOUT: %int.convert_checked: init %i16 = call %bound_method.loc7_3.2(%int_1) [concrete = constants.%int_1.f90]
  1496. // CHECK:STDOUT: %.loc7_3: init %i16 = converted %int_1, %int.convert_checked [concrete = constants.%int_1.f90]
  1497. // CHECK:STDOUT: assign %a.var, %.loc7_3
  1498. // CHECK:STDOUT: %.loc7_10: type = splice_block %i16 [concrete = constants.%i16] {
  1499. // CHECK:STDOUT: %int_16: Core.IntLiteral = int_value 16 [concrete = constants.%int_16]
  1500. // CHECK:STDOUT: %i16: type = class_type @Int, @Int(constants.%int_16) [concrete = constants.%i16]
  1501. // CHECK:STDOUT: }
  1502. // CHECK:STDOUT: %a: ref %i16 = bind_name a, %a.var
  1503. // CHECK:STDOUT: %Cpp.ref: <namespace> = name_ref Cpp, imports.%Cpp [concrete = imports.%Cpp]
  1504. // CHECK:STDOUT: %foo.ref: <error> = name_ref foo, <error> [concrete = <error>]
  1505. // CHECK:STDOUT: %a.ref: ref %i16 = name_ref a, %a
  1506. // CHECK:STDOUT: %addr: %ptr.251 = addr_of %a.ref
  1507. // CHECK:STDOUT: return
  1508. // CHECK:STDOUT: }
  1509. // CHECK:STDOUT: