import.carbon 68 KB

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