import.carbon 77 KB

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