import.carbon 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206
  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 "[[@TEST_NAME]]";
  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 "[[@TEST_NAME]]";
  23. extern library "redecl_extern_api" fn A();
  24. extern library "redecl_extern_api" fn B(b: i32) -> i32;
  25. extern library "redecl_extern_api" fn C(c: (i32,)) -> {.c: i32};
  26. extern library "redecl_extern_api" fn D();
  27. namespace NS;
  28. extern library "redecl_extern_api" fn NS.E();
  29. // ============================================================================
  30. // Test files
  31. // ============================================================================
  32. // --- basics.carbon
  33. library "[[@TEST_NAME]]";
  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. // --- fail_redecl_api.carbon
  41. library "[[@TEST_NAME]]";
  42. import library "api";
  43. // CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+8]]:1: error: redeclarations of `fn A` must match use of `extern`
  44. // CHECK:STDERR: extern fn A();
  45. // CHECK:STDERR: ^~~~~~~~~~~~~~
  46. // CHECK:STDERR: fail_redecl_api.carbon:[[@LINE-5]]:1: in import
  47. // CHECK:STDERR: api.carbon:4:1: note: previously declared here
  48. // CHECK:STDERR: fn A();
  49. // CHECK:STDERR: ^~~~~~~
  50. // CHECK:STDERR:
  51. extern fn A();
  52. // CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+8]]:1: error: redeclarations of `fn B` must match use of `extern`
  53. // CHECK:STDERR: extern fn B(b: i32) -> i32;
  54. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  55. // CHECK:STDERR: fail_redecl_api.carbon:[[@LINE-14]]:1: in import
  56. // CHECK:STDERR: api.carbon:5:1: note: previously declared here
  57. // CHECK:STDERR: fn B(b: i32) -> i32;
  58. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
  59. // CHECK:STDERR:
  60. extern fn B(b: i32) -> i32;
  61. // CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+8]]:1: error: redeclarations of `fn C` must match use of `extern`
  62. // CHECK:STDERR: extern fn C(c: (i32,)) -> {.c: i32};
  63. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  64. // CHECK:STDERR: fail_redecl_api.carbon:[[@LINE-23]]:1: in import
  65. // CHECK:STDERR: api.carbon:6:1: note: previously declared here
  66. // CHECK:STDERR: fn C(c: (i32,)) -> {.c: i32};
  67. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  68. // CHECK:STDERR:
  69. extern fn C(c: (i32,)) -> {.c: i32};
  70. // CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+8]]:1: error: redeclaration of `fn D` is redundant
  71. // CHECK:STDERR: extern fn D();
  72. // CHECK:STDERR: ^~~~~~~~~~~~~~
  73. // CHECK:STDERR: fail_redecl_api.carbon:[[@LINE-32]]:1: in import
  74. // CHECK:STDERR: api.carbon:7:1: note: previously declared here
  75. // CHECK:STDERR: extern fn D();
  76. // CHECK:STDERR: ^~~~~~~~~~~~~~
  77. // CHECK:STDERR:
  78. extern fn D();
  79. // CHECK:STDERR: fail_redecl_api.carbon:[[@LINE+8]]:1: error: redeclarations of `fn E` must match use of `extern`
  80. // CHECK:STDERR: extern fn NS.E();
  81. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
  82. // CHECK:STDERR: fail_redecl_api.carbon:[[@LINE-41]]:1: in import
  83. // CHECK:STDERR: api.carbon:10:1: note: previously declared here
  84. // CHECK:STDERR: fn NS.E();
  85. // CHECK:STDERR: ^~~~~~~~~~
  86. // CHECK:STDERR:
  87. extern fn NS.E();
  88. var a: () = A();
  89. var b: i32 = B(1);
  90. var c: {.c: i32} = C((1,));
  91. var d: () = D();
  92. var e: () = NS.E();
  93. // --- redecl_extern_api.carbon
  94. library "[[@TEST_NAME]]";
  95. import library "extern_api";
  96. extern fn A();
  97. extern fn B(b: i32) -> i32;
  98. extern fn C(c: (i32,)) -> {.c: i32};
  99. extern fn D();
  100. extern fn NS.E();
  101. var a: () = A();
  102. var b: i32 = B(1);
  103. var c: {.c: i32} = C((1,));
  104. var d: () = D();
  105. var e: () = NS.E();
  106. // --- fail_merge.carbon
  107. library "[[@TEST_NAME]]";
  108. // CHECK:STDERR: fail_merge.carbon:[[@LINE+45]]:1: in import
  109. // CHECK:STDERR: extern_api.carbon:4:1: error: duplicate name being declared in the same scope
  110. // CHECK:STDERR: extern library "redecl_extern_api" fn A();
  111. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  112. // CHECK:STDERR: fail_merge.carbon:[[@LINE+41]]:1: in import
  113. // CHECK:STDERR: api.carbon:4:1: note: name is previously declared here
  114. // CHECK:STDERR: fn A();
  115. // CHECK:STDERR: ^~~~~~~
  116. // CHECK:STDERR:
  117. // CHECK:STDERR: fail_merge.carbon:[[@LINE+36]]:1: in import
  118. // CHECK:STDERR: extern_api.carbon:5:1: error: duplicate name being declared in the same scope
  119. // CHECK:STDERR: extern library "redecl_extern_api" fn B(b: i32) -> i32;
  120. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  121. // CHECK:STDERR: fail_merge.carbon:[[@LINE+32]]:1: in import
  122. // CHECK:STDERR: api.carbon:5:1: note: name is previously declared here
  123. // CHECK:STDERR: fn B(b: i32) -> i32;
  124. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
  125. // CHECK:STDERR:
  126. // CHECK:STDERR: fail_merge.carbon:[[@LINE+27]]:1: in import
  127. // CHECK:STDERR: extern_api.carbon:6:1: error: duplicate name being declared in the same scope
  128. // CHECK:STDERR: extern library "redecl_extern_api" fn C(c: (i32,)) -> {.c: i32};
  129. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  130. // CHECK:STDERR: fail_merge.carbon:[[@LINE+23]]:1: in import
  131. // CHECK:STDERR: api.carbon:6:1: note: name is previously declared here
  132. // CHECK:STDERR: fn C(c: (i32,)) -> {.c: i32};
  133. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  134. // CHECK:STDERR:
  135. // CHECK:STDERR: fail_merge.carbon:[[@LINE+18]]:1: in import
  136. // CHECK:STDERR: extern_api.carbon:7:1: error: duplicate name being declared in the same scope
  137. // CHECK:STDERR: extern library "redecl_extern_api" fn D();
  138. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  139. // CHECK:STDERR: fail_merge.carbon:[[@LINE+14]]:1: in import
  140. // CHECK:STDERR: api.carbon:7:1: note: name is previously declared here
  141. // CHECK:STDERR: extern fn D();
  142. // CHECK:STDERR: ^~~~~~~~~~~~~~
  143. // CHECK:STDERR:
  144. // CHECK:STDERR: fail_merge.carbon:[[@LINE+9]]:1: in import
  145. // CHECK:STDERR: extern_api.carbon:10:1: error: duplicate name being declared in the same scope
  146. // CHECK:STDERR: extern library "redecl_extern_api" fn NS.E();
  147. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  148. // CHECK:STDERR: fail_merge.carbon:[[@LINE+5]]:1: in import
  149. // CHECK:STDERR: api.carbon:10:1: note: name is previously declared here
  150. // CHECK:STDERR: fn NS.E();
  151. // CHECK:STDERR: ^~~~~~~~~~
  152. // CHECK:STDERR:
  153. import library "api";
  154. import library "extern_api";
  155. var a: () = A();
  156. var b: i32 = B(1);
  157. var c: {.c: i32} = C((1,));
  158. var d: () = D();
  159. var e: () = NS.E();
  160. // --- fail_merge_reverse.carbon
  161. library "[[@TEST_NAME]]";
  162. // CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+44]]:1: in import
  163. // CHECK:STDERR: api.carbon:4:1: error: duplicate name being declared in the same scope
  164. // CHECK:STDERR: fn A();
  165. // CHECK:STDERR: ^~~~~~~
  166. // CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+40]]:1: in import
  167. // CHECK:STDERR: extern_api.carbon:4:1: note: name is previously declared here
  168. // CHECK:STDERR: extern library "redecl_extern_api" fn A();
  169. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  170. // CHECK:STDERR:
  171. // CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+35]]:1: in import
  172. // CHECK:STDERR: api.carbon:5:1: error: duplicate name being declared in the same scope
  173. // CHECK:STDERR: fn B(b: i32) -> i32;
  174. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~
  175. // CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+31]]:1: in import
  176. // CHECK:STDERR: extern_api.carbon:5:1: note: name is previously declared here
  177. // CHECK:STDERR: extern library "redecl_extern_api" fn B(b: i32) -> i32;
  178. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  179. // CHECK:STDERR:
  180. // CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+26]]:1: in import
  181. // CHECK:STDERR: api.carbon:6:1: error: duplicate name being declared in the same scope
  182. // CHECK:STDERR: fn C(c: (i32,)) -> {.c: i32};
  183. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  184. // CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+22]]:1: in import
  185. // CHECK:STDERR: extern_api.carbon:6:1: note: name is previously declared here
  186. // CHECK:STDERR: extern library "redecl_extern_api" fn C(c: (i32,)) -> {.c: i32};
  187. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  188. // CHECK:STDERR:
  189. // CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+17]]:1: in import
  190. // CHECK:STDERR: api.carbon:7:1: error: duplicate name being declared in the same scope
  191. // CHECK:STDERR: extern fn D();
  192. // CHECK:STDERR: ^~~~~~~~~~~~~~
  193. // CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+13]]:1: in import
  194. // CHECK:STDERR: extern_api.carbon:7:1: note: name is previously declared here
  195. // CHECK:STDERR: extern library "redecl_extern_api" fn D();
  196. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  197. // CHECK:STDERR:
  198. // CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+8]]:1: in import
  199. // CHECK:STDERR: api.carbon:10:1: error: duplicate name being declared in the same scope
  200. // CHECK:STDERR: fn NS.E();
  201. // CHECK:STDERR: ^~~~~~~~~~
  202. // CHECK:STDERR: fail_merge_reverse.carbon:[[@LINE+4]]:1: in import
  203. // CHECK:STDERR: extern_api.carbon:10:1: note: name is previously declared here
  204. // CHECK:STDERR: extern library "redecl_extern_api" fn NS.E();
  205. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  206. import library "extern_api";
  207. import library "api";
  208. var a: () = A();
  209. var b: i32 = B(1);
  210. var c: {.c: i32} = C((1,));
  211. var d: () = D();
  212. var e: () = NS.E();
  213. // --- unloaded.carbon
  214. library "[[@TEST_NAME]]";
  215. import library "api";
  216. // --- unloaded_extern.carbon
  217. library "[[@TEST_NAME]]";
  218. import library "extern_api";
  219. // CHECK:STDOUT: --- api.carbon
  220. // CHECK:STDOUT:
  221. // CHECK:STDOUT: constants {
  222. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  223. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  224. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  225. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  226. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  227. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  228. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  229. // CHECK:STDOUT: %.2: type = tuple_type (type) [template]
  230. // CHECK:STDOUT: %.3: type = tuple_type (i32) [template]
  231. // CHECK:STDOUT: %.4: type = struct_type {.c: i32} [template]
  232. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  233. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  234. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  235. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  236. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  237. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  238. // CHECK:STDOUT: }
  239. // CHECK:STDOUT:
  240. // CHECK:STDOUT: imports {
  241. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  242. // CHECK:STDOUT: .Int32 = %import_ref
  243. // CHECK:STDOUT: import Core//prelude
  244. // CHECK:STDOUT: import Core//prelude/operators
  245. // CHECK:STDOUT: import Core//prelude/types
  246. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  247. // CHECK:STDOUT: import Core//prelude/operators/as
  248. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  249. // CHECK:STDOUT: import Core//prelude/operators/comparison
  250. // CHECK:STDOUT: import Core//prelude/types/bool
  251. // CHECK:STDOUT: }
  252. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  253. // CHECK:STDOUT: }
  254. // CHECK:STDOUT:
  255. // CHECK:STDOUT: file {
  256. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  257. // CHECK:STDOUT: .Core = imports.%Core
  258. // CHECK:STDOUT: .A = %A.decl
  259. // CHECK:STDOUT: .B = %B.decl
  260. // CHECK:STDOUT: .C = %C.decl
  261. // CHECK:STDOUT: .D = %D.decl
  262. // CHECK:STDOUT: .NS = %NS
  263. // CHECK:STDOUT: }
  264. // CHECK:STDOUT: %Core.import = import Core
  265. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {}
  266. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {
  267. // CHECK:STDOUT: %int.make_type_32.loc5_9: init type = call constants.%Int32() [template = i32]
  268. // CHECK:STDOUT: %.loc5_9.1: type = value_of_initializer %int.make_type_32.loc5_9 [template = i32]
  269. // CHECK:STDOUT: %.loc5_9.2: type = converted %int.make_type_32.loc5_9, %.loc5_9.1 [template = i32]
  270. // CHECK:STDOUT: %b.loc5_6.1: i32 = param b, runtime_param0
  271. // CHECK:STDOUT: @B.%b: i32 = bind_name b, %b.loc5_6.1
  272. // CHECK:STDOUT: %int.make_type_32.loc5_17: init type = call constants.%Int32() [template = i32]
  273. // CHECK:STDOUT: %.loc5_17.1: type = value_of_initializer %int.make_type_32.loc5_17 [template = i32]
  274. // CHECK:STDOUT: %.loc5_17.2: type = converted %int.make_type_32.loc5_17, %.loc5_17.1 [template = i32]
  275. // CHECK:STDOUT: @B.%return: ref i32 = var <return slot>
  276. // CHECK:STDOUT: }
  277. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {
  278. // CHECK:STDOUT: %int.make_type_32.loc6_10: init type = call constants.%Int32() [template = i32]
  279. // CHECK:STDOUT: %.loc6_14.1: %.2 = tuple_literal (%int.make_type_32.loc6_10)
  280. // CHECK:STDOUT: %.loc6_14.2: type = value_of_initializer %int.make_type_32.loc6_10 [template = i32]
  281. // CHECK:STDOUT: %.loc6_14.3: type = converted %int.make_type_32.loc6_10, %.loc6_14.2 [template = i32]
  282. // CHECK:STDOUT: %.loc6_14.4: type = converted %.loc6_14.1, constants.%.3 [template = constants.%.3]
  283. // CHECK:STDOUT: %c.loc6_6.1: %.3 = param c, runtime_param0
  284. // CHECK:STDOUT: @C.%c: %.3 = bind_name c, %c.loc6_6.1
  285. // CHECK:STDOUT: %int.make_type_32.loc6_25: init type = call constants.%Int32() [template = i32]
  286. // CHECK:STDOUT: %.loc6_25.1: type = value_of_initializer %int.make_type_32.loc6_25 [template = i32]
  287. // CHECK:STDOUT: %.loc6_25.2: type = converted %int.make_type_32.loc6_25, %.loc6_25.1 [template = i32]
  288. // CHECK:STDOUT: %.loc6_28: type = struct_type {.c: i32} [template = constants.%.4]
  289. // CHECK:STDOUT: @C.%return: ref %.4 = var <return slot>
  290. // CHECK:STDOUT: }
  291. // CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [template = constants.%D] {}
  292. // CHECK:STDOUT: %NS: <namespace> = namespace [template] {
  293. // CHECK:STDOUT: .E = %E.decl
  294. // CHECK:STDOUT: }
  295. // CHECK:STDOUT: %E.decl: %E.type = fn_decl @E [template = constants.%E] {}
  296. // CHECK:STDOUT: }
  297. // CHECK:STDOUT:
  298. // CHECK:STDOUT: fn @A();
  299. // CHECK:STDOUT:
  300. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  301. // CHECK:STDOUT:
  302. // CHECK:STDOUT: fn @B(%b: i32) -> i32;
  303. // CHECK:STDOUT:
  304. // CHECK:STDOUT: fn @C(%c: %.3) -> %.4;
  305. // CHECK:STDOUT:
  306. // CHECK:STDOUT: extern fn @D();
  307. // CHECK:STDOUT:
  308. // CHECK:STDOUT: fn @E();
  309. // CHECK:STDOUT:
  310. // CHECK:STDOUT: --- extern_api.carbon
  311. // CHECK:STDOUT:
  312. // CHECK:STDOUT: constants {
  313. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  314. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  315. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  316. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  317. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  318. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  319. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  320. // CHECK:STDOUT: %.2: type = tuple_type (type) [template]
  321. // CHECK:STDOUT: %.3: type = tuple_type (i32) [template]
  322. // CHECK:STDOUT: %.4: type = struct_type {.c: i32} [template]
  323. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  324. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  325. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  326. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  327. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  328. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  329. // CHECK:STDOUT: }
  330. // CHECK:STDOUT:
  331. // CHECK:STDOUT: imports {
  332. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  333. // CHECK:STDOUT: .Int32 = %import_ref
  334. // CHECK:STDOUT: import Core//prelude
  335. // CHECK:STDOUT: import Core//prelude/operators
  336. // CHECK:STDOUT: import Core//prelude/types
  337. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  338. // CHECK:STDOUT: import Core//prelude/operators/as
  339. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  340. // CHECK:STDOUT: import Core//prelude/operators/comparison
  341. // CHECK:STDOUT: import Core//prelude/types/bool
  342. // CHECK:STDOUT: }
  343. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  344. // CHECK:STDOUT: }
  345. // CHECK:STDOUT:
  346. // CHECK:STDOUT: file {
  347. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  348. // CHECK:STDOUT: .Core = imports.%Core
  349. // CHECK:STDOUT: .A = %A.decl
  350. // CHECK:STDOUT: .B = %B.decl
  351. // CHECK:STDOUT: .C = %C.decl
  352. // CHECK:STDOUT: .D = %D.decl
  353. // CHECK:STDOUT: .NS = %NS
  354. // CHECK:STDOUT: }
  355. // CHECK:STDOUT: %Core.import = import Core
  356. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {}
  357. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {
  358. // CHECK:STDOUT: %int.make_type_32.loc5_44: init type = call constants.%Int32() [template = i32]
  359. // CHECK:STDOUT: %.loc5_44.1: type = value_of_initializer %int.make_type_32.loc5_44 [template = i32]
  360. // CHECK:STDOUT: %.loc5_44.2: type = converted %int.make_type_32.loc5_44, %.loc5_44.1 [template = i32]
  361. // CHECK:STDOUT: %b.loc5_41.1: i32 = param b, runtime_param0
  362. // CHECK:STDOUT: @B.%b: i32 = bind_name b, %b.loc5_41.1
  363. // CHECK:STDOUT: %int.make_type_32.loc5_52: init type = call constants.%Int32() [template = i32]
  364. // CHECK:STDOUT: %.loc5_52.1: type = value_of_initializer %int.make_type_32.loc5_52 [template = i32]
  365. // CHECK:STDOUT: %.loc5_52.2: type = converted %int.make_type_32.loc5_52, %.loc5_52.1 [template = i32]
  366. // CHECK:STDOUT: @B.%return: ref i32 = var <return slot>
  367. // CHECK:STDOUT: }
  368. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {
  369. // CHECK:STDOUT: %int.make_type_32.loc6_45: init type = call constants.%Int32() [template = i32]
  370. // CHECK:STDOUT: %.loc6_49.1: %.2 = tuple_literal (%int.make_type_32.loc6_45)
  371. // CHECK:STDOUT: %.loc6_49.2: type = value_of_initializer %int.make_type_32.loc6_45 [template = i32]
  372. // CHECK:STDOUT: %.loc6_49.3: type = converted %int.make_type_32.loc6_45, %.loc6_49.2 [template = i32]
  373. // CHECK:STDOUT: %.loc6_49.4: type = converted %.loc6_49.1, constants.%.3 [template = constants.%.3]
  374. // CHECK:STDOUT: %c.loc6_41.1: %.3 = param c, runtime_param0
  375. // CHECK:STDOUT: @C.%c: %.3 = bind_name c, %c.loc6_41.1
  376. // CHECK:STDOUT: %int.make_type_32.loc6_60: init type = call constants.%Int32() [template = i32]
  377. // CHECK:STDOUT: %.loc6_60.1: type = value_of_initializer %int.make_type_32.loc6_60 [template = i32]
  378. // CHECK:STDOUT: %.loc6_60.2: type = converted %int.make_type_32.loc6_60, %.loc6_60.1 [template = i32]
  379. // CHECK:STDOUT: %.loc6_63: type = struct_type {.c: i32} [template = constants.%.4]
  380. // CHECK:STDOUT: @C.%return: ref %.4 = var <return slot>
  381. // CHECK:STDOUT: }
  382. // CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [template = constants.%D] {}
  383. // CHECK:STDOUT: %NS: <namespace> = namespace [template] {
  384. // CHECK:STDOUT: .E = %E.decl
  385. // CHECK:STDOUT: }
  386. // CHECK:STDOUT: %E.decl: %E.type = fn_decl @E [template = constants.%E] {}
  387. // CHECK:STDOUT: }
  388. // CHECK:STDOUT:
  389. // CHECK:STDOUT: extern fn @A();
  390. // CHECK:STDOUT:
  391. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  392. // CHECK:STDOUT:
  393. // CHECK:STDOUT: extern fn @B(%b: i32) -> i32;
  394. // CHECK:STDOUT:
  395. // CHECK:STDOUT: extern fn @C(%c: %.3) -> %.4;
  396. // CHECK:STDOUT:
  397. // CHECK:STDOUT: extern fn @D();
  398. // CHECK:STDOUT:
  399. // CHECK:STDOUT: extern fn @E();
  400. // CHECK:STDOUT:
  401. // CHECK:STDOUT: --- basics.carbon
  402. // CHECK:STDOUT:
  403. // CHECK:STDOUT: constants {
  404. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  405. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  406. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  407. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  408. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  409. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  410. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  411. // CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
  412. // CHECK:STDOUT: %.3: type = struct_type {.c: i32} [template]
  413. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  414. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  415. // CHECK:STDOUT: %.4: type = tuple_type (i32) [template]
  416. // CHECK:STDOUT: %tuple: %.4 = tuple_value (%.2) [template]
  417. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  418. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  419. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  420. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  421. // CHECK:STDOUT: }
  422. // CHECK:STDOUT:
  423. // CHECK:STDOUT: imports {
  424. // CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//api, inst+3, loaded [template = constants.%A]
  425. // CHECK:STDOUT: %import_ref.2: %B.type = import_ref Main//api, inst+21, loaded [template = constants.%B]
  426. // CHECK:STDOUT: %import_ref.3: %C.type = import_ref Main//api, inst+41, loaded [template = constants.%C]
  427. // CHECK:STDOUT: %import_ref.4: %D.type = import_ref Main//api, inst+44, loaded [template = constants.%D]
  428. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//api, inst+47, loaded
  429. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  430. // CHECK:STDOUT: .E = %import_ref.6
  431. // CHECK:STDOUT: }
  432. // CHECK:STDOUT: %import_ref.6: %E.type = import_ref Main//api, inst+48, loaded [template = constants.%E]
  433. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  434. // CHECK:STDOUT: .Int32 = %import_ref.7
  435. // CHECK:STDOUT: import Core//prelude
  436. // CHECK:STDOUT: import Core//prelude/operators
  437. // CHECK:STDOUT: import Core//prelude/types
  438. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  439. // CHECK:STDOUT: import Core//prelude/operators/as
  440. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  441. // CHECK:STDOUT: import Core//prelude/operators/comparison
  442. // CHECK:STDOUT: import Core//prelude/types/bool
  443. // CHECK:STDOUT: }
  444. // CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  445. // CHECK:STDOUT: }
  446. // CHECK:STDOUT:
  447. // CHECK:STDOUT: file {
  448. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  449. // CHECK:STDOUT: .A = imports.%import_ref.1
  450. // CHECK:STDOUT: .B = imports.%import_ref.2
  451. // CHECK:STDOUT: .C = imports.%import_ref.3
  452. // CHECK:STDOUT: .D = imports.%import_ref.4
  453. // CHECK:STDOUT: .NS = imports.%NS
  454. // CHECK:STDOUT: .Core = imports.%Core
  455. // CHECK:STDOUT: .a = %a
  456. // CHECK:STDOUT: .b = %b
  457. // CHECK:STDOUT: .c = %c
  458. // CHECK:STDOUT: .d = %d
  459. // CHECK:STDOUT: .e = %e
  460. // CHECK:STDOUT: }
  461. // CHECK:STDOUT: %Core.import = import Core
  462. // CHECK:STDOUT: %default.import = import <invalid>
  463. // CHECK:STDOUT: %.loc6_9.1: %.1 = tuple_literal ()
  464. // CHECK:STDOUT: %.loc6_9.2: type = converted %.loc6_9.1, constants.%.1 [template = constants.%.1]
  465. // CHECK:STDOUT: %a.var: ref %.1 = var a
  466. // CHECK:STDOUT: %a: ref %.1 = bind_name a, %a.var
  467. // CHECK:STDOUT: %int.make_type_32.loc7: init type = call constants.%Int32() [template = i32]
  468. // CHECK:STDOUT: %.loc7_8.1: type = value_of_initializer %int.make_type_32.loc7 [template = i32]
  469. // CHECK:STDOUT: %.loc7_8.2: type = converted %int.make_type_32.loc7, %.loc7_8.1 [template = i32]
  470. // CHECK:STDOUT: %b.var: ref i32 = var b
  471. // CHECK:STDOUT: %b: ref i32 = bind_name b, %b.var
  472. // CHECK:STDOUT: %int.make_type_32.loc8: init type = call constants.%Int32() [template = i32]
  473. // CHECK:STDOUT: %.loc8_13.1: type = value_of_initializer %int.make_type_32.loc8 [template = i32]
  474. // CHECK:STDOUT: %.loc8_13.2: type = converted %int.make_type_32.loc8, %.loc8_13.1 [template = i32]
  475. // CHECK:STDOUT: %.loc8_16: type = struct_type {.c: i32} [template = constants.%.3]
  476. // CHECK:STDOUT: %c.var: ref %.3 = var c
  477. // CHECK:STDOUT: %c: ref %.3 = bind_name c, %c.var
  478. // CHECK:STDOUT: %.loc9_9.1: %.1 = tuple_literal ()
  479. // CHECK:STDOUT: %.loc9_9.2: type = converted %.loc9_9.1, constants.%.1 [template = constants.%.1]
  480. // CHECK:STDOUT: %d.var: ref %.1 = var d
  481. // CHECK:STDOUT: %d: ref %.1 = bind_name d, %d.var
  482. // CHECK:STDOUT: %.loc10_9.1: %.1 = tuple_literal ()
  483. // CHECK:STDOUT: %.loc10_9.2: type = converted %.loc10_9.1, constants.%.1 [template = constants.%.1]
  484. // CHECK:STDOUT: %e.var: ref %.1 = var e
  485. // CHECK:STDOUT: %e: ref %.1 = bind_name e, %e.var
  486. // CHECK:STDOUT: }
  487. // CHECK:STDOUT:
  488. // CHECK:STDOUT: fn @A();
  489. // CHECK:STDOUT:
  490. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  491. // CHECK:STDOUT:
  492. // CHECK:STDOUT: fn @B(%b: i32) -> i32;
  493. // CHECK:STDOUT:
  494. // CHECK:STDOUT: fn @C(%c: %.4) -> %.3;
  495. // CHECK:STDOUT:
  496. // CHECK:STDOUT: extern fn @D();
  497. // CHECK:STDOUT:
  498. // CHECK:STDOUT: fn @E();
  499. // CHECK:STDOUT:
  500. // CHECK:STDOUT: fn @__global_init() {
  501. // CHECK:STDOUT: !entry:
  502. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, imports.%import_ref.1 [template = constants.%A]
  503. // CHECK:STDOUT: %A.call: init %.1 = call %A.ref()
  504. // CHECK:STDOUT: assign file.%a.var, %A.call
  505. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, imports.%import_ref.2 [template = constants.%B]
  506. // CHECK:STDOUT: %.loc7: i32 = int_literal 1 [template = constants.%.2]
  507. // CHECK:STDOUT: %B.call: init i32 = call %B.ref(%.loc7)
  508. // CHECK:STDOUT: assign file.%b.var, %B.call
  509. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.3 [template = constants.%C]
  510. // CHECK:STDOUT: %.loc8_23: i32 = int_literal 1 [template = constants.%.2]
  511. // CHECK:STDOUT: %.loc8_25: %.4 = tuple_literal (%.loc8_23)
  512. // CHECK:STDOUT: %tuple: %.4 = tuple_value (%.loc8_23) [template = constants.%tuple]
  513. // CHECK:STDOUT: %.loc8_21: %.4 = converted %.loc8_25, %tuple [template = constants.%tuple]
  514. // CHECK:STDOUT: %C.call: init %.3 = call %C.ref(%.loc8_21)
  515. // CHECK:STDOUT: assign file.%c.var, %C.call
  516. // CHECK:STDOUT: %D.ref: %D.type = name_ref D, imports.%import_ref.4 [template = constants.%D]
  517. // CHECK:STDOUT: %D.call: init %.1 = call %D.ref()
  518. // CHECK:STDOUT: assign file.%d.var, %D.call
  519. // CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
  520. // CHECK:STDOUT: %E.ref: %E.type = name_ref E, imports.%import_ref.6 [template = constants.%E]
  521. // CHECK:STDOUT: %E.call: init %.1 = call %E.ref()
  522. // CHECK:STDOUT: assign file.%e.var, %E.call
  523. // CHECK:STDOUT: return
  524. // CHECK:STDOUT: }
  525. // CHECK:STDOUT:
  526. // CHECK:STDOUT: --- fail_redecl_api.carbon
  527. // CHECK:STDOUT:
  528. // CHECK:STDOUT: constants {
  529. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  530. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  531. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  532. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  533. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  534. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  535. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  536. // CHECK:STDOUT: %.2: type = tuple_type (type) [template]
  537. // CHECK:STDOUT: %.3: type = tuple_type (i32) [template]
  538. // CHECK:STDOUT: %.4: type = struct_type {.c: i32} [template]
  539. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  540. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  541. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  542. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  543. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  544. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  545. // CHECK:STDOUT: %.5: i32 = int_literal 1 [template]
  546. // CHECK:STDOUT: %tuple: %.3 = tuple_value (%.5) [template]
  547. // CHECK:STDOUT: }
  548. // CHECK:STDOUT:
  549. // CHECK:STDOUT: imports {
  550. // CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//api, inst+3, loaded [template = constants.%A]
  551. // CHECK:STDOUT: %import_ref.2: %B.type = import_ref Main//api, inst+21, loaded [template = constants.%B]
  552. // CHECK:STDOUT: %import_ref.3: %C.type = import_ref Main//api, inst+41, loaded [template = constants.%C]
  553. // CHECK:STDOUT: %import_ref.4: %D.type = import_ref Main//api, inst+44, loaded [template = constants.%D]
  554. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//api, inst+47, loaded
  555. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  556. // CHECK:STDOUT: .E = file.%E.decl
  557. // CHECK:STDOUT: }
  558. // CHECK:STDOUT: %import_ref.6: %E.type = import_ref Main//api, inst+48, loaded [template = constants.%E]
  559. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  560. // CHECK:STDOUT: .Int32 = %import_ref.7
  561. // CHECK:STDOUT: import Core//prelude
  562. // CHECK:STDOUT: import Core//prelude/operators
  563. // CHECK:STDOUT: import Core//prelude/types
  564. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  565. // CHECK:STDOUT: import Core//prelude/operators/as
  566. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  567. // CHECK:STDOUT: import Core//prelude/operators/comparison
  568. // CHECK:STDOUT: import Core//prelude/types/bool
  569. // CHECK:STDOUT: }
  570. // CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  571. // CHECK:STDOUT: }
  572. // CHECK:STDOUT:
  573. // CHECK:STDOUT: file {
  574. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  575. // CHECK:STDOUT: .A = %A.decl
  576. // CHECK:STDOUT: .B = %B.decl
  577. // CHECK:STDOUT: .C = %C.decl
  578. // CHECK:STDOUT: .D = %D.decl
  579. // CHECK:STDOUT: .NS = imports.%NS
  580. // CHECK:STDOUT: .Core = imports.%Core
  581. // CHECK:STDOUT: .a = %a
  582. // CHECK:STDOUT: .b = %b.loc53
  583. // CHECK:STDOUT: .c = %c.loc54
  584. // CHECK:STDOUT: .d = %d
  585. // CHECK:STDOUT: .e = %e
  586. // CHECK:STDOUT: }
  587. // CHECK:STDOUT: %Core.import = import Core
  588. // CHECK:STDOUT: %default.import = import <invalid>
  589. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {}
  590. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {
  591. // CHECK:STDOUT: %int.make_type_32.loc23_16: init type = call constants.%Int32() [template = i32]
  592. // CHECK:STDOUT: %.loc23_16.1: type = value_of_initializer %int.make_type_32.loc23_16 [template = i32]
  593. // CHECK:STDOUT: %.loc23_16.2: type = converted %int.make_type_32.loc23_16, %.loc23_16.1 [template = i32]
  594. // CHECK:STDOUT: %b.loc23_13.1: i32 = param b, runtime_param0
  595. // CHECK:STDOUT: %b.loc23_13.2: i32 = bind_name b, %b.loc23_13.1
  596. // CHECK:STDOUT: %int.make_type_32.loc23_24: init type = call constants.%Int32() [template = i32]
  597. // CHECK:STDOUT: %.loc23_24.1: type = value_of_initializer %int.make_type_32.loc23_24 [template = i32]
  598. // CHECK:STDOUT: %.loc23_24.2: type = converted %int.make_type_32.loc23_24, %.loc23_24.1 [template = i32]
  599. // CHECK:STDOUT: %return.var.loc23: ref i32 = var <return slot>
  600. // CHECK:STDOUT: }
  601. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {
  602. // CHECK:STDOUT: %int.make_type_32.loc32_17: init type = call constants.%Int32() [template = i32]
  603. // CHECK:STDOUT: %.loc32_21.1: %.2 = tuple_literal (%int.make_type_32.loc32_17)
  604. // CHECK:STDOUT: %.loc32_21.2: type = value_of_initializer %int.make_type_32.loc32_17 [template = i32]
  605. // CHECK:STDOUT: %.loc32_21.3: type = converted %int.make_type_32.loc32_17, %.loc32_21.2 [template = i32]
  606. // CHECK:STDOUT: %.loc32_21.4: type = converted %.loc32_21.1, constants.%.3 [template = constants.%.3]
  607. // CHECK:STDOUT: %c.loc32_13.1: %.3 = param c, runtime_param0
  608. // CHECK:STDOUT: %c.loc32_13.2: %.3 = bind_name c, %c.loc32_13.1
  609. // CHECK:STDOUT: %int.make_type_32.loc32_32: init type = call constants.%Int32() [template = i32]
  610. // CHECK:STDOUT: %.loc32_32.1: type = value_of_initializer %int.make_type_32.loc32_32 [template = i32]
  611. // CHECK:STDOUT: %.loc32_32.2: type = converted %int.make_type_32.loc32_32, %.loc32_32.1 [template = i32]
  612. // CHECK:STDOUT: %.loc32_35: type = struct_type {.c: i32} [template = constants.%.4]
  613. // CHECK:STDOUT: %return.var.loc32: ref %.4 = var <return slot>
  614. // CHECK:STDOUT: }
  615. // CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [template = constants.%D] {}
  616. // CHECK:STDOUT: %E.decl: %E.type = fn_decl @E [template = constants.%E] {}
  617. // CHECK:STDOUT: %.loc52_9.1: %.1 = tuple_literal ()
  618. // CHECK:STDOUT: %.loc52_9.2: type = converted %.loc52_9.1, constants.%.1 [template = constants.%.1]
  619. // CHECK:STDOUT: %a.var: ref %.1 = var a
  620. // CHECK:STDOUT: %a: ref %.1 = bind_name a, %a.var
  621. // CHECK:STDOUT: %int.make_type_32.loc53: init type = call constants.%Int32() [template = i32]
  622. // CHECK:STDOUT: %.loc53_8.1: type = value_of_initializer %int.make_type_32.loc53 [template = i32]
  623. // CHECK:STDOUT: %.loc53_8.2: type = converted %int.make_type_32.loc53, %.loc53_8.1 [template = i32]
  624. // CHECK:STDOUT: %b.var: ref i32 = var b
  625. // CHECK:STDOUT: %b.loc53: ref i32 = bind_name b, %b.var
  626. // CHECK:STDOUT: %int.make_type_32.loc54: init type = call constants.%Int32() [template = i32]
  627. // CHECK:STDOUT: %.loc54_13.1: type = value_of_initializer %int.make_type_32.loc54 [template = i32]
  628. // CHECK:STDOUT: %.loc54_13.2: type = converted %int.make_type_32.loc54, %.loc54_13.1 [template = i32]
  629. // CHECK:STDOUT: %.loc54_16: type = struct_type {.c: i32} [template = constants.%.4]
  630. // CHECK:STDOUT: %c.var: ref %.4 = var c
  631. // CHECK:STDOUT: %c.loc54: ref %.4 = bind_name c, %c.var
  632. // CHECK:STDOUT: %.loc55_9.1: %.1 = tuple_literal ()
  633. // CHECK:STDOUT: %.loc55_9.2: type = converted %.loc55_9.1, constants.%.1 [template = constants.%.1]
  634. // CHECK:STDOUT: %d.var: ref %.1 = var d
  635. // CHECK:STDOUT: %d: ref %.1 = bind_name d, %d.var
  636. // CHECK:STDOUT: %.loc56_9.1: %.1 = tuple_literal ()
  637. // CHECK:STDOUT: %.loc56_9.2: type = converted %.loc56_9.1, constants.%.1 [template = constants.%.1]
  638. // CHECK:STDOUT: %e.var: ref %.1 = var e
  639. // CHECK:STDOUT: %e: ref %.1 = bind_name e, %e.var
  640. // CHECK:STDOUT: }
  641. // CHECK:STDOUT:
  642. // CHECK:STDOUT: fn @A();
  643. // CHECK:STDOUT:
  644. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  645. // CHECK:STDOUT:
  646. // CHECK:STDOUT: fn @B(%b: i32) -> i32;
  647. // CHECK:STDOUT:
  648. // CHECK:STDOUT: fn @C(%c: %.3) -> %.4;
  649. // CHECK:STDOUT:
  650. // CHECK:STDOUT: extern fn @D();
  651. // CHECK:STDOUT:
  652. // CHECK:STDOUT: fn @E();
  653. // CHECK:STDOUT:
  654. // CHECK:STDOUT: fn @__global_init() {
  655. // CHECK:STDOUT: !entry:
  656. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [template = constants.%A]
  657. // CHECK:STDOUT: %A.call: init %.1 = call %A.ref()
  658. // CHECK:STDOUT: assign file.%a.var, %A.call
  659. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, file.%B.decl [template = constants.%B]
  660. // CHECK:STDOUT: %.loc53: i32 = int_literal 1 [template = constants.%.5]
  661. // CHECK:STDOUT: %B.call: init i32 = call %B.ref(%.loc53)
  662. // CHECK:STDOUT: assign file.%b.var, %B.call
  663. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [template = constants.%C]
  664. // CHECK:STDOUT: %.loc54_23: i32 = int_literal 1 [template = constants.%.5]
  665. // CHECK:STDOUT: %.loc54_25: %.3 = tuple_literal (%.loc54_23)
  666. // CHECK:STDOUT: %tuple: %.3 = tuple_value (%.loc54_23) [template = constants.%tuple]
  667. // CHECK:STDOUT: %.loc54_21: %.3 = converted %.loc54_25, %tuple [template = constants.%tuple]
  668. // CHECK:STDOUT: %C.call: init %.4 = call %C.ref(%.loc54_21)
  669. // CHECK:STDOUT: assign file.%c.var, %C.call
  670. // CHECK:STDOUT: %D.ref: %D.type = name_ref D, file.%D.decl [template = constants.%D]
  671. // CHECK:STDOUT: %D.call: init %.1 = call %D.ref()
  672. // CHECK:STDOUT: assign file.%d.var, %D.call
  673. // CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
  674. // CHECK:STDOUT: %E.ref: %E.type = name_ref E, file.%E.decl [template = constants.%E]
  675. // CHECK:STDOUT: %E.call: init %.1 = call %E.ref()
  676. // CHECK:STDOUT: assign file.%e.var, %E.call
  677. // CHECK:STDOUT: return
  678. // CHECK:STDOUT: }
  679. // CHECK:STDOUT:
  680. // CHECK:STDOUT: --- redecl_extern_api.carbon
  681. // CHECK:STDOUT:
  682. // CHECK:STDOUT: constants {
  683. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  684. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  685. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  686. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  687. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  688. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  689. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  690. // CHECK:STDOUT: %.2: type = tuple_type (type) [template]
  691. // CHECK:STDOUT: %.3: type = tuple_type (i32) [template]
  692. // CHECK:STDOUT: %.4: type = struct_type {.c: i32} [template]
  693. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  694. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  695. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  696. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  697. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  698. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  699. // CHECK:STDOUT: %.5: i32 = int_literal 1 [template]
  700. // CHECK:STDOUT: %tuple: %.3 = tuple_value (%.5) [template]
  701. // CHECK:STDOUT: }
  702. // CHECK:STDOUT:
  703. // CHECK:STDOUT: imports {
  704. // CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//extern_api, inst+3, loaded [template = constants.%A]
  705. // CHECK:STDOUT: %import_ref.2: %B.type = import_ref Main//extern_api, inst+21, loaded [template = constants.%B]
  706. // CHECK:STDOUT: %import_ref.3: %C.type = import_ref Main//extern_api, inst+41, loaded [template = constants.%C]
  707. // CHECK:STDOUT: %import_ref.4: %D.type = import_ref Main//extern_api, inst+44, loaded [template = constants.%D]
  708. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//extern_api, inst+47, loaded
  709. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  710. // CHECK:STDOUT: .E = file.%E.decl
  711. // CHECK:STDOUT: }
  712. // CHECK:STDOUT: %import_ref.6: %E.type = import_ref Main//extern_api, inst+48, loaded [template = constants.%E]
  713. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  714. // CHECK:STDOUT: .Int32 = %import_ref.7
  715. // CHECK:STDOUT: import Core//prelude
  716. // CHECK:STDOUT: import Core//prelude/operators
  717. // CHECK:STDOUT: import Core//prelude/types
  718. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  719. // CHECK:STDOUT: import Core//prelude/operators/as
  720. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  721. // CHECK:STDOUT: import Core//prelude/operators/comparison
  722. // CHECK:STDOUT: import Core//prelude/types/bool
  723. // CHECK:STDOUT: }
  724. // CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  725. // CHECK:STDOUT: }
  726. // CHECK:STDOUT:
  727. // CHECK:STDOUT: file {
  728. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  729. // CHECK:STDOUT: .A = %A.decl
  730. // CHECK:STDOUT: .B = %B.decl
  731. // CHECK:STDOUT: .C = %C.decl
  732. // CHECK:STDOUT: .D = %D.decl
  733. // CHECK:STDOUT: .NS = imports.%NS
  734. // CHECK:STDOUT: .Core = imports.%Core
  735. // CHECK:STDOUT: .a = %a
  736. // CHECK:STDOUT: .b = %b.loc13
  737. // CHECK:STDOUT: .c = %c.loc14
  738. // CHECK:STDOUT: .d = %d
  739. // CHECK:STDOUT: .e = %e
  740. // CHECK:STDOUT: }
  741. // CHECK:STDOUT: %Core.import = import Core
  742. // CHECK:STDOUT: %default.import = import <invalid>
  743. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [template = constants.%A] {}
  744. // CHECK:STDOUT: %B.decl: %B.type = fn_decl @B [template = constants.%B] {
  745. // CHECK:STDOUT: %int.make_type_32.loc7_16: init type = call constants.%Int32() [template = i32]
  746. // CHECK:STDOUT: %.loc7_16.1: type = value_of_initializer %int.make_type_32.loc7_16 [template = i32]
  747. // CHECK:STDOUT: %.loc7_16.2: type = converted %int.make_type_32.loc7_16, %.loc7_16.1 [template = i32]
  748. // CHECK:STDOUT: %b.loc7_13.1: i32 = param b, runtime_param0
  749. // CHECK:STDOUT: %b.loc7_13.2: i32 = bind_name b, %b.loc7_13.1
  750. // CHECK:STDOUT: %int.make_type_32.loc7_24: init type = call constants.%Int32() [template = i32]
  751. // CHECK:STDOUT: %.loc7_24.1: type = value_of_initializer %int.make_type_32.loc7_24 [template = i32]
  752. // CHECK:STDOUT: %.loc7_24.2: type = converted %int.make_type_32.loc7_24, %.loc7_24.1 [template = i32]
  753. // CHECK:STDOUT: %return.var.loc7: ref i32 = var <return slot>
  754. // CHECK:STDOUT: }
  755. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [template = constants.%C] {
  756. // CHECK:STDOUT: %int.make_type_32.loc8_17: init type = call constants.%Int32() [template = i32]
  757. // CHECK:STDOUT: %.loc8_21.1: %.2 = tuple_literal (%int.make_type_32.loc8_17)
  758. // CHECK:STDOUT: %.loc8_21.2: type = value_of_initializer %int.make_type_32.loc8_17 [template = i32]
  759. // CHECK:STDOUT: %.loc8_21.3: type = converted %int.make_type_32.loc8_17, %.loc8_21.2 [template = i32]
  760. // CHECK:STDOUT: %.loc8_21.4: type = converted %.loc8_21.1, constants.%.3 [template = constants.%.3]
  761. // CHECK:STDOUT: %c.loc8_13.1: %.3 = param c, runtime_param0
  762. // CHECK:STDOUT: %c.loc8_13.2: %.3 = bind_name c, %c.loc8_13.1
  763. // CHECK:STDOUT: %int.make_type_32.loc8_32: init type = call constants.%Int32() [template = i32]
  764. // CHECK:STDOUT: %.loc8_32.1: type = value_of_initializer %int.make_type_32.loc8_32 [template = i32]
  765. // CHECK:STDOUT: %.loc8_32.2: type = converted %int.make_type_32.loc8_32, %.loc8_32.1 [template = i32]
  766. // CHECK:STDOUT: %.loc8_35: type = struct_type {.c: i32} [template = constants.%.4]
  767. // CHECK:STDOUT: %return.var.loc8: ref %.4 = var <return slot>
  768. // CHECK:STDOUT: }
  769. // CHECK:STDOUT: %D.decl: %D.type = fn_decl @D [template = constants.%D] {}
  770. // CHECK:STDOUT: %E.decl: %E.type = fn_decl @E [template = constants.%E] {}
  771. // CHECK:STDOUT: %.loc12_9.1: %.1 = tuple_literal ()
  772. // CHECK:STDOUT: %.loc12_9.2: type = converted %.loc12_9.1, constants.%.1 [template = constants.%.1]
  773. // CHECK:STDOUT: %a.var: ref %.1 = var a
  774. // CHECK:STDOUT: %a: ref %.1 = bind_name a, %a.var
  775. // CHECK:STDOUT: %int.make_type_32.loc13: init type = call constants.%Int32() [template = i32]
  776. // CHECK:STDOUT: %.loc13_8.1: type = value_of_initializer %int.make_type_32.loc13 [template = i32]
  777. // CHECK:STDOUT: %.loc13_8.2: type = converted %int.make_type_32.loc13, %.loc13_8.1 [template = i32]
  778. // CHECK:STDOUT: %b.var: ref i32 = var b
  779. // CHECK:STDOUT: %b.loc13: ref i32 = bind_name b, %b.var
  780. // CHECK:STDOUT: %int.make_type_32.loc14: init type = call constants.%Int32() [template = i32]
  781. // CHECK:STDOUT: %.loc14_13.1: type = value_of_initializer %int.make_type_32.loc14 [template = i32]
  782. // CHECK:STDOUT: %.loc14_13.2: type = converted %int.make_type_32.loc14, %.loc14_13.1 [template = i32]
  783. // CHECK:STDOUT: %.loc14_16: type = struct_type {.c: i32} [template = constants.%.4]
  784. // CHECK:STDOUT: %c.var: ref %.4 = var c
  785. // CHECK:STDOUT: %c.loc14: ref %.4 = bind_name c, %c.var
  786. // CHECK:STDOUT: %.loc15_9.1: %.1 = tuple_literal ()
  787. // CHECK:STDOUT: %.loc15_9.2: type = converted %.loc15_9.1, constants.%.1 [template = constants.%.1]
  788. // CHECK:STDOUT: %d.var: ref %.1 = var d
  789. // CHECK:STDOUT: %d: ref %.1 = bind_name d, %d.var
  790. // CHECK:STDOUT: %.loc16_9.1: %.1 = tuple_literal ()
  791. // CHECK:STDOUT: %.loc16_9.2: type = converted %.loc16_9.1, constants.%.1 [template = constants.%.1]
  792. // CHECK:STDOUT: %e.var: ref %.1 = var e
  793. // CHECK:STDOUT: %e: ref %.1 = bind_name e, %e.var
  794. // CHECK:STDOUT: }
  795. // CHECK:STDOUT:
  796. // CHECK:STDOUT: extern fn @A();
  797. // CHECK:STDOUT:
  798. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  799. // CHECK:STDOUT:
  800. // CHECK:STDOUT: extern fn @B(%b: i32) -> i32;
  801. // CHECK:STDOUT:
  802. // CHECK:STDOUT: extern fn @C(%c: %.3) -> %.4;
  803. // CHECK:STDOUT:
  804. // CHECK:STDOUT: extern fn @D();
  805. // CHECK:STDOUT:
  806. // CHECK:STDOUT: extern fn @E();
  807. // CHECK:STDOUT:
  808. // CHECK:STDOUT: fn @__global_init() {
  809. // CHECK:STDOUT: !entry:
  810. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [template = constants.%A]
  811. // CHECK:STDOUT: %A.call: init %.1 = call %A.ref()
  812. // CHECK:STDOUT: assign file.%a.var, %A.call
  813. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, file.%B.decl [template = constants.%B]
  814. // CHECK:STDOUT: %.loc13: i32 = int_literal 1 [template = constants.%.5]
  815. // CHECK:STDOUT: %B.call: init i32 = call %B.ref(%.loc13)
  816. // CHECK:STDOUT: assign file.%b.var, %B.call
  817. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [template = constants.%C]
  818. // CHECK:STDOUT: %.loc14_23: i32 = int_literal 1 [template = constants.%.5]
  819. // CHECK:STDOUT: %.loc14_25: %.3 = tuple_literal (%.loc14_23)
  820. // CHECK:STDOUT: %tuple: %.3 = tuple_value (%.loc14_23) [template = constants.%tuple]
  821. // CHECK:STDOUT: %.loc14_21: %.3 = converted %.loc14_25, %tuple [template = constants.%tuple]
  822. // CHECK:STDOUT: %C.call: init %.4 = call %C.ref(%.loc14_21)
  823. // CHECK:STDOUT: assign file.%c.var, %C.call
  824. // CHECK:STDOUT: %D.ref: %D.type = name_ref D, file.%D.decl [template = constants.%D]
  825. // CHECK:STDOUT: %D.call: init %.1 = call %D.ref()
  826. // CHECK:STDOUT: assign file.%d.var, %D.call
  827. // CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
  828. // CHECK:STDOUT: %E.ref: %E.type = name_ref E, file.%E.decl [template = constants.%E]
  829. // CHECK:STDOUT: %E.call: init %.1 = call %E.ref()
  830. // CHECK:STDOUT: assign file.%e.var, %E.call
  831. // CHECK:STDOUT: return
  832. // CHECK:STDOUT: }
  833. // CHECK:STDOUT:
  834. // CHECK:STDOUT: --- fail_merge.carbon
  835. // CHECK:STDOUT:
  836. // CHECK:STDOUT: constants {
  837. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  838. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  839. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  840. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  841. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  842. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  843. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  844. // CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
  845. // CHECK:STDOUT: %.3: type = struct_type {.c: i32} [template]
  846. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  847. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  848. // CHECK:STDOUT: %.4: type = tuple_type (i32) [template]
  849. // CHECK:STDOUT: %tuple: %.4 = tuple_value (%.2) [template]
  850. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  851. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  852. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  853. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  854. // CHECK:STDOUT: }
  855. // CHECK:STDOUT:
  856. // CHECK:STDOUT: imports {
  857. // CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//api, inst+3, loaded [template = constants.%A]
  858. // CHECK:STDOUT: %import_ref.2: %B.type = import_ref Main//api, inst+21, loaded [template = constants.%B]
  859. // CHECK:STDOUT: %import_ref.3: %C.type = import_ref Main//api, inst+41, loaded [template = constants.%C]
  860. // CHECK:STDOUT: %import_ref.4: %D.type = import_ref Main//api, inst+44, loaded [template = constants.%D]
  861. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//api, inst+47, loaded
  862. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  863. // CHECK:STDOUT: .E = %import_ref.6
  864. // CHECK:STDOUT: }
  865. // CHECK:STDOUT: %import_ref.6: %E.type = import_ref Main//api, inst+48, loaded [template = constants.%E]
  866. // CHECK:STDOUT: %import_ref.7 = import_ref Main//extern_api, inst+3, unloaded
  867. // CHECK:STDOUT: %import_ref.8 = import_ref Main//extern_api, inst+21, unloaded
  868. // CHECK:STDOUT: %import_ref.9 = import_ref Main//extern_api, inst+41, unloaded
  869. // CHECK:STDOUT: %import_ref.10 = import_ref Main//extern_api, inst+44, unloaded
  870. // CHECK:STDOUT: %import_ref.11 = import_ref Main//extern_api, inst+48, unloaded
  871. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  872. // CHECK:STDOUT: .Int32 = %import_ref.12
  873. // CHECK:STDOUT: import Core//prelude
  874. // CHECK:STDOUT: import Core//prelude/operators
  875. // CHECK:STDOUT: import Core//prelude/types
  876. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  877. // CHECK:STDOUT: import Core//prelude/operators/as
  878. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  879. // CHECK:STDOUT: import Core//prelude/operators/comparison
  880. // CHECK:STDOUT: import Core//prelude/types/bool
  881. // CHECK:STDOUT: }
  882. // CHECK:STDOUT: %import_ref.12: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  883. // CHECK:STDOUT: }
  884. // CHECK:STDOUT:
  885. // CHECK:STDOUT: file {
  886. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  887. // CHECK:STDOUT: .A = imports.%import_ref.1
  888. // CHECK:STDOUT: .B = imports.%import_ref.2
  889. // CHECK:STDOUT: .C = imports.%import_ref.3
  890. // CHECK:STDOUT: .D = imports.%import_ref.4
  891. // CHECK:STDOUT: .NS = imports.%NS
  892. // CHECK:STDOUT: .Core = imports.%Core
  893. // CHECK:STDOUT: .a = %a
  894. // CHECK:STDOUT: .b = %b
  895. // CHECK:STDOUT: .c = %c
  896. // CHECK:STDOUT: .d = %d
  897. // CHECK:STDOUT: .e = %e
  898. // CHECK:STDOUT: }
  899. // CHECK:STDOUT: %Core.import = import Core
  900. // CHECK:STDOUT: %default.import = import <invalid>
  901. // CHECK:STDOUT: %.loc52_9.1: %.1 = tuple_literal ()
  902. // CHECK:STDOUT: %.loc52_9.2: type = converted %.loc52_9.1, constants.%.1 [template = constants.%.1]
  903. // CHECK:STDOUT: %a.var: ref %.1 = var a
  904. // CHECK:STDOUT: %a: ref %.1 = bind_name a, %a.var
  905. // CHECK:STDOUT: %int.make_type_32.loc53: init type = call constants.%Int32() [template = i32]
  906. // CHECK:STDOUT: %.loc53_8.1: type = value_of_initializer %int.make_type_32.loc53 [template = i32]
  907. // CHECK:STDOUT: %.loc53_8.2: type = converted %int.make_type_32.loc53, %.loc53_8.1 [template = i32]
  908. // CHECK:STDOUT: %b.var: ref i32 = var b
  909. // CHECK:STDOUT: %b: ref i32 = bind_name b, %b.var
  910. // CHECK:STDOUT: %int.make_type_32.loc54: init type = call constants.%Int32() [template = i32]
  911. // CHECK:STDOUT: %.loc54_13.1: type = value_of_initializer %int.make_type_32.loc54 [template = i32]
  912. // CHECK:STDOUT: %.loc54_13.2: type = converted %int.make_type_32.loc54, %.loc54_13.1 [template = i32]
  913. // CHECK:STDOUT: %.loc54_16: type = struct_type {.c: i32} [template = constants.%.3]
  914. // CHECK:STDOUT: %c.var: ref %.3 = var c
  915. // CHECK:STDOUT: %c: ref %.3 = bind_name c, %c.var
  916. // CHECK:STDOUT: %.loc55_9.1: %.1 = tuple_literal ()
  917. // CHECK:STDOUT: %.loc55_9.2: type = converted %.loc55_9.1, constants.%.1 [template = constants.%.1]
  918. // CHECK:STDOUT: %d.var: ref %.1 = var d
  919. // CHECK:STDOUT: %d: ref %.1 = bind_name d, %d.var
  920. // CHECK:STDOUT: %.loc56_9.1: %.1 = tuple_literal ()
  921. // CHECK:STDOUT: %.loc56_9.2: type = converted %.loc56_9.1, constants.%.1 [template = constants.%.1]
  922. // CHECK:STDOUT: %e.var: ref %.1 = var e
  923. // CHECK:STDOUT: %e: ref %.1 = bind_name e, %e.var
  924. // CHECK:STDOUT: }
  925. // CHECK:STDOUT:
  926. // CHECK:STDOUT: fn @A();
  927. // CHECK:STDOUT:
  928. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  929. // CHECK:STDOUT:
  930. // CHECK:STDOUT: fn @B(%b: i32) -> i32;
  931. // CHECK:STDOUT:
  932. // CHECK:STDOUT: fn @C(%c: %.4) -> %.3;
  933. // CHECK:STDOUT:
  934. // CHECK:STDOUT: extern fn @D();
  935. // CHECK:STDOUT:
  936. // CHECK:STDOUT: fn @E();
  937. // CHECK:STDOUT:
  938. // CHECK:STDOUT: fn @__global_init() {
  939. // CHECK:STDOUT: !entry:
  940. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, imports.%import_ref.1 [template = constants.%A]
  941. // CHECK:STDOUT: %A.call: init %.1 = call %A.ref()
  942. // CHECK:STDOUT: assign file.%a.var, %A.call
  943. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, imports.%import_ref.2 [template = constants.%B]
  944. // CHECK:STDOUT: %.loc53: i32 = int_literal 1 [template = constants.%.2]
  945. // CHECK:STDOUT: %B.call: init i32 = call %B.ref(%.loc53)
  946. // CHECK:STDOUT: assign file.%b.var, %B.call
  947. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.3 [template = constants.%C]
  948. // CHECK:STDOUT: %.loc54_23: i32 = int_literal 1 [template = constants.%.2]
  949. // CHECK:STDOUT: %.loc54_25: %.4 = tuple_literal (%.loc54_23)
  950. // CHECK:STDOUT: %tuple: %.4 = tuple_value (%.loc54_23) [template = constants.%tuple]
  951. // CHECK:STDOUT: %.loc54_21: %.4 = converted %.loc54_25, %tuple [template = constants.%tuple]
  952. // CHECK:STDOUT: %C.call: init %.3 = call %C.ref(%.loc54_21)
  953. // CHECK:STDOUT: assign file.%c.var, %C.call
  954. // CHECK:STDOUT: %D.ref: %D.type = name_ref D, imports.%import_ref.4 [template = constants.%D]
  955. // CHECK:STDOUT: %D.call: init %.1 = call %D.ref()
  956. // CHECK:STDOUT: assign file.%d.var, %D.call
  957. // CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
  958. // CHECK:STDOUT: %E.ref: %E.type = name_ref E, imports.%import_ref.6 [template = constants.%E]
  959. // CHECK:STDOUT: %E.call: init %.1 = call %E.ref()
  960. // CHECK:STDOUT: assign file.%e.var, %E.call
  961. // CHECK:STDOUT: return
  962. // CHECK:STDOUT: }
  963. // CHECK:STDOUT:
  964. // CHECK:STDOUT: --- fail_merge_reverse.carbon
  965. // CHECK:STDOUT:
  966. // CHECK:STDOUT: constants {
  967. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  968. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  969. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  970. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  971. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  972. // CHECK:STDOUT: %B.type: type = fn_type @B [template]
  973. // CHECK:STDOUT: %B: %B.type = struct_value () [template]
  974. // CHECK:STDOUT: %.2: i32 = int_literal 1 [template]
  975. // CHECK:STDOUT: %.3: type = struct_type {.c: i32} [template]
  976. // CHECK:STDOUT: %C.type: type = fn_type @C [template]
  977. // CHECK:STDOUT: %C: %C.type = struct_value () [template]
  978. // CHECK:STDOUT: %.4: type = tuple_type (i32) [template]
  979. // CHECK:STDOUT: %tuple: %.4 = tuple_value (%.2) [template]
  980. // CHECK:STDOUT: %D.type: type = fn_type @D [template]
  981. // CHECK:STDOUT: %D: %D.type = struct_value () [template]
  982. // CHECK:STDOUT: %E.type: type = fn_type @E [template]
  983. // CHECK:STDOUT: %E: %E.type = struct_value () [template]
  984. // CHECK:STDOUT: }
  985. // CHECK:STDOUT:
  986. // CHECK:STDOUT: imports {
  987. // CHECK:STDOUT: %import_ref.1: %A.type = import_ref Main//extern_api, inst+3, loaded [template = constants.%A]
  988. // CHECK:STDOUT: %import_ref.2: %B.type = import_ref Main//extern_api, inst+21, loaded [template = constants.%B]
  989. // CHECK:STDOUT: %import_ref.3: %C.type = import_ref Main//extern_api, inst+41, loaded [template = constants.%C]
  990. // CHECK:STDOUT: %import_ref.4: %D.type = import_ref Main//extern_api, inst+44, loaded [template = constants.%D]
  991. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//extern_api, inst+47, loaded
  992. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  993. // CHECK:STDOUT: .E = %import_ref.6
  994. // CHECK:STDOUT: }
  995. // CHECK:STDOUT: %import_ref.6: %E.type = import_ref Main//extern_api, inst+48, loaded [template = constants.%E]
  996. // CHECK:STDOUT: %import_ref.7 = import_ref Main//api, inst+3, unloaded
  997. // CHECK:STDOUT: %import_ref.8 = import_ref Main//api, inst+21, unloaded
  998. // CHECK:STDOUT: %import_ref.9 = import_ref Main//api, inst+41, unloaded
  999. // CHECK:STDOUT: %import_ref.10 = import_ref Main//api, inst+44, unloaded
  1000. // CHECK:STDOUT: %import_ref.11 = import_ref Main//api, inst+48, unloaded
  1001. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  1002. // CHECK:STDOUT: .Int32 = %import_ref.12
  1003. // CHECK:STDOUT: import Core//prelude
  1004. // CHECK:STDOUT: import Core//prelude/operators
  1005. // CHECK:STDOUT: import Core//prelude/types
  1006. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  1007. // CHECK:STDOUT: import Core//prelude/operators/as
  1008. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  1009. // CHECK:STDOUT: import Core//prelude/operators/comparison
  1010. // CHECK:STDOUT: import Core//prelude/types/bool
  1011. // CHECK:STDOUT: }
  1012. // CHECK:STDOUT: %import_ref.12: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  1013. // CHECK:STDOUT: }
  1014. // CHECK:STDOUT:
  1015. // CHECK:STDOUT: file {
  1016. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  1017. // CHECK:STDOUT: .A = imports.%import_ref.1
  1018. // CHECK:STDOUT: .B = imports.%import_ref.2
  1019. // CHECK:STDOUT: .C = imports.%import_ref.3
  1020. // CHECK:STDOUT: .D = imports.%import_ref.4
  1021. // CHECK:STDOUT: .NS = imports.%NS
  1022. // CHECK:STDOUT: .Core = imports.%Core
  1023. // CHECK:STDOUT: .a = %a
  1024. // CHECK:STDOUT: .b = %b
  1025. // CHECK:STDOUT: .c = %c
  1026. // CHECK:STDOUT: .d = %d
  1027. // CHECK:STDOUT: .e = %e
  1028. // CHECK:STDOUT: }
  1029. // CHECK:STDOUT: %Core.import = import Core
  1030. // CHECK:STDOUT: %default.import = import <invalid>
  1031. // CHECK:STDOUT: %.loc51_9.1: %.1 = tuple_literal ()
  1032. // CHECK:STDOUT: %.loc51_9.2: type = converted %.loc51_9.1, constants.%.1 [template = constants.%.1]
  1033. // CHECK:STDOUT: %a.var: ref %.1 = var a
  1034. // CHECK:STDOUT: %a: ref %.1 = bind_name a, %a.var
  1035. // CHECK:STDOUT: %int.make_type_32.loc52: init type = call constants.%Int32() [template = i32]
  1036. // CHECK:STDOUT: %.loc52_8.1: type = value_of_initializer %int.make_type_32.loc52 [template = i32]
  1037. // CHECK:STDOUT: %.loc52_8.2: type = converted %int.make_type_32.loc52, %.loc52_8.1 [template = i32]
  1038. // CHECK:STDOUT: %b.var: ref i32 = var b
  1039. // CHECK:STDOUT: %b: ref i32 = bind_name b, %b.var
  1040. // CHECK:STDOUT: %int.make_type_32.loc53: init type = call constants.%Int32() [template = i32]
  1041. // CHECK:STDOUT: %.loc53_13.1: type = value_of_initializer %int.make_type_32.loc53 [template = i32]
  1042. // CHECK:STDOUT: %.loc53_13.2: type = converted %int.make_type_32.loc53, %.loc53_13.1 [template = i32]
  1043. // CHECK:STDOUT: %.loc53_16: type = struct_type {.c: i32} [template = constants.%.3]
  1044. // CHECK:STDOUT: %c.var: ref %.3 = var c
  1045. // CHECK:STDOUT: %c: ref %.3 = bind_name c, %c.var
  1046. // CHECK:STDOUT: %.loc54_9.1: %.1 = tuple_literal ()
  1047. // CHECK:STDOUT: %.loc54_9.2: type = converted %.loc54_9.1, constants.%.1 [template = constants.%.1]
  1048. // CHECK:STDOUT: %d.var: ref %.1 = var d
  1049. // CHECK:STDOUT: %d: ref %.1 = bind_name d, %d.var
  1050. // CHECK:STDOUT: %.loc55_9.1: %.1 = tuple_literal ()
  1051. // CHECK:STDOUT: %.loc55_9.2: type = converted %.loc55_9.1, constants.%.1 [template = constants.%.1]
  1052. // CHECK:STDOUT: %e.var: ref %.1 = var e
  1053. // CHECK:STDOUT: %e: ref %.1 = bind_name e, %e.var
  1054. // CHECK:STDOUT: }
  1055. // CHECK:STDOUT:
  1056. // CHECK:STDOUT: extern fn @A();
  1057. // CHECK:STDOUT:
  1058. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  1059. // CHECK:STDOUT:
  1060. // CHECK:STDOUT: extern fn @B(%b: i32) -> i32;
  1061. // CHECK:STDOUT:
  1062. // CHECK:STDOUT: extern fn @C(%c: %.4) -> %.3;
  1063. // CHECK:STDOUT:
  1064. // CHECK:STDOUT: extern fn @D();
  1065. // CHECK:STDOUT:
  1066. // CHECK:STDOUT: extern fn @E();
  1067. // CHECK:STDOUT:
  1068. // CHECK:STDOUT: fn @__global_init() {
  1069. // CHECK:STDOUT: !entry:
  1070. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, imports.%import_ref.1 [template = constants.%A]
  1071. // CHECK:STDOUT: %A.call: init %.1 = call %A.ref()
  1072. // CHECK:STDOUT: assign file.%a.var, %A.call
  1073. // CHECK:STDOUT: %B.ref: %B.type = name_ref B, imports.%import_ref.2 [template = constants.%B]
  1074. // CHECK:STDOUT: %.loc52: i32 = int_literal 1 [template = constants.%.2]
  1075. // CHECK:STDOUT: %B.call: init i32 = call %B.ref(%.loc52)
  1076. // CHECK:STDOUT: assign file.%b.var, %B.call
  1077. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.3 [template = constants.%C]
  1078. // CHECK:STDOUT: %.loc53_23: i32 = int_literal 1 [template = constants.%.2]
  1079. // CHECK:STDOUT: %.loc53_25: %.4 = tuple_literal (%.loc53_23)
  1080. // CHECK:STDOUT: %tuple: %.4 = tuple_value (%.loc53_23) [template = constants.%tuple]
  1081. // CHECK:STDOUT: %.loc53_21: %.4 = converted %.loc53_25, %tuple [template = constants.%tuple]
  1082. // CHECK:STDOUT: %C.call: init %.3 = call %C.ref(%.loc53_21)
  1083. // CHECK:STDOUT: assign file.%c.var, %C.call
  1084. // CHECK:STDOUT: %D.ref: %D.type = name_ref D, imports.%import_ref.4 [template = constants.%D]
  1085. // CHECK:STDOUT: %D.call: init %.1 = call %D.ref()
  1086. // CHECK:STDOUT: assign file.%d.var, %D.call
  1087. // CHECK:STDOUT: %NS.ref: <namespace> = name_ref NS, imports.%NS [template = imports.%NS]
  1088. // CHECK:STDOUT: %E.ref: %E.type = name_ref E, imports.%import_ref.6 [template = constants.%E]
  1089. // CHECK:STDOUT: %E.call: init %.1 = call %E.ref()
  1090. // CHECK:STDOUT: assign file.%e.var, %E.call
  1091. // CHECK:STDOUT: return
  1092. // CHECK:STDOUT: }
  1093. // CHECK:STDOUT:
  1094. // CHECK:STDOUT: --- unloaded.carbon
  1095. // CHECK:STDOUT:
  1096. // CHECK:STDOUT: imports {
  1097. // CHECK:STDOUT: %import_ref.1 = import_ref Main//api, inst+3, unloaded
  1098. // CHECK:STDOUT: %import_ref.2 = import_ref Main//api, inst+21, unloaded
  1099. // CHECK:STDOUT: %import_ref.3 = import_ref Main//api, inst+41, unloaded
  1100. // CHECK:STDOUT: %import_ref.4 = import_ref Main//api, inst+44, unloaded
  1101. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//api, inst+47, loaded
  1102. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  1103. // CHECK:STDOUT: .E = %import_ref.6
  1104. // CHECK:STDOUT: }
  1105. // CHECK:STDOUT: %import_ref.6 = import_ref Main//api, inst+48, unloaded
  1106. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  1107. // CHECK:STDOUT: import Core//prelude
  1108. // CHECK:STDOUT: import Core//prelude/operators
  1109. // CHECK:STDOUT: import Core//prelude/types
  1110. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  1111. // CHECK:STDOUT: import Core//prelude/operators/as
  1112. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  1113. // CHECK:STDOUT: import Core//prelude/operators/comparison
  1114. // CHECK:STDOUT: import Core//prelude/types/bool
  1115. // CHECK:STDOUT: }
  1116. // CHECK:STDOUT: }
  1117. // CHECK:STDOUT:
  1118. // CHECK:STDOUT: file {
  1119. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  1120. // CHECK:STDOUT: .A = imports.%import_ref.1
  1121. // CHECK:STDOUT: .B = imports.%import_ref.2
  1122. // CHECK:STDOUT: .C = imports.%import_ref.3
  1123. // CHECK:STDOUT: .D = imports.%import_ref.4
  1124. // CHECK:STDOUT: .NS = imports.%NS
  1125. // CHECK:STDOUT: .Core = imports.%Core
  1126. // CHECK:STDOUT: }
  1127. // CHECK:STDOUT: %Core.import = import Core
  1128. // CHECK:STDOUT: %default.import = import <invalid>
  1129. // CHECK:STDOUT: }
  1130. // CHECK:STDOUT:
  1131. // CHECK:STDOUT: --- unloaded_extern.carbon
  1132. // CHECK:STDOUT:
  1133. // CHECK:STDOUT: imports {
  1134. // CHECK:STDOUT: %import_ref.1 = import_ref Main//extern_api, inst+3, unloaded
  1135. // CHECK:STDOUT: %import_ref.2 = import_ref Main//extern_api, inst+21, unloaded
  1136. // CHECK:STDOUT: %import_ref.3 = import_ref Main//extern_api, inst+41, unloaded
  1137. // CHECK:STDOUT: %import_ref.4 = import_ref Main//extern_api, inst+44, unloaded
  1138. // CHECK:STDOUT: %import_ref.5: <namespace> = import_ref Main//extern_api, inst+47, loaded
  1139. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.5, [template] {
  1140. // CHECK:STDOUT: .E = %import_ref.6
  1141. // CHECK:STDOUT: }
  1142. // CHECK:STDOUT: %import_ref.6 = import_ref Main//extern_api, inst+48, unloaded
  1143. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  1144. // CHECK:STDOUT: import Core//prelude
  1145. // CHECK:STDOUT: import Core//prelude/operators
  1146. // CHECK:STDOUT: import Core//prelude/types
  1147. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  1148. // CHECK:STDOUT: import Core//prelude/operators/as
  1149. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  1150. // CHECK:STDOUT: import Core//prelude/operators/comparison
  1151. // CHECK:STDOUT: import Core//prelude/types/bool
  1152. // CHECK:STDOUT: }
  1153. // CHECK:STDOUT: }
  1154. // CHECK:STDOUT:
  1155. // CHECK:STDOUT: file {
  1156. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  1157. // CHECK:STDOUT: .A = imports.%import_ref.1
  1158. // CHECK:STDOUT: .B = imports.%import_ref.2
  1159. // CHECK:STDOUT: .C = imports.%import_ref.3
  1160. // CHECK:STDOUT: .D = imports.%import_ref.4
  1161. // CHECK:STDOUT: .NS = imports.%NS
  1162. // CHECK:STDOUT: .Core = imports.%Core
  1163. // CHECK:STDOUT: }
  1164. // CHECK:STDOUT: %Core.import = import Core
  1165. // CHECK:STDOUT: %default.import = import <invalid>
  1166. // CHECK:STDOUT: }
  1167. // CHECK:STDOUT: