import.carbon 60 KB

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