import.carbon 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539
  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: %Core: <namespace> = namespace file.%Core.import, [template] {
  336. // CHECK:STDOUT: .Int32 = %import_ref
  337. // CHECK:STDOUT: import Core//prelude
  338. // CHECK:STDOUT: import Core//prelude/operators
  339. // CHECK:STDOUT: import Core//prelude/types
  340. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  341. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  342. // CHECK:STDOUT: import Core//prelude/operators/comparison
  343. // CHECK:STDOUT: import Core//prelude/types/bool
  344. // CHECK:STDOUT: }
  345. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  346. // CHECK:STDOUT: }
  347. // CHECK:STDOUT:
  348. // CHECK:STDOUT: file {
  349. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  350. // CHECK:STDOUT: .Core = imports.%Core
  351. // CHECK:STDOUT: .A = %A.decl
  352. // CHECK:STDOUT: .B = %B.decl
  353. // CHECK:STDOUT: .C = %C.decl
  354. // CHECK:STDOUT: .D = %D.decl
  355. // CHECK:STDOUT: .NS = %NS
  356. // CHECK:STDOUT: }
  357. // CHECK:STDOUT: %Core.import = import Core
  358. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {}
  359. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {
  360. // CHECK:STDOUT: %int.make_type_32.loc5_9: init type = call constants.%Int32() [template = i32]
  361. // CHECK:STDOUT: %.loc5_9.1: type = value_of_initializer %int.make_type_32.loc5_9 [template = i32]
  362. // CHECK:STDOUT: %.loc5_9.2: type = converted %int.make_type_32.loc5_9, %.loc5_9.1 [template = i32]
  363. // CHECK:STDOUT: %b.loc5_6.1: i32 = param b
  364. // CHECK:STDOUT: @B.%b: i32 = bind_name b, %b.loc5_6.1
  365. // CHECK:STDOUT: %int.make_type_32.loc5_17: init type = call constants.%Int32() [template = i32]
  366. // CHECK:STDOUT: %.loc5_17.1: type = value_of_initializer %int.make_type_32.loc5_17 [template = i32]
  367. // CHECK:STDOUT: %.loc5_17.2: type = converted %int.make_type_32.loc5_17, %.loc5_17.1 [template = i32]
  368. // CHECK:STDOUT: @B.%return: ref i32 = var <return slot>
  369. // CHECK:STDOUT: }
  370. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {
  371. // CHECK:STDOUT: %int.make_type_32.loc6_10: init type = call constants.%Int32() [template = i32]
  372. // CHECK:STDOUT: %.loc6_14.1: %.2 = tuple_literal (%int.make_type_32.loc6_10)
  373. // CHECK:STDOUT: %.loc6_14.2: type = value_of_initializer %int.make_type_32.loc6_10 [template = i32]
  374. // CHECK:STDOUT: %.loc6_14.3: type = converted %int.make_type_32.loc6_10, %.loc6_14.2 [template = i32]
  375. // CHECK:STDOUT: %.loc6_14.4: type = converted %.loc6_14.1, constants.%.3 [template = constants.%.3]
  376. // CHECK:STDOUT: %c.loc6_6.1: %.3 = param c
  377. // CHECK:STDOUT: @C.%c: %.3 = bind_name c, %c.loc6_6.1
  378. // CHECK:STDOUT: %int.make_type_32.loc6_25: init type = call constants.%Int32() [template = i32]
  379. // CHECK:STDOUT: %.loc6_25.1: type = value_of_initializer %int.make_type_32.loc6_25 [template = i32]
  380. // CHECK:STDOUT: %.loc6_25.2: type = converted %int.make_type_32.loc6_25, %.loc6_25.1 [template = i32]
  381. // CHECK:STDOUT: %.loc6_28: type = struct_type {.c: i32} [template = constants.%.4]
  382. // CHECK:STDOUT: @C.%return: ref %.4 = var <return slot>
  383. // CHECK:STDOUT: }
  384. // CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [template = constants.%D] {}
  385. // CHECK:STDOUT: %NS: <namespace> = namespace [template] {
  386. // CHECK:STDOUT: .E = %E.decl
  387. // CHECK:STDOUT: }
  388. // CHECK:STDOUT: %E.decl: %E.type = fn_decl @E [template = constants.%E] {}
  389. // CHECK:STDOUT: }
  390. // CHECK:STDOUT:
  391. // CHECK:STDOUT: fn @A();
  392. // CHECK:STDOUT:
  393. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  394. // CHECK:STDOUT:
  395. // CHECK:STDOUT: fn @B(%b: i32) -> i32;
  396. // CHECK:STDOUT:
  397. // CHECK:STDOUT: fn @C(%c: %.3) -> %.4;
  398. // CHECK:STDOUT:
  399. // CHECK:STDOUT: extern fn @D();
  400. // CHECK:STDOUT:
  401. // CHECK:STDOUT: fn @E();
  402. // CHECK:STDOUT:
  403. // CHECK:STDOUT: --- extern_api.carbon
  404. // CHECK:STDOUT:
  405. // CHECK:STDOUT: constants {
  406. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  407. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  408. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  409. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  410. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  411. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  412. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  413. // CHECK:STDOUT: %.2: type = tuple_type (type) [template]
  414. // CHECK:STDOUT: %.3: type = tuple_type (i32) [template]
  415. // CHECK:STDOUT: %.4: type = struct_type {.c: i32} [template]
  416. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  417. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  418. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  419. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  420. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  421. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  422. // CHECK:STDOUT: }
  423. // CHECK:STDOUT:
  424. // CHECK:STDOUT: imports {
  425. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  426. // CHECK:STDOUT: .Int32 = %import_ref
  427. // CHECK:STDOUT: import Core//prelude
  428. // CHECK:STDOUT: import Core//prelude/operators
  429. // CHECK:STDOUT: import Core//prelude/types
  430. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  431. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  432. // CHECK:STDOUT: import Core//prelude/operators/comparison
  433. // CHECK:STDOUT: import Core//prelude/types/bool
  434. // CHECK:STDOUT: }
  435. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  436. // CHECK:STDOUT: }
  437. // CHECK:STDOUT:
  438. // CHECK:STDOUT: file {
  439. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  440. // CHECK:STDOUT: .Core = imports.%Core
  441. // CHECK:STDOUT: .A = %A.decl
  442. // CHECK:STDOUT: .B = %B.decl
  443. // CHECK:STDOUT: .C = %C.decl
  444. // CHECK:STDOUT: .D = %D.decl
  445. // CHECK:STDOUT: .NS = %NS
  446. // CHECK:STDOUT: }
  447. // CHECK:STDOUT: %Core.import = import Core
  448. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {}
  449. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {
  450. // CHECK:STDOUT: %int.make_type_32.loc5_16: init type = call constants.%Int32() [template = i32]
  451. // CHECK:STDOUT: %.loc5_16.1: type = value_of_initializer %int.make_type_32.loc5_16 [template = i32]
  452. // CHECK:STDOUT: %.loc5_16.2: type = converted %int.make_type_32.loc5_16, %.loc5_16.1 [template = i32]
  453. // CHECK:STDOUT: %b.loc5_13.1: i32 = param b
  454. // CHECK:STDOUT: @B.%b: i32 = bind_name b, %b.loc5_13.1
  455. // CHECK:STDOUT: %int.make_type_32.loc5_24: init type = call constants.%Int32() [template = i32]
  456. // CHECK:STDOUT: %.loc5_24.1: type = value_of_initializer %int.make_type_32.loc5_24 [template = i32]
  457. // CHECK:STDOUT: %.loc5_24.2: type = converted %int.make_type_32.loc5_24, %.loc5_24.1 [template = i32]
  458. // CHECK:STDOUT: @B.%return: ref i32 = var <return slot>
  459. // CHECK:STDOUT: }
  460. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {
  461. // CHECK:STDOUT: %int.make_type_32.loc6_17: init type = call constants.%Int32() [template = i32]
  462. // CHECK:STDOUT: %.loc6_21.1: %.2 = tuple_literal (%int.make_type_32.loc6_17)
  463. // CHECK:STDOUT: %.loc6_21.2: type = value_of_initializer %int.make_type_32.loc6_17 [template = i32]
  464. // CHECK:STDOUT: %.loc6_21.3: type = converted %int.make_type_32.loc6_17, %.loc6_21.2 [template = i32]
  465. // CHECK:STDOUT: %.loc6_21.4: type = converted %.loc6_21.1, constants.%.3 [template = constants.%.3]
  466. // CHECK:STDOUT: %c.loc6_13.1: %.3 = param c
  467. // CHECK:STDOUT: @C.%c: %.3 = bind_name c, %c.loc6_13.1
  468. // CHECK:STDOUT: %int.make_type_32.loc6_32: init type = call constants.%Int32() [template = i32]
  469. // CHECK:STDOUT: %.loc6_32.1: type = value_of_initializer %int.make_type_32.loc6_32 [template = i32]
  470. // CHECK:STDOUT: %.loc6_32.2: type = converted %int.make_type_32.loc6_32, %.loc6_32.1 [template = i32]
  471. // CHECK:STDOUT: %.loc6_35: type = struct_type {.c: i32} [template = constants.%.4]
  472. // CHECK:STDOUT: @C.%return: ref %.4 = var <return slot>
  473. // CHECK:STDOUT: }
  474. // CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [template = constants.%D] {}
  475. // CHECK:STDOUT: %NS: <namespace> = namespace [template] {
  476. // CHECK:STDOUT: .E = %E.decl
  477. // CHECK:STDOUT: }
  478. // CHECK:STDOUT: %E.decl: %E.type = fn_decl @E [template = constants.%E] {}
  479. // CHECK:STDOUT: }
  480. // CHECK:STDOUT:
  481. // CHECK:STDOUT: extern fn @A();
  482. // CHECK:STDOUT:
  483. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  484. // CHECK:STDOUT:
  485. // CHECK:STDOUT: extern fn @B(%b: i32) -> i32;
  486. // CHECK:STDOUT:
  487. // CHECK:STDOUT: extern fn @C(%c: %.3) -> %.4;
  488. // CHECK:STDOUT:
  489. // CHECK:STDOUT: extern fn @D();
  490. // CHECK:STDOUT:
  491. // CHECK:STDOUT: extern fn @E();
  492. // CHECK:STDOUT:
  493. // CHECK:STDOUT: --- basics.carbon
  494. // CHECK:STDOUT:
  495. // CHECK:STDOUT: constants {
  496. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  497. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  498. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  499. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  500. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  501. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  502. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  503. // CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
  504. // CHECK:STDOUT: %.3: type = struct_type {.c: i32} [template]
  505. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  506. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  507. // CHECK:STDOUT: %.4: type = tuple_type (i32) [template]
  508. // CHECK:STDOUT: %tuple: %.4 = tuple_value (%.2) [template]
  509. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  510. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  511. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  512. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  513. // CHECK:STDOUT: }
  514. // CHECK:STDOUT:
  515. // CHECK:STDOUT: imports {
  516. // CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//api, inst+3, loaded [template = constants.%A]
  517. // CHECK:STDOUT: %import_ref.2: %B.type = import_ref Main//api, inst+21, loaded [template = constants.%B]
  518. // CHECK:STDOUT: %import_ref.3: %C.type = import_ref Main//api, inst+41, loaded [template = constants.%C]
  519. // CHECK:STDOUT: %import_ref.4: %D.type = import_ref Main//api, inst+44, loaded [template = constants.%D]
  520. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//api, inst+47, loaded
  521. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  522. // CHECK:STDOUT: .E = %import_ref.6
  523. // CHECK:STDOUT: }
  524. // CHECK:STDOUT: %import_ref.6: %E.type = import_ref Main//api, inst+48, loaded [template = constants.%E]
  525. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  526. // CHECK:STDOUT: .Int32 = %import_ref.7
  527. // CHECK:STDOUT: import Core//prelude
  528. // CHECK:STDOUT: import Core//prelude/operators
  529. // CHECK:STDOUT: import Core//prelude/types
  530. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  531. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  532. // CHECK:STDOUT: import Core//prelude/operators/comparison
  533. // CHECK:STDOUT: import Core//prelude/types/bool
  534. // CHECK:STDOUT: }
  535. // CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  536. // CHECK:STDOUT: }
  537. // CHECK:STDOUT:
  538. // CHECK:STDOUT: file {
  539. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  540. // CHECK:STDOUT: .A = imports.%import_ref.1
  541. // CHECK:STDOUT: .B = imports.%import_ref.2
  542. // CHECK:STDOUT: .C = imports.%import_ref.3
  543. // CHECK:STDOUT: .D = imports.%import_ref.4
  544. // CHECK:STDOUT: .NS = imports.%NS
  545. // CHECK:STDOUT: .Core = imports.%Core
  546. // CHECK:STDOUT: .a = %a
  547. // CHECK:STDOUT: .b = %b
  548. // CHECK:STDOUT: .c = %c
  549. // CHECK:STDOUT: .d = %d
  550. // CHECK:STDOUT: .e = %e
  551. // CHECK:STDOUT: }
  552. // CHECK:STDOUT: %Core.import = import Core
  553. // CHECK:STDOUT: %default.import = import <invalid>
  554. // CHECK:STDOUT: %.loc6_9.1: %.1 = tuple_literal ()
  555. // CHECK:STDOUT: %.loc6_9.2: type = converted %.loc6_9.1, constants.%.1 [template = constants.%.1]
  556. // CHECK:STDOUT: %a.var: ref %.1 = var a
  557. // CHECK:STDOUT: %a: ref %.1 = bind_name a, %a.var
  558. // CHECK:STDOUT: %int.make_type_32.loc7: init type = call constants.%Int32() [template = i32]
  559. // CHECK:STDOUT: %.loc7_8.1: type = value_of_initializer %int.make_type_32.loc7 [template = i32]
  560. // CHECK:STDOUT: %.loc7_8.2: type = converted %int.make_type_32.loc7, %.loc7_8.1 [template = i32]
  561. // CHECK:STDOUT: %b.var: ref i32 = var b
  562. // CHECK:STDOUT: %b: ref i32 = bind_name b, %b.var
  563. // CHECK:STDOUT: %int.make_type_32.loc8: init type = call constants.%Int32() [template = i32]
  564. // CHECK:STDOUT: %.loc8_13.1: type = value_of_initializer %int.make_type_32.loc8 [template = i32]
  565. // CHECK:STDOUT: %.loc8_13.2: type = converted %int.make_type_32.loc8, %.loc8_13.1 [template = i32]
  566. // CHECK:STDOUT: %.loc8_16: type = struct_type {.c: i32} [template = constants.%.3]
  567. // CHECK:STDOUT: %c.var: ref %.3 = var c
  568. // CHECK:STDOUT: %c: ref %.3 = bind_name c, %c.var
  569. // CHECK:STDOUT: %.loc9_9.1: %.1 = tuple_literal ()
  570. // CHECK:STDOUT: %.loc9_9.2: type = converted %.loc9_9.1, constants.%.1 [template = constants.%.1]
  571. // CHECK:STDOUT: %d.var: ref %.1 = var d
  572. // CHECK:STDOUT: %d: ref %.1 = bind_name d, %d.var
  573. // CHECK:STDOUT: %.loc10_9.1: %.1 = tuple_literal ()
  574. // CHECK:STDOUT: %.loc10_9.2: type = converted %.loc10_9.1, constants.%.1 [template = constants.%.1]
  575. // CHECK:STDOUT: %e.var: ref %.1 = var e
  576. // CHECK:STDOUT: %e: ref %.1 = bind_name e, %e.var
  577. // CHECK:STDOUT: }
  578. // CHECK:STDOUT:
  579. // CHECK:STDOUT: fn @A();
  580. // CHECK:STDOUT:
  581. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  582. // CHECK:STDOUT:
  583. // CHECK:STDOUT: fn @B(%b: i32) -> i32;
  584. // CHECK:STDOUT:
  585. // CHECK:STDOUT: fn @C(%c: %.4) -> %.3;
  586. // CHECK:STDOUT:
  587. // CHECK:STDOUT: extern fn @D();
  588. // CHECK:STDOUT:
  589. // CHECK:STDOUT: fn @E();
  590. // CHECK:STDOUT:
  591. // CHECK:STDOUT: fn @__global_init() {
  592. // CHECK:STDOUT: !entry:
  593. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, imports.%import_ref.1 [template = constants.%A]
  594. // CHECK:STDOUT: %A.call: init %.1 = call %A.ref()
  595. // CHECK:STDOUT: assign file.%a.var, %A.call
  596. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, imports.%import_ref.2 [template = constants.%B]
  597. // CHECK:STDOUT: %.loc7: i32 = int_literal 1 [template = constants.%.2]
  598. // CHECK:STDOUT: %B.call: init i32 = call %B.ref(%.loc7)
  599. // CHECK:STDOUT: assign file.%b.var, %B.call
  600. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.3 [template = constants.%C]
  601. // CHECK:STDOUT: %.loc8_23: i32 = int_literal 1 [template = constants.%.2]
  602. // CHECK:STDOUT: %.loc8_25: %.4 = tuple_literal (%.loc8_23)
  603. // CHECK:STDOUT: %tuple: %.4 = tuple_value (%.loc8_23) [template = constants.%tuple]
  604. // CHECK:STDOUT: %.loc8_21: %.4 = converted %.loc8_25, %tuple [template = constants.%tuple]
  605. // CHECK:STDOUT: %C.call: init %.3 = call %C.ref(%.loc8_21)
  606. // CHECK:STDOUT: assign file.%c.var, %C.call
  607. // CHECK:STDOUT: %D.ref: %D.type = name_ref D, imports.%import_ref.4 [template = constants.%D]
  608. // CHECK:STDOUT: %D.call: init %.1 = call %D.ref()
  609. // CHECK:STDOUT: assign file.%d.var, %D.call
  610. // CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
  611. // CHECK:STDOUT: %E.ref: %E.type = name_ref E, imports.%import_ref.6 [template = constants.%E]
  612. // CHECK:STDOUT: %E.call: init %.1 = call %E.ref()
  613. // CHECK:STDOUT: assign file.%e.var, %E.call
  614. // CHECK:STDOUT: return
  615. // CHECK:STDOUT: }
  616. // CHECK:STDOUT:
  617. // CHECK:STDOUT: --- redecl_api.carbon
  618. // CHECK:STDOUT:
  619. // CHECK:STDOUT: constants {
  620. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  621. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  622. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  623. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  624. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  625. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  626. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  627. // CHECK:STDOUT: %.2: type = tuple_type (type) [template]
  628. // CHECK:STDOUT: %.3: type = tuple_type (i32) [template]
  629. // CHECK:STDOUT: %.4: type = struct_type {.c: i32} [template]
  630. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  631. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  632. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  633. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  634. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  635. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  636. // CHECK:STDOUT: %.5: i32 = int_literal 1 [template]
  637. // CHECK:STDOUT: %tuple: %.3 = tuple_value (%.5) [template]
  638. // CHECK:STDOUT: }
  639. // CHECK:STDOUT:
  640. // CHECK:STDOUT: imports {
  641. // CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//api, inst+3, loaded [template = constants.%A]
  642. // CHECK:STDOUT: %import_ref.2: %B.type = import_ref Main//api, inst+21, loaded [template = constants.%B]
  643. // CHECK:STDOUT: %import_ref.3: %C.type = import_ref Main//api, inst+41, loaded [template = constants.%C]
  644. // CHECK:STDOUT: %import_ref.4: %D.type = import_ref Main//api, inst+44, loaded [template = constants.%D]
  645. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//api, inst+47, loaded
  646. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  647. // CHECK:STDOUT: .E = file.%E.decl
  648. // CHECK:STDOUT: }
  649. // CHECK:STDOUT: %import_ref.6: %E.type = import_ref Main//api, inst+48, loaded [template = constants.%E]
  650. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  651. // CHECK:STDOUT: .Int32 = %import_ref.7
  652. // CHECK:STDOUT: import Core//prelude
  653. // CHECK:STDOUT: import Core//prelude/operators
  654. // CHECK:STDOUT: import Core//prelude/types
  655. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  656. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  657. // CHECK:STDOUT: import Core//prelude/operators/comparison
  658. // CHECK:STDOUT: import Core//prelude/types/bool
  659. // CHECK:STDOUT: }
  660. // CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  661. // CHECK:STDOUT: }
  662. // CHECK:STDOUT:
  663. // CHECK:STDOUT: file {
  664. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  665. // CHECK:STDOUT: .A = %A.decl
  666. // CHECK:STDOUT: .B = %B.decl
  667. // CHECK:STDOUT: .C = %C.decl
  668. // CHECK:STDOUT: .D = %D.decl
  669. // CHECK:STDOUT: .NS = imports.%NS
  670. // CHECK:STDOUT: .Core = imports.%Core
  671. // CHECK:STDOUT: .a = %a
  672. // CHECK:STDOUT: .b = %b.loc13
  673. // CHECK:STDOUT: .c = %c.loc14
  674. // CHECK:STDOUT: .d = %d
  675. // CHECK:STDOUT: .e = %e
  676. // CHECK:STDOUT: }
  677. // CHECK:STDOUT: %Core.import = import Core
  678. // CHECK:STDOUT: %default.import = import <invalid>
  679. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {}
  680. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {
  681. // CHECK:STDOUT: %int.make_type_32.loc7_16: init type = call constants.%Int32() [template = i32]
  682. // CHECK:STDOUT: %.loc7_16.1: type = value_of_initializer %int.make_type_32.loc7_16 [template = i32]
  683. // CHECK:STDOUT: %.loc7_16.2: type = converted %int.make_type_32.loc7_16, %.loc7_16.1 [template = i32]
  684. // CHECK:STDOUT: %b.loc7_13.1: i32 = param b
  685. // CHECK:STDOUT: %b.loc7_13.2: i32 = bind_name b, %b.loc7_13.1
  686. // CHECK:STDOUT: %int.make_type_32.loc7_24: init type = call constants.%Int32() [template = i32]
  687. // CHECK:STDOUT: %.loc7_24.1: type = value_of_initializer %int.make_type_32.loc7_24 [template = i32]
  688. // CHECK:STDOUT: %.loc7_24.2: type = converted %int.make_type_32.loc7_24, %.loc7_24.1 [template = i32]
  689. // CHECK:STDOUT: %return.var.loc7: ref i32 = var <return slot>
  690. // CHECK:STDOUT: }
  691. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {
  692. // CHECK:STDOUT: %int.make_type_32.loc8_17: init type = call constants.%Int32() [template = i32]
  693. // CHECK:STDOUT: %.loc8_21.1: %.2 = tuple_literal (%int.make_type_32.loc8_17)
  694. // CHECK:STDOUT: %.loc8_21.2: type = value_of_initializer %int.make_type_32.loc8_17 [template = i32]
  695. // CHECK:STDOUT: %.loc8_21.3: type = converted %int.make_type_32.loc8_17, %.loc8_21.2 [template = i32]
  696. // CHECK:STDOUT: %.loc8_21.4: type = converted %.loc8_21.1, constants.%.3 [template = constants.%.3]
  697. // CHECK:STDOUT: %c.loc8_13.1: %.3 = param c
  698. // CHECK:STDOUT: %c.loc8_13.2: %.3 = bind_name c, %c.loc8_13.1
  699. // CHECK:STDOUT: %int.make_type_32.loc8_32: init type = call constants.%Int32() [template = i32]
  700. // CHECK:STDOUT: %.loc8_32.1: type = value_of_initializer %int.make_type_32.loc8_32 [template = i32]
  701. // CHECK:STDOUT: %.loc8_32.2: type = converted %int.make_type_32.loc8_32, %.loc8_32.1 [template = i32]
  702. // CHECK:STDOUT: %.loc8_35: type = struct_type {.c: i32} [template = constants.%.4]
  703. // CHECK:STDOUT: %return.var.loc8: ref %.4 = var <return slot>
  704. // CHECK:STDOUT: }
  705. // CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [template = constants.%D] {}
  706. // CHECK:STDOUT: %E.decl: %E.type = fn_decl @E [template = constants.%E] {}
  707. // CHECK:STDOUT: %.loc12_9.1: %.1 = tuple_literal ()
  708. // CHECK:STDOUT: %.loc12_9.2: type = converted %.loc12_9.1, constants.%.1 [template = constants.%.1]
  709. // CHECK:STDOUT: %a.var: ref %.1 = var a
  710. // CHECK:STDOUT: %a: ref %.1 = bind_name a, %a.var
  711. // CHECK:STDOUT: %int.make_type_32.loc13: init type = call constants.%Int32() [template = i32]
  712. // CHECK:STDOUT: %.loc13_8.1: type = value_of_initializer %int.make_type_32.loc13 [template = i32]
  713. // CHECK:STDOUT: %.loc13_8.2: type = converted %int.make_type_32.loc13, %.loc13_8.1 [template = i32]
  714. // CHECK:STDOUT: %b.var: ref i32 = var b
  715. // CHECK:STDOUT: %b.loc13: ref i32 = bind_name b, %b.var
  716. // CHECK:STDOUT: %int.make_type_32.loc14: init type = call constants.%Int32() [template = i32]
  717. // CHECK:STDOUT: %.loc14_13.1: type = value_of_initializer %int.make_type_32.loc14 [template = i32]
  718. // CHECK:STDOUT: %.loc14_13.2: type = converted %int.make_type_32.loc14, %.loc14_13.1 [template = i32]
  719. // CHECK:STDOUT: %.loc14_16: type = struct_type {.c: i32} [template = constants.%.4]
  720. // CHECK:STDOUT: %c.var: ref %.4 = var c
  721. // CHECK:STDOUT: %c.loc14: ref %.4 = bind_name c, %c.var
  722. // CHECK:STDOUT: %.loc15_9.1: %.1 = tuple_literal ()
  723. // CHECK:STDOUT: %.loc15_9.2: type = converted %.loc15_9.1, constants.%.1 [template = constants.%.1]
  724. // CHECK:STDOUT: %d.var: ref %.1 = var d
  725. // CHECK:STDOUT: %d: ref %.1 = bind_name d, %d.var
  726. // CHECK:STDOUT: %.loc16_9.1: %.1 = tuple_literal ()
  727. // CHECK:STDOUT: %.loc16_9.2: type = converted %.loc16_9.1, constants.%.1 [template = constants.%.1]
  728. // CHECK:STDOUT: %e.var: ref %.1 = var e
  729. // CHECK:STDOUT: %e: ref %.1 = bind_name e, %e.var
  730. // CHECK:STDOUT: }
  731. // CHECK:STDOUT:
  732. // CHECK:STDOUT: extern fn @A();
  733. // CHECK:STDOUT:
  734. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  735. // CHECK:STDOUT:
  736. // CHECK:STDOUT: extern fn @B(%b: i32) -> i32;
  737. // CHECK:STDOUT:
  738. // CHECK:STDOUT: extern fn @C(%c: %.3) -> %.4;
  739. // CHECK:STDOUT:
  740. // CHECK:STDOUT: extern fn @D();
  741. // CHECK:STDOUT:
  742. // CHECK:STDOUT: extern fn @E();
  743. // CHECK:STDOUT:
  744. // CHECK:STDOUT: fn @__global_init() {
  745. // CHECK:STDOUT: !entry:
  746. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [template = constants.%A]
  747. // CHECK:STDOUT: %A.call: init %.1 = call %A.ref()
  748. // CHECK:STDOUT: assign file.%a.var, %A.call
  749. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, file.%B.decl [template = constants.%B]
  750. // CHECK:STDOUT: %.loc13: i32 = int_literal 1 [template = constants.%.5]
  751. // CHECK:STDOUT: %B.call: init i32 = call %B.ref(%.loc13)
  752. // CHECK:STDOUT: assign file.%b.var, %B.call
  753. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [template = constants.%C]
  754. // CHECK:STDOUT: %.loc14_23: i32 = int_literal 1 [template = constants.%.5]
  755. // CHECK:STDOUT: %.loc14_25: %.3 = tuple_literal (%.loc14_23)
  756. // CHECK:STDOUT: %tuple: %.3 = tuple_value (%.loc14_23) [template = constants.%tuple]
  757. // CHECK:STDOUT: %.loc14_21: %.3 = converted %.loc14_25, %tuple [template = constants.%tuple]
  758. // CHECK:STDOUT: %C.call: init %.4 = call %C.ref(%.loc14_21)
  759. // CHECK:STDOUT: assign file.%c.var, %C.call
  760. // CHECK:STDOUT: %D.ref: %D.type = name_ref D, file.%D.decl [template = constants.%D]
  761. // CHECK:STDOUT: %D.call: init %.1 = call %D.ref()
  762. // CHECK:STDOUT: assign file.%d.var, %D.call
  763. // CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
  764. // CHECK:STDOUT: %E.ref: %E.type = name_ref E, file.%E.decl [template = constants.%E]
  765. // CHECK:STDOUT: %E.call: init %.1 = call %E.ref()
  766. // CHECK:STDOUT: assign file.%e.var, %E.call
  767. // CHECK:STDOUT: return
  768. // CHECK:STDOUT: }
  769. // CHECK:STDOUT:
  770. // CHECK:STDOUT: --- redecl_extern_api.carbon
  771. // CHECK:STDOUT:
  772. // CHECK:STDOUT: constants {
  773. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  774. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  775. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  776. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  777. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  778. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  779. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  780. // CHECK:STDOUT: %.2: type = tuple_type (type) [template]
  781. // CHECK:STDOUT: %.3: type = tuple_type (i32) [template]
  782. // CHECK:STDOUT: %.4: type = struct_type {.c: i32} [template]
  783. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  784. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  785. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  786. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  787. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  788. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  789. // CHECK:STDOUT: %.5: i32 = int_literal 1 [template]
  790. // CHECK:STDOUT: %tuple: %.3 = tuple_value (%.5) [template]
  791. // CHECK:STDOUT: }
  792. // CHECK:STDOUT:
  793. // CHECK:STDOUT: imports {
  794. // CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//extern_api, inst+3, loaded [template = constants.%A]
  795. // CHECK:STDOUT: %import_ref.2: %B.type = import_ref Main//extern_api, inst+21, loaded [template = constants.%B]
  796. // CHECK:STDOUT: %import_ref.3: %C.type = import_ref Main//extern_api, inst+41, loaded [template = constants.%C]
  797. // CHECK:STDOUT: %import_ref.4: %D.type = import_ref Main//extern_api, inst+44, loaded [template = constants.%D]
  798. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//extern_api, inst+47, loaded
  799. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  800. // CHECK:STDOUT: .E = file.%E.decl
  801. // CHECK:STDOUT: }
  802. // CHECK:STDOUT: %import_ref.6: %E.type = import_ref Main//extern_api, inst+48, loaded [template = constants.%E]
  803. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  804. // CHECK:STDOUT: .Int32 = %import_ref.7
  805. // CHECK:STDOUT: import Core//prelude
  806. // CHECK:STDOUT: import Core//prelude/operators
  807. // CHECK:STDOUT: import Core//prelude/types
  808. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  809. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  810. // CHECK:STDOUT: import Core//prelude/operators/comparison
  811. // CHECK:STDOUT: import Core//prelude/types/bool
  812. // CHECK:STDOUT: }
  813. // CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  814. // CHECK:STDOUT: }
  815. // CHECK:STDOUT:
  816. // CHECK:STDOUT: file {
  817. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  818. // CHECK:STDOUT: .A = %A.decl
  819. // CHECK:STDOUT: .B = %B.decl
  820. // CHECK:STDOUT: .C = %C.decl
  821. // CHECK:STDOUT: .D = %D.decl
  822. // CHECK:STDOUT: .NS = imports.%NS
  823. // CHECK:STDOUT: .Core = imports.%Core
  824. // CHECK:STDOUT: .a = %a
  825. // CHECK:STDOUT: .b = %b.loc13
  826. // CHECK:STDOUT: .c = %c.loc14
  827. // CHECK:STDOUT: .d = %d
  828. // CHECK:STDOUT: .e = %e
  829. // CHECK:STDOUT: }
  830. // CHECK:STDOUT: %Core.import = import Core
  831. // CHECK:STDOUT: %default.import = import <invalid>
  832. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {}
  833. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {
  834. // CHECK:STDOUT: %int.make_type_32.loc7_16: init type = call constants.%Int32() [template = i32]
  835. // CHECK:STDOUT: %.loc7_16.1: type = value_of_initializer %int.make_type_32.loc7_16 [template = i32]
  836. // CHECK:STDOUT: %.loc7_16.2: type = converted %int.make_type_32.loc7_16, %.loc7_16.1 [template = i32]
  837. // CHECK:STDOUT: %b.loc7_13.1: i32 = param b
  838. // CHECK:STDOUT: %b.loc7_13.2: i32 = bind_name b, %b.loc7_13.1
  839. // CHECK:STDOUT: %int.make_type_32.loc7_24: init type = call constants.%Int32() [template = i32]
  840. // CHECK:STDOUT: %.loc7_24.1: type = value_of_initializer %int.make_type_32.loc7_24 [template = i32]
  841. // CHECK:STDOUT: %.loc7_24.2: type = converted %int.make_type_32.loc7_24, %.loc7_24.1 [template = i32]
  842. // CHECK:STDOUT: %return.var.loc7: ref i32 = var <return slot>
  843. // CHECK:STDOUT: }
  844. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {
  845. // CHECK:STDOUT: %int.make_type_32.loc8_17: init type = call constants.%Int32() [template = i32]
  846. // CHECK:STDOUT: %.loc8_21.1: %.2 = tuple_literal (%int.make_type_32.loc8_17)
  847. // CHECK:STDOUT: %.loc8_21.2: type = value_of_initializer %int.make_type_32.loc8_17 [template = i32]
  848. // CHECK:STDOUT: %.loc8_21.3: type = converted %int.make_type_32.loc8_17, %.loc8_21.2 [template = i32]
  849. // CHECK:STDOUT: %.loc8_21.4: type = converted %.loc8_21.1, constants.%.3 [template = constants.%.3]
  850. // CHECK:STDOUT: %c.loc8_13.1: %.3 = param c
  851. // CHECK:STDOUT: %c.loc8_13.2: %.3 = bind_name c, %c.loc8_13.1
  852. // CHECK:STDOUT: %int.make_type_32.loc8_32: init type = call constants.%Int32() [template = i32]
  853. // CHECK:STDOUT: %.loc8_32.1: type = value_of_initializer %int.make_type_32.loc8_32 [template = i32]
  854. // CHECK:STDOUT: %.loc8_32.2: type = converted %int.make_type_32.loc8_32, %.loc8_32.1 [template = i32]
  855. // CHECK:STDOUT: %.loc8_35: type = struct_type {.c: i32} [template = constants.%.4]
  856. // CHECK:STDOUT: %return.var.loc8: ref %.4 = var <return slot>
  857. // CHECK:STDOUT: }
  858. // CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [template = constants.%D] {}
  859. // CHECK:STDOUT: %E.decl: %E.type = fn_decl @E [template = constants.%E] {}
  860. // CHECK:STDOUT: %.loc12_9.1: %.1 = tuple_literal ()
  861. // CHECK:STDOUT: %.loc12_9.2: type = converted %.loc12_9.1, constants.%.1 [template = constants.%.1]
  862. // CHECK:STDOUT: %a.var: ref %.1 = var a
  863. // CHECK:STDOUT: %a: ref %.1 = bind_name a, %a.var
  864. // CHECK:STDOUT: %int.make_type_32.loc13: init type = call constants.%Int32() [template = i32]
  865. // CHECK:STDOUT: %.loc13_8.1: type = value_of_initializer %int.make_type_32.loc13 [template = i32]
  866. // CHECK:STDOUT: %.loc13_8.2: type = converted %int.make_type_32.loc13, %.loc13_8.1 [template = i32]
  867. // CHECK:STDOUT: %b.var: ref i32 = var b
  868. // CHECK:STDOUT: %b.loc13: ref i32 = bind_name b, %b.var
  869. // CHECK:STDOUT: %int.make_type_32.loc14: init type = call constants.%Int32() [template = i32]
  870. // CHECK:STDOUT: %.loc14_13.1: type = value_of_initializer %int.make_type_32.loc14 [template = i32]
  871. // CHECK:STDOUT: %.loc14_13.2: type = converted %int.make_type_32.loc14, %.loc14_13.1 [template = i32]
  872. // CHECK:STDOUT: %.loc14_16: type = struct_type {.c: i32} [template = constants.%.4]
  873. // CHECK:STDOUT: %c.var: ref %.4 = var c
  874. // CHECK:STDOUT: %c.loc14: ref %.4 = bind_name c, %c.var
  875. // CHECK:STDOUT: %.loc15_9.1: %.1 = tuple_literal ()
  876. // CHECK:STDOUT: %.loc15_9.2: type = converted %.loc15_9.1, constants.%.1 [template = constants.%.1]
  877. // CHECK:STDOUT: %d.var: ref %.1 = var d
  878. // CHECK:STDOUT: %d: ref %.1 = bind_name d, %d.var
  879. // CHECK:STDOUT: %.loc16_9.1: %.1 = tuple_literal ()
  880. // CHECK:STDOUT: %.loc16_9.2: type = converted %.loc16_9.1, constants.%.1 [template = constants.%.1]
  881. // CHECK:STDOUT: %e.var: ref %.1 = var e
  882. // CHECK:STDOUT: %e: ref %.1 = bind_name e, %e.var
  883. // CHECK:STDOUT: }
  884. // CHECK:STDOUT:
  885. // CHECK:STDOUT: extern fn @A();
  886. // CHECK:STDOUT:
  887. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  888. // CHECK:STDOUT:
  889. // CHECK:STDOUT: extern fn @B(%b: i32) -> i32;
  890. // CHECK:STDOUT:
  891. // CHECK:STDOUT: extern fn @C(%c: %.3) -> %.4;
  892. // CHECK:STDOUT:
  893. // CHECK:STDOUT: extern fn @D();
  894. // CHECK:STDOUT:
  895. // CHECK:STDOUT: extern fn @E();
  896. // CHECK:STDOUT:
  897. // CHECK:STDOUT: fn @__global_init() {
  898. // CHECK:STDOUT: !entry:
  899. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [template = constants.%A]
  900. // CHECK:STDOUT: %A.call: init %.1 = call %A.ref()
  901. // CHECK:STDOUT: assign file.%a.var, %A.call
  902. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, file.%B.decl [template = constants.%B]
  903. // CHECK:STDOUT: %.loc13: i32 = int_literal 1 [template = constants.%.5]
  904. // CHECK:STDOUT: %B.call: init i32 = call %B.ref(%.loc13)
  905. // CHECK:STDOUT: assign file.%b.var, %B.call
  906. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [template = constants.%C]
  907. // CHECK:STDOUT: %.loc14_23: i32 = int_literal 1 [template = constants.%.5]
  908. // CHECK:STDOUT: %.loc14_25: %.3 = tuple_literal (%.loc14_23)
  909. // CHECK:STDOUT: %tuple: %.3 = tuple_value (%.loc14_23) [template = constants.%tuple]
  910. // CHECK:STDOUT: %.loc14_21: %.3 = converted %.loc14_25, %tuple [template = constants.%tuple]
  911. // CHECK:STDOUT: %C.call: init %.4 = call %C.ref(%.loc14_21)
  912. // CHECK:STDOUT: assign file.%c.var, %C.call
  913. // CHECK:STDOUT: %D.ref: %D.type = name_ref D, file.%D.decl [template = constants.%D]
  914. // CHECK:STDOUT: %D.call: init %.1 = call %D.ref()
  915. // CHECK:STDOUT: assign file.%d.var, %D.call
  916. // CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
  917. // CHECK:STDOUT: %E.ref: %E.type = name_ref E, file.%E.decl [template = constants.%E]
  918. // CHECK:STDOUT: %E.call: init %.1 = call %E.ref()
  919. // CHECK:STDOUT: assign file.%e.var, %E.call
  920. // CHECK:STDOUT: return
  921. // CHECK:STDOUT: }
  922. // CHECK:STDOUT:
  923. // CHECK:STDOUT: --- fail_todo_merge.carbon
  924. // CHECK:STDOUT:
  925. // CHECK:STDOUT: constants {
  926. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  927. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  928. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  929. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  930. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  931. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  932. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  933. // CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
  934. // CHECK:STDOUT: %.3: type = struct_type {.c: i32} [template]
  935. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  936. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  937. // CHECK:STDOUT: %.4: type = tuple_type (i32) [template]
  938. // CHECK:STDOUT: %tuple: %.4 = tuple_value (%.2) [template]
  939. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  940. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  941. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  942. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  943. // CHECK:STDOUT: }
  944. // CHECK:STDOUT:
  945. // CHECK:STDOUT: imports {
  946. // CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//api, inst+3, loaded [template = constants.%A]
  947. // CHECK:STDOUT: %import_ref.2: %B.type = import_ref Main//api, inst+21, loaded [template = constants.%B]
  948. // CHECK:STDOUT: %import_ref.3: %C.type = import_ref Main//api, inst+41, loaded [template = constants.%C]
  949. // CHECK:STDOUT: %import_ref.4: %D.type = import_ref Main//api, inst+44, loaded [template = constants.%D]
  950. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//api, inst+47, loaded
  951. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  952. // CHECK:STDOUT: .E = %import_ref.6
  953. // CHECK:STDOUT: }
  954. // CHECK:STDOUT: %import_ref.6: %E.type = import_ref Main//api, inst+48, loaded [template = constants.%E]
  955. // CHECK:STDOUT: %import_ref.7 = import_ref Main//extern_api, inst+3, unloaded
  956. // CHECK:STDOUT: %import_ref.8 = import_ref Main//extern_api, inst+21, unloaded
  957. // CHECK:STDOUT: %import_ref.9 = import_ref Main//extern_api, inst+41, unloaded
  958. // CHECK:STDOUT: %import_ref.10 = import_ref Main//extern_api, inst+44, unloaded
  959. // CHECK:STDOUT: %import_ref.11 = import_ref Main//extern_api, inst+48, unloaded
  960. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  961. // CHECK:STDOUT: .Int32 = %import_ref.12
  962. // CHECK:STDOUT: import Core//prelude
  963. // CHECK:STDOUT: import Core//prelude/operators
  964. // CHECK:STDOUT: import Core//prelude/types
  965. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  966. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  967. // CHECK:STDOUT: import Core//prelude/operators/comparison
  968. // CHECK:STDOUT: import Core//prelude/types/bool
  969. // CHECK:STDOUT: }
  970. // CHECK:STDOUT: %import_ref.12: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  971. // CHECK:STDOUT: }
  972. // CHECK:STDOUT:
  973. // CHECK:STDOUT: file {
  974. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  975. // CHECK:STDOUT: .A = imports.%import_ref.1
  976. // CHECK:STDOUT: .B = imports.%import_ref.2
  977. // CHECK:STDOUT: .C = imports.%import_ref.3
  978. // CHECK:STDOUT: .D = imports.%import_ref.4
  979. // CHECK:STDOUT: .NS = imports.%NS
  980. // CHECK:STDOUT: .Core = imports.%Core
  981. // CHECK:STDOUT: .a = %a
  982. // CHECK:STDOUT: .b = %b
  983. // CHECK:STDOUT: .c = %c
  984. // CHECK:STDOUT: .d = %d
  985. // CHECK:STDOUT: .e = %e
  986. // CHECK:STDOUT: }
  987. // CHECK:STDOUT: %Core.import = import Core
  988. // CHECK:STDOUT: %default.import = import <invalid>
  989. // CHECK:STDOUT: %.loc72_9.1: %.1 = tuple_literal ()
  990. // CHECK:STDOUT: %.loc72_9.2: type = converted %.loc72_9.1, constants.%.1 [template = constants.%.1]
  991. // CHECK:STDOUT: %a.var: ref %.1 = var a
  992. // CHECK:STDOUT: %a: ref %.1 = bind_name a, %a.var
  993. // CHECK:STDOUT: %int.make_type_32.loc73: init type = call constants.%Int32() [template = i32]
  994. // CHECK:STDOUT: %.loc73_8.1: type = value_of_initializer %int.make_type_32.loc73 [template = i32]
  995. // CHECK:STDOUT: %.loc73_8.2: type = converted %int.make_type_32.loc73, %.loc73_8.1 [template = i32]
  996. // CHECK:STDOUT: %b.var: ref i32 = var b
  997. // CHECK:STDOUT: %b: ref i32 = bind_name b, %b.var
  998. // CHECK:STDOUT: %int.make_type_32.loc74: init type = call constants.%Int32() [template = i32]
  999. // CHECK:STDOUT: %.loc74_13.1: type = value_of_initializer %int.make_type_32.loc74 [template = i32]
  1000. // CHECK:STDOUT: %.loc74_13.2: type = converted %int.make_type_32.loc74, %.loc74_13.1 [template = i32]
  1001. // CHECK:STDOUT: %.loc74_16: type = struct_type {.c: i32} [template = constants.%.3]
  1002. // CHECK:STDOUT: %c.var: ref %.3 = var c
  1003. // CHECK:STDOUT: %c: ref %.3 = bind_name c, %c.var
  1004. // CHECK:STDOUT: %.loc75_9.1: %.1 = tuple_literal ()
  1005. // CHECK:STDOUT: %.loc75_9.2: type = converted %.loc75_9.1, constants.%.1 [template = constants.%.1]
  1006. // CHECK:STDOUT: %d.var: ref %.1 = var d
  1007. // CHECK:STDOUT: %d: ref %.1 = bind_name d, %d.var
  1008. // CHECK:STDOUT: %.loc76_9.1: %.1 = tuple_literal ()
  1009. // CHECK:STDOUT: %.loc76_9.2: type = converted %.loc76_9.1, constants.%.1 [template = constants.%.1]
  1010. // CHECK:STDOUT: %e.var: ref %.1 = var e
  1011. // CHECK:STDOUT: %e: ref %.1 = bind_name e, %e.var
  1012. // CHECK:STDOUT: }
  1013. // CHECK:STDOUT:
  1014. // CHECK:STDOUT: fn @A();
  1015. // CHECK:STDOUT:
  1016. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  1017. // CHECK:STDOUT:
  1018. // CHECK:STDOUT: fn @B(%b: i32) -> i32;
  1019. // CHECK:STDOUT:
  1020. // CHECK:STDOUT: fn @C(%c: %.4) -> %.3;
  1021. // CHECK:STDOUT:
  1022. // CHECK:STDOUT: extern fn @D();
  1023. // CHECK:STDOUT:
  1024. // CHECK:STDOUT: fn @E();
  1025. // CHECK:STDOUT:
  1026. // CHECK:STDOUT: fn @__global_init() {
  1027. // CHECK:STDOUT: !entry:
  1028. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, imports.%import_ref.1 [template = constants.%A]
  1029. // CHECK:STDOUT: %A.call: init %.1 = call %A.ref()
  1030. // CHECK:STDOUT: assign file.%a.var, %A.call
  1031. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, imports.%import_ref.2 [template = constants.%B]
  1032. // CHECK:STDOUT: %.loc73: i32 = int_literal 1 [template = constants.%.2]
  1033. // CHECK:STDOUT: %B.call: init i32 = call %B.ref(%.loc73)
  1034. // CHECK:STDOUT: assign file.%b.var, %B.call
  1035. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.3 [template = constants.%C]
  1036. // CHECK:STDOUT: %.loc74_23: i32 = int_literal 1 [template = constants.%.2]
  1037. // CHECK:STDOUT: %.loc74_25: %.4 = tuple_literal (%.loc74_23)
  1038. // CHECK:STDOUT: %tuple: %.4 = tuple_value (%.loc74_23) [template = constants.%tuple]
  1039. // CHECK:STDOUT: %.loc74_21: %.4 = converted %.loc74_25, %tuple [template = constants.%tuple]
  1040. // CHECK:STDOUT: %C.call: init %.3 = call %C.ref(%.loc74_21)
  1041. // CHECK:STDOUT: assign file.%c.var, %C.call
  1042. // CHECK:STDOUT: %D.ref: %D.type = name_ref D, imports.%import_ref.4 [template = constants.%D]
  1043. // CHECK:STDOUT: %D.call: init %.1 = call %D.ref()
  1044. // CHECK:STDOUT: assign file.%d.var, %D.call
  1045. // CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
  1046. // CHECK:STDOUT: %E.ref: %E.type = name_ref E, imports.%import_ref.6 [template = constants.%E]
  1047. // CHECK:STDOUT: %E.call: init %.1 = call %E.ref()
  1048. // CHECK:STDOUT: assign file.%e.var, %E.call
  1049. // CHECK:STDOUT: return
  1050. // CHECK:STDOUT: }
  1051. // CHECK:STDOUT:
  1052. // CHECK:STDOUT: --- fail_todo_merge_reverse.carbon
  1053. // CHECK:STDOUT:
  1054. // CHECK:STDOUT: constants {
  1055. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  1056. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  1057. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  1058. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  1059. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  1060. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  1061. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  1062. // CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
  1063. // CHECK:STDOUT: %.3: type = struct_type {.c: i32} [template]
  1064. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  1065. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  1066. // CHECK:STDOUT: %.4: type = tuple_type (i32) [template]
  1067. // CHECK:STDOUT: %tuple: %.4 = tuple_value (%.2) [template]
  1068. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  1069. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  1070. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  1071. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  1072. // CHECK:STDOUT: }
  1073. // CHECK:STDOUT:
  1074. // CHECK:STDOUT: imports {
  1075. // CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//extern_api, inst+3, loaded [template = constants.%A]
  1076. // CHECK:STDOUT: %import_ref.2: %B.type = import_ref Main//extern_api, inst+21, loaded [template = constants.%B]
  1077. // CHECK:STDOUT: %import_ref.3: %C.type = import_ref Main//extern_api, inst+41, loaded [template = constants.%C]
  1078. // CHECK:STDOUT: %import_ref.4: %D.type = import_ref Main//extern_api, inst+44, loaded [template = constants.%D]
  1079. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//extern_api, inst+47, loaded
  1080. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  1081. // CHECK:STDOUT: .E = %import_ref.6
  1082. // CHECK:STDOUT: }
  1083. // CHECK:STDOUT: %import_ref.6: %E.type = import_ref Main//extern_api, inst+48, loaded [template = constants.%E]
  1084. // CHECK:STDOUT: %import_ref.7 = import_ref Main//api, inst+3, unloaded
  1085. // CHECK:STDOUT: %import_ref.8 = import_ref Main//api, inst+21, unloaded
  1086. // CHECK:STDOUT: %import_ref.9 = import_ref Main//api, inst+41, unloaded
  1087. // CHECK:STDOUT: %import_ref.10 = import_ref Main//api, inst+44, unloaded
  1088. // CHECK:STDOUT: %import_ref.11 = import_ref Main//api, inst+48, unloaded
  1089. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  1090. // CHECK:STDOUT: .Int32 = %import_ref.12
  1091. // CHECK:STDOUT: import Core//prelude
  1092. // CHECK:STDOUT: import Core//prelude/operators
  1093. // CHECK:STDOUT: import Core//prelude/types
  1094. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  1095. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  1096. // CHECK:STDOUT: import Core//prelude/operators/comparison
  1097. // CHECK:STDOUT: import Core//prelude/types/bool
  1098. // CHECK:STDOUT: }
  1099. // CHECK:STDOUT: %import_ref.12: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  1100. // CHECK:STDOUT: }
  1101. // CHECK:STDOUT:
  1102. // CHECK:STDOUT: file {
  1103. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  1104. // CHECK:STDOUT: .A = imports.%import_ref.1
  1105. // CHECK:STDOUT: .B = imports.%import_ref.2
  1106. // CHECK:STDOUT: .C = imports.%import_ref.3
  1107. // CHECK:STDOUT: .D = imports.%import_ref.4
  1108. // CHECK:STDOUT: .NS = imports.%NS
  1109. // CHECK:STDOUT: .Core = imports.%Core
  1110. // CHECK:STDOUT: .a = %a
  1111. // CHECK:STDOUT: .b = %b
  1112. // CHECK:STDOUT: .c = %c
  1113. // CHECK:STDOUT: .d = %d
  1114. // CHECK:STDOUT: .e = %e
  1115. // CHECK:STDOUT: }
  1116. // CHECK:STDOUT: %Core.import = import Core
  1117. // CHECK:STDOUT: %default.import = import <invalid>
  1118. // CHECK:STDOUT: %.loc72_9.1: %.1 = tuple_literal ()
  1119. // CHECK:STDOUT: %.loc72_9.2: type = converted %.loc72_9.1, constants.%.1 [template = constants.%.1]
  1120. // CHECK:STDOUT: %a.var: ref %.1 = var a
  1121. // CHECK:STDOUT: %a: ref %.1 = bind_name a, %a.var
  1122. // CHECK:STDOUT: %int.make_type_32.loc73: init type = call constants.%Int32() [template = i32]
  1123. // CHECK:STDOUT: %.loc73_8.1: type = value_of_initializer %int.make_type_32.loc73 [template = i32]
  1124. // CHECK:STDOUT: %.loc73_8.2: type = converted %int.make_type_32.loc73, %.loc73_8.1 [template = i32]
  1125. // CHECK:STDOUT: %b.var: ref i32 = var b
  1126. // CHECK:STDOUT: %b: ref i32 = bind_name b, %b.var
  1127. // CHECK:STDOUT: %int.make_type_32.loc74: init type = call constants.%Int32() [template = i32]
  1128. // CHECK:STDOUT: %.loc74_13.1: type = value_of_initializer %int.make_type_32.loc74 [template = i32]
  1129. // CHECK:STDOUT: %.loc74_13.2: type = converted %int.make_type_32.loc74, %.loc74_13.1 [template = i32]
  1130. // CHECK:STDOUT: %.loc74_16: type = struct_type {.c: i32} [template = constants.%.3]
  1131. // CHECK:STDOUT: %c.var: ref %.3 = var c
  1132. // CHECK:STDOUT: %c: ref %.3 = bind_name c, %c.var
  1133. // CHECK:STDOUT: %.loc75_9.1: %.1 = tuple_literal ()
  1134. // CHECK:STDOUT: %.loc75_9.2: type = converted %.loc75_9.1, constants.%.1 [template = constants.%.1]
  1135. // CHECK:STDOUT: %d.var: ref %.1 = var d
  1136. // CHECK:STDOUT: %d: ref %.1 = bind_name d, %d.var
  1137. // CHECK:STDOUT: %.loc76_9.1: %.1 = tuple_literal ()
  1138. // CHECK:STDOUT: %.loc76_9.2: type = converted %.loc76_9.1, constants.%.1 [template = constants.%.1]
  1139. // CHECK:STDOUT: %e.var: ref %.1 = var e
  1140. // CHECK:STDOUT: %e: ref %.1 = bind_name e, %e.var
  1141. // CHECK:STDOUT: }
  1142. // CHECK:STDOUT:
  1143. // CHECK:STDOUT: extern fn @A();
  1144. // CHECK:STDOUT:
  1145. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  1146. // CHECK:STDOUT:
  1147. // CHECK:STDOUT: extern fn @B(%b: i32) -> i32;
  1148. // CHECK:STDOUT:
  1149. // CHECK:STDOUT: extern fn @C(%c: %.4) -> %.3;
  1150. // CHECK:STDOUT:
  1151. // CHECK:STDOUT: extern fn @D();
  1152. // CHECK:STDOUT:
  1153. // CHECK:STDOUT: extern fn @E();
  1154. // CHECK:STDOUT:
  1155. // CHECK:STDOUT: fn @__global_init() {
  1156. // CHECK:STDOUT: !entry:
  1157. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, imports.%import_ref.1 [template = constants.%A]
  1158. // CHECK:STDOUT: %A.call: init %.1 = call %A.ref()
  1159. // CHECK:STDOUT: assign file.%a.var, %A.call
  1160. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, imports.%import_ref.2 [template = constants.%B]
  1161. // CHECK:STDOUT: %.loc73: i32 = int_literal 1 [template = constants.%.2]
  1162. // CHECK:STDOUT: %B.call: init i32 = call %B.ref(%.loc73)
  1163. // CHECK:STDOUT: assign file.%b.var, %B.call
  1164. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.3 [template = constants.%C]
  1165. // CHECK:STDOUT: %.loc74_23: i32 = int_literal 1 [template = constants.%.2]
  1166. // CHECK:STDOUT: %.loc74_25: %.4 = tuple_literal (%.loc74_23)
  1167. // CHECK:STDOUT: %tuple: %.4 = tuple_value (%.loc74_23) [template = constants.%tuple]
  1168. // CHECK:STDOUT: %.loc74_21: %.4 = converted %.loc74_25, %tuple [template = constants.%tuple]
  1169. // CHECK:STDOUT: %C.call: init %.3 = call %C.ref(%.loc74_21)
  1170. // CHECK:STDOUT: assign file.%c.var, %C.call
  1171. // CHECK:STDOUT: %D.ref: %D.type = name_ref D, imports.%import_ref.4 [template = constants.%D]
  1172. // CHECK:STDOUT: %D.call: init %.1 = call %D.ref()
  1173. // CHECK:STDOUT: assign file.%d.var, %D.call
  1174. // CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
  1175. // CHECK:STDOUT: %E.ref: %E.type = name_ref E, imports.%import_ref.6 [template = constants.%E]
  1176. // CHECK:STDOUT: %E.call: init %.1 = call %E.ref()
  1177. // CHECK:STDOUT: assign file.%e.var, %E.call
  1178. // CHECK:STDOUT: return
  1179. // CHECK:STDOUT: }
  1180. // CHECK:STDOUT:
  1181. // CHECK:STDOUT: --- decl_after_use.carbon
  1182. // CHECK:STDOUT:
  1183. // CHECK:STDOUT: constants {
  1184. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  1185. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  1186. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  1187. // CHECK:STDOUT: }
  1188. // CHECK:STDOUT:
  1189. // CHECK:STDOUT: imports {
  1190. // CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//extern_api, inst+3, loaded [template = constants.%A]
  1191. // CHECK:STDOUT: %import_ref.2 = import_ref Main//extern_api, inst+21, unloaded
  1192. // CHECK:STDOUT: %import_ref.3 = import_ref Main//extern_api, inst+41, unloaded
  1193. // CHECK:STDOUT: %import_ref.4 = import_ref Main//extern_api, inst+44, unloaded
  1194. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//extern_api, inst+47, loaded
  1195. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  1196. // CHECK:STDOUT: .E = %import_ref.6
  1197. // CHECK:STDOUT: }
  1198. // CHECK:STDOUT: %import_ref.6 = import_ref Main//extern_api, inst+48, unloaded
  1199. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  1200. // CHECK:STDOUT: import Core//prelude
  1201. // CHECK:STDOUT: import Core//prelude/operators
  1202. // CHECK:STDOUT: import Core//prelude/types
  1203. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  1204. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  1205. // CHECK:STDOUT: import Core//prelude/operators/comparison
  1206. // CHECK:STDOUT: import Core//prelude/types/bool
  1207. // CHECK:STDOUT: }
  1208. // CHECK:STDOUT: }
  1209. // CHECK:STDOUT:
  1210. // CHECK:STDOUT: file {
  1211. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  1212. // CHECK:STDOUT: .A = %A.decl
  1213. // CHECK:STDOUT: .B = imports.%import_ref.2
  1214. // CHECK:STDOUT: .C = imports.%import_ref.3
  1215. // CHECK:STDOUT: .D = imports.%import_ref.4
  1216. // CHECK:STDOUT: .NS = imports.%NS
  1217. // CHECK:STDOUT: .Core = imports.%Core
  1218. // CHECK:STDOUT: .a = %a
  1219. // CHECK:STDOUT: }
  1220. // CHECK:STDOUT: %Core.import = import Core
  1221. // CHECK:STDOUT: %default.import = import <invalid>
  1222. // CHECK:STDOUT: %.loc6_9.1: %.1 = tuple_literal ()
  1223. // CHECK:STDOUT: %.loc6_9.2: type = converted %.loc6_9.1, constants.%.1 [template = constants.%.1]
  1224. // CHECK:STDOUT: %a.var: ref %.1 = var a
  1225. // CHECK:STDOUT: %a: ref %.1 = bind_name a, %a.var
  1226. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {}
  1227. // CHECK:STDOUT: }
  1228. // CHECK:STDOUT:
  1229. // CHECK:STDOUT: fn @A();
  1230. // CHECK:STDOUT:
  1231. // CHECK:STDOUT: fn @__global_init() {
  1232. // CHECK:STDOUT: !entry:
  1233. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, imports.%import_ref.1 [template = constants.%A]
  1234. // CHECK:STDOUT: %A.call: init %.1 = call %A.ref()
  1235. // CHECK:STDOUT: assign file.%a.var, %A.call
  1236. // CHECK:STDOUT: return
  1237. // CHECK:STDOUT: }
  1238. // CHECK:STDOUT:
  1239. // CHECK:STDOUT: --- fail_redecl_mismatch_after_use.carbon
  1240. // CHECK:STDOUT:
  1241. // CHECK:STDOUT: constants {
  1242. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  1243. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  1244. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  1245. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  1246. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  1247. // CHECK:STDOUT: %.type: type = fn_type @.1 [template]
  1248. // CHECK:STDOUT: %.2: %.type = struct_value () [template]
  1249. // CHECK:STDOUT: }
  1250. // CHECK:STDOUT:
  1251. // CHECK:STDOUT: imports {
  1252. // CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//extern_api, inst+3, loaded [template = constants.%A]
  1253. // CHECK:STDOUT: %import_ref.2 = import_ref Main//extern_api, inst+21, unloaded
  1254. // CHECK:STDOUT: %import_ref.3 = import_ref Main//extern_api, inst+41, unloaded
  1255. // CHECK:STDOUT: %import_ref.4 = import_ref Main//extern_api, inst+44, unloaded
  1256. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//extern_api, inst+47, loaded
  1257. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  1258. // CHECK:STDOUT: .E = %import_ref.6
  1259. // CHECK:STDOUT: }
  1260. // CHECK:STDOUT: %import_ref.6 = import_ref Main//extern_api, inst+48, unloaded
  1261. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  1262. // CHECK:STDOUT: .Int32 = %import_ref.7
  1263. // CHECK:STDOUT: import Core//prelude
  1264. // CHECK:STDOUT: import Core//prelude/operators
  1265. // CHECK:STDOUT: import Core//prelude/types
  1266. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  1267. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  1268. // CHECK:STDOUT: import Core//prelude/operators/comparison
  1269. // CHECK:STDOUT: import Core//prelude/types/bool
  1270. // CHECK:STDOUT: }
  1271. // CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  1272. // CHECK:STDOUT: }
  1273. // CHECK:STDOUT:
  1274. // CHECK:STDOUT: file {
  1275. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  1276. // CHECK:STDOUT: .A = imports.%import_ref.1
  1277. // CHECK:STDOUT: .B = imports.%import_ref.2
  1278. // CHECK:STDOUT: .C = imports.%import_ref.3
  1279. // CHECK:STDOUT: .D = imports.%import_ref.4
  1280. // CHECK:STDOUT: .NS = imports.%NS
  1281. // CHECK:STDOUT: .Core = imports.%Core
  1282. // CHECK:STDOUT: .a = %a
  1283. // CHECK:STDOUT: }
  1284. // CHECK:STDOUT: %Core.import = import Core
  1285. // CHECK:STDOUT: %default.import = import <invalid>
  1286. // CHECK:STDOUT: %.loc6_9.1: %.1 = tuple_literal ()
  1287. // CHECK:STDOUT: %.loc6_9.2: type = converted %.loc6_9.1, constants.%.1 [template = constants.%.1]
  1288. // CHECK:STDOUT: %a.var: ref %.1 = var a
  1289. // CHECK:STDOUT: %a: ref %.1 = bind_name a, %a.var
  1290. // CHECK:STDOUT: %.decl: %.type = fn_decl @.1 [template = constants.%.2] {
  1291. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  1292. // CHECK:STDOUT: %.loc18_11.1: type = value_of_initializer %int.make_type_32 [template = i32]
  1293. // CHECK:STDOUT: %.loc18_11.2: type = converted %int.make_type_32, %.loc18_11.1 [template = i32]
  1294. // CHECK:STDOUT: @.1.%return: ref i32 = var <return slot>
  1295. // CHECK:STDOUT: }
  1296. // CHECK:STDOUT: }
  1297. // CHECK:STDOUT:
  1298. // CHECK:STDOUT: extern fn @A();
  1299. // CHECK:STDOUT:
  1300. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  1301. // CHECK:STDOUT:
  1302. // CHECK:STDOUT: fn @.1() -> i32;
  1303. // CHECK:STDOUT:
  1304. // CHECK:STDOUT: fn @__global_init() {
  1305. // CHECK:STDOUT: !entry:
  1306. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, imports.%import_ref.1 [template = constants.%A]
  1307. // CHECK:STDOUT: %A.call: init %.1 = call %A.ref()
  1308. // CHECK:STDOUT: assign file.%a.var, %A.call
  1309. // CHECK:STDOUT: return
  1310. // CHECK:STDOUT: }
  1311. // CHECK:STDOUT:
  1312. // CHECK:STDOUT: --- todo_fail_extern_after_use.carbon
  1313. // CHECK:STDOUT:
  1314. // CHECK:STDOUT: constants {
  1315. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  1316. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  1317. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  1318. // CHECK:STDOUT: }
  1319. // CHECK:STDOUT:
  1320. // CHECK:STDOUT: imports {
  1321. // CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//api, inst+3, loaded [template = constants.%A]
  1322. // CHECK:STDOUT: %import_ref.2 = import_ref Main//api, inst+21, unloaded
  1323. // CHECK:STDOUT: %import_ref.3 = import_ref Main//api, inst+41, unloaded
  1324. // CHECK:STDOUT: %import_ref.4 = import_ref Main//api, inst+44, unloaded
  1325. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//api, inst+47, loaded
  1326. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  1327. // CHECK:STDOUT: .E = %import_ref.6
  1328. // CHECK:STDOUT: }
  1329. // CHECK:STDOUT: %import_ref.6 = import_ref Main//api, inst+48, unloaded
  1330. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  1331. // CHECK:STDOUT: import Core//prelude
  1332. // CHECK:STDOUT: import Core//prelude/operators
  1333. // CHECK:STDOUT: import Core//prelude/types
  1334. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  1335. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  1336. // CHECK:STDOUT: import Core//prelude/operators/comparison
  1337. // CHECK:STDOUT: import Core//prelude/types/bool
  1338. // CHECK:STDOUT: }
  1339. // CHECK:STDOUT: }
  1340. // CHECK:STDOUT:
  1341. // CHECK:STDOUT: file {
  1342. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  1343. // CHECK:STDOUT: .A = %A.decl
  1344. // CHECK:STDOUT: .B = imports.%import_ref.2
  1345. // CHECK:STDOUT: .C = imports.%import_ref.3
  1346. // CHECK:STDOUT: .D = imports.%import_ref.4
  1347. // CHECK:STDOUT: .NS = imports.%NS
  1348. // CHECK:STDOUT: .Core = imports.%Core
  1349. // CHECK:STDOUT: .a = %a
  1350. // CHECK:STDOUT: }
  1351. // CHECK:STDOUT: %Core.import = import Core
  1352. // CHECK:STDOUT: %default.import = import <invalid>
  1353. // CHECK:STDOUT: %.loc6_9.1: %.1 = tuple_literal ()
  1354. // CHECK:STDOUT: %.loc6_9.2: type = converted %.loc6_9.1, constants.%.1 [template = constants.%.1]
  1355. // CHECK:STDOUT: %a.var: ref %.1 = var a
  1356. // CHECK:STDOUT: %a: ref %.1 = bind_name a, %a.var
  1357. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {}
  1358. // CHECK:STDOUT: }
  1359. // CHECK:STDOUT:
  1360. // CHECK:STDOUT: extern fn @A();
  1361. // CHECK:STDOUT:
  1362. // CHECK:STDOUT: fn @__global_init() {
  1363. // CHECK:STDOUT: !entry:
  1364. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, imports.%import_ref.1 [template = constants.%A]
  1365. // CHECK:STDOUT: %A.call: init %.1 = call %A.ref()
  1366. // CHECK:STDOUT: assign file.%a.var, %A.call
  1367. // CHECK:STDOUT: return
  1368. // CHECK:STDOUT: }
  1369. // CHECK:STDOUT:
  1370. // CHECK:STDOUT: --- unloaded.carbon
  1371. // CHECK:STDOUT:
  1372. // CHECK:STDOUT: imports {
  1373. // CHECK:STDOUT: %import_ref.1 = import_ref Main//api, inst+3, unloaded
  1374. // CHECK:STDOUT: %import_ref.2 = import_ref Main//api, inst+21, unloaded
  1375. // CHECK:STDOUT: %import_ref.3 = import_ref Main//api, inst+41, unloaded
  1376. // CHECK:STDOUT: %import_ref.4 = import_ref Main//api, inst+44, unloaded
  1377. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//api, inst+47, loaded
  1378. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  1379. // CHECK:STDOUT: .E = %import_ref.6
  1380. // CHECK:STDOUT: }
  1381. // CHECK:STDOUT: %import_ref.6 = import_ref Main//api, inst+48, unloaded
  1382. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  1383. // CHECK:STDOUT: import Core//prelude
  1384. // CHECK:STDOUT: import Core//prelude/operators
  1385. // CHECK:STDOUT: import Core//prelude/types
  1386. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  1387. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  1388. // CHECK:STDOUT: import Core//prelude/operators/comparison
  1389. // CHECK:STDOUT: import Core//prelude/types/bool
  1390. // CHECK:STDOUT: }
  1391. // CHECK:STDOUT: }
  1392. // CHECK:STDOUT:
  1393. // CHECK:STDOUT: file {
  1394. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  1395. // CHECK:STDOUT: .A = imports.%import_ref.1
  1396. // CHECK:STDOUT: .B = imports.%import_ref.2
  1397. // CHECK:STDOUT: .C = imports.%import_ref.3
  1398. // CHECK:STDOUT: .D = imports.%import_ref.4
  1399. // CHECK:STDOUT: .NS = imports.%NS
  1400. // CHECK:STDOUT: .Core = imports.%Core
  1401. // CHECK:STDOUT: }
  1402. // CHECK:STDOUT: %Core.import = import Core
  1403. // CHECK:STDOUT: %default.import = import <invalid>
  1404. // CHECK:STDOUT: }
  1405. // CHECK:STDOUT:
  1406. // CHECK:STDOUT: --- unloaded_extern.carbon
  1407. // CHECK:STDOUT:
  1408. // CHECK:STDOUT: imports {
  1409. // CHECK:STDOUT: %import_ref.1 = import_ref Main//extern_api, inst+3, unloaded
  1410. // CHECK:STDOUT: %import_ref.2 = import_ref Main//extern_api, inst+21, unloaded
  1411. // CHECK:STDOUT: %import_ref.3 = import_ref Main//extern_api, inst+41, unloaded
  1412. // CHECK:STDOUT: %import_ref.4 = import_ref Main//extern_api, inst+44, unloaded
  1413. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//extern_api, inst+47, loaded
  1414. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  1415. // CHECK:STDOUT: .E = %import_ref.6
  1416. // CHECK:STDOUT: }
  1417. // CHECK:STDOUT: %import_ref.6 = import_ref Main//extern_api, inst+48, unloaded
  1418. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  1419. // CHECK:STDOUT: import Core//prelude
  1420. // CHECK:STDOUT: import Core//prelude/operators
  1421. // CHECK:STDOUT: import Core//prelude/types
  1422. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  1423. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  1424. // CHECK:STDOUT: import Core//prelude/operators/comparison
  1425. // CHECK:STDOUT: import Core//prelude/types/bool
  1426. // CHECK:STDOUT: }
  1427. // CHECK:STDOUT: }
  1428. // CHECK:STDOUT:
  1429. // CHECK:STDOUT: file {
  1430. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  1431. // CHECK:STDOUT: .A = imports.%import_ref.1
  1432. // CHECK:STDOUT: .B = imports.%import_ref.2
  1433. // CHECK:STDOUT: .C = imports.%import_ref.3
  1434. // CHECK:STDOUT: .D = imports.%import_ref.4
  1435. // CHECK:STDOUT: .NS = imports.%NS
  1436. // CHECK:STDOUT: .Core = imports.%Core
  1437. // CHECK:STDOUT: }
  1438. // CHECK:STDOUT: %Core.import = import Core
  1439. // CHECK:STDOUT: %default.import = import <invalid>
  1440. // CHECK:STDOUT: }
  1441. // CHECK:STDOUT:
  1442. // CHECK:STDOUT: --- fail_todo_loaded_merge.carbon
  1443. // CHECK:STDOUT:
  1444. // CHECK:STDOUT: imports {
  1445. // CHECK:STDOUT: %import_ref.1 = import_ref Main//api, inst+3, unloaded
  1446. // CHECK:STDOUT: %import_ref.2 = import_ref Main//api, inst+21, unloaded
  1447. // CHECK:STDOUT: %import_ref.3 = import_ref Main//api, inst+41, unloaded
  1448. // CHECK:STDOUT: %import_ref.4 = import_ref Main//api, inst+44, unloaded
  1449. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//api, inst+47, loaded
  1450. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  1451. // CHECK:STDOUT: .E = %import_ref.6
  1452. // CHECK:STDOUT: }
  1453. // CHECK:STDOUT: %import_ref.6 = import_ref Main//api, inst+48, unloaded
  1454. // CHECK:STDOUT: %import_ref.7 = import_ref Main//extern_api, inst+3, unloaded
  1455. // CHECK:STDOUT: %import_ref.8 = import_ref Main//extern_api, inst+21, unloaded
  1456. // CHECK:STDOUT: %import_ref.9 = import_ref Main//extern_api, inst+41, unloaded
  1457. // CHECK:STDOUT: %import_ref.10 = import_ref Main//extern_api, inst+44, unloaded
  1458. // CHECK:STDOUT: %import_ref.11 = import_ref Main//extern_api, inst+48, unloaded
  1459. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  1460. // CHECK:STDOUT: import Core//prelude
  1461. // CHECK:STDOUT: import Core//prelude/operators
  1462. // CHECK:STDOUT: import Core//prelude/types
  1463. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  1464. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  1465. // CHECK:STDOUT: import Core//prelude/operators/comparison
  1466. // CHECK:STDOUT: import Core//prelude/types/bool
  1467. // CHECK:STDOUT: }
  1468. // CHECK:STDOUT: }
  1469. // CHECK:STDOUT:
  1470. // CHECK:STDOUT: file {
  1471. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  1472. // CHECK:STDOUT: .A = imports.%import_ref.1
  1473. // CHECK:STDOUT: .B = imports.%import_ref.2
  1474. // CHECK:STDOUT: .C = imports.%import_ref.3
  1475. // CHECK:STDOUT: .D = imports.%import_ref.4
  1476. // CHECK:STDOUT: .NS = imports.%NS
  1477. // CHECK:STDOUT: .Core = imports.%Core
  1478. // CHECK:STDOUT: }
  1479. // CHECK:STDOUT: %Core.import = import Core
  1480. // CHECK:STDOUT: %default.import = import <invalid>
  1481. // CHECK:STDOUT: }
  1482. // CHECK:STDOUT: