cross_package_export.carbon 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/packages/cross_package_export.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/packages/cross_package_export.carbon
  14. // ============================================================================
  15. // Setup files
  16. // ============================================================================
  17. // --- base.carbon
  18. package Other library "[[@TEST_NAME]]";
  19. class C {
  20. var x: ();
  21. };
  22. // --- conflict.carbon
  23. package Other library "[[@TEST_NAME]]";
  24. fn C() {}
  25. // --- export_import.carbon
  26. package Other library "[[@TEST_NAME]]";
  27. export import library "base";
  28. // --- export_import_copy.carbon
  29. package Other library "[[@TEST_NAME]]";
  30. export import library "base";
  31. // --- export_import_indirect.carbon
  32. package Other library "[[@TEST_NAME]]";
  33. export import library "export_import";
  34. // --- export_name.carbon
  35. package Other library "[[@TEST_NAME]]";
  36. import library "base";
  37. export C;
  38. // --- export_name_copy.carbon
  39. package Other library "[[@TEST_NAME]]";
  40. import library "base";
  41. export C;
  42. // --- export_name_indirect.carbon
  43. package Other library "[[@TEST_NAME]]";
  44. import library "export_name";
  45. export C;
  46. // ============================================================================
  47. // Test files
  48. // ============================================================================
  49. // --- use_export_import.carbon
  50. library "[[@TEST_NAME]]";
  51. import Other library "export_import";
  52. var c: Other.C = {.x = ()};
  53. // --- use_export_import_with_copy.carbon
  54. library "[[@TEST_NAME]]";
  55. import Other library "export_import";
  56. import Other library "export_import_copy";
  57. var c: Other.C = {.x = ()};
  58. // --- use_export_import_indirect.carbon
  59. library "[[@TEST_NAME]]";
  60. import Other library "export_import_indirect";
  61. var c: Other.C = {.x = ()};
  62. // --- use_export_name.carbon
  63. library "[[@TEST_NAME]]";
  64. import Other library "export_name";
  65. var c: Other.C = {.x = ()};
  66. // --- use_export_name_with_copy.carbon
  67. library "[[@TEST_NAME]]";
  68. import Other library "export_name";
  69. import Other library "export_name_copy";
  70. var c: Other.C = {.x = ()};
  71. // --- use_export_name_indirect.carbon
  72. library "[[@TEST_NAME]]";
  73. import Other library "export_name_indirect";
  74. var c: Other.C = {.x = ()};
  75. // --- use_export_all.carbon
  76. library "[[@TEST_NAME]]";
  77. import Other library "export_import";
  78. import Other library "export_name";
  79. import Other library "export_import_copy";
  80. import Other library "export_name_copy";
  81. import Other library "export_import_indirect";
  82. import Other library "export_name_indirect";
  83. var c: Other.C = {.x = ()};
  84. // --- unused_conflict_on_export_import.carbon
  85. library "[[@TEST_NAME]]";
  86. import Other library "export_import";
  87. import Other library "conflict";
  88. // --- unused_conflict_on_export_name.carbon
  89. library "[[@TEST_NAME]]";
  90. import Other library "export_name";
  91. import Other library "conflict";
  92. // --- fail_conflict_on_export_import.carbon
  93. library "[[@TEST_NAME]]";
  94. // CHECK:STDERR: fail_conflict_on_export_import.carbon:[[@LINE+8]]:1: in import [InImport]
  95. // CHECK:STDERR: base.carbon:4:1: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate]
  96. // CHECK:STDERR: class C {
  97. // CHECK:STDERR: ^~~~~~~~~
  98. // CHECK:STDERR: fail_conflict_on_export_import.carbon:[[@LINE+4]]:1: in import [InImport]
  99. // CHECK:STDERR: conflict.carbon:4:1: note: name is previously declared here [NameDeclPrevious]
  100. // CHECK:STDERR: fn C() {}
  101. // CHECK:STDERR: ^~~~~~~~
  102. import Other library "export_import";
  103. import Other library "conflict";
  104. // CHECK:STDERR: fail_conflict_on_export_import.carbon:[[@LINE+4]]:11: note: in name lookup for `C` [InNameLookup]
  105. // CHECK:STDERR: alias C = Other.C;
  106. // CHECK:STDERR: ^~~~~~~
  107. // CHECK:STDERR:
  108. alias C = Other.C;
  109. // --- fail_conflict_on_export_name.carbon
  110. library "[[@TEST_NAME]]";
  111. // CHECK:STDERR: fail_conflict_on_export_name.carbon:[[@LINE+9]]:1: in import [InImport]
  112. // CHECK:STDERR: conflict.carbon:4:1: error: duplicate name `C` being declared in the same scope [NameDeclDuplicate]
  113. // CHECK:STDERR: fn C() {}
  114. // CHECK:STDERR: ^~~~~~~~
  115. // CHECK:STDERR: fail_conflict_on_export_name.carbon:[[@LINE+5]]:1: in import [InImport]
  116. // CHECK:STDERR: export_name.carbon:4:1: in import [InImport]
  117. // CHECK:STDERR: base.carbon:4:1: note: name is previously declared here [NameDeclPrevious]
  118. // CHECK:STDERR: class C {
  119. // CHECK:STDERR: ^~~~~~~~~
  120. import Other library "export_name";
  121. import Other library "conflict";
  122. // CHECK:STDERR: fail_conflict_on_export_name.carbon:[[@LINE+4]]:11: note: in name lookup for `C` [InNameLookup]
  123. // CHECK:STDERR: alias C = Other.C;
  124. // CHECK:STDERR: ^~~~~~~
  125. // CHECK:STDERR:
  126. alias C = Other.C;
  127. // CHECK:STDOUT: --- base.carbon
  128. // CHECK:STDOUT:
  129. // CHECK:STDOUT: constants {
  130. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  131. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  132. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  133. // CHECK:STDOUT: %C.elem: type = unbound_element_type %C, %empty_tuple.type [concrete]
  134. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [concrete]
  135. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x [concrete]
  136. // CHECK:STDOUT: }
  137. // CHECK:STDOUT:
  138. // CHECK:STDOUT: file {
  139. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  140. // CHECK:STDOUT: .C = %C.decl
  141. // CHECK:STDOUT: }
  142. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  143. // CHECK:STDOUT: }
  144. // CHECK:STDOUT:
  145. // CHECK:STDOUT: class @C {
  146. // CHECK:STDOUT: %.loc5_11.1: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  147. // CHECK:STDOUT: %.loc5_11.2: type = converted %.loc5_11.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  148. // CHECK:STDOUT: %.loc5_8: %C.elem = field_decl x, element0 [concrete]
  149. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%struct_type.x [concrete = constants.%complete_type]
  150. // CHECK:STDOUT: complete_type_witness = %complete_type
  151. // CHECK:STDOUT:
  152. // CHECK:STDOUT: !members:
  153. // CHECK:STDOUT: .Self = constants.%C
  154. // CHECK:STDOUT: .x = %.loc5_8
  155. // CHECK:STDOUT: }
  156. // CHECK:STDOUT:
  157. // CHECK:STDOUT: --- conflict.carbon
  158. // CHECK:STDOUT:
  159. // CHECK:STDOUT: constants {
  160. // CHECK:STDOUT: %C.type: type = fn_type @C [concrete]
  161. // CHECK:STDOUT: %C: %C.type = struct_value () [concrete]
  162. // CHECK:STDOUT: }
  163. // CHECK:STDOUT:
  164. // CHECK:STDOUT: file {
  165. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  166. // CHECK:STDOUT: .C = %C.decl
  167. // CHECK:STDOUT: }
  168. // CHECK:STDOUT: %C.decl: %C.type = fn_decl @C [concrete = constants.%C] {} {}
  169. // CHECK:STDOUT: }
  170. // CHECK:STDOUT:
  171. // CHECK:STDOUT: fn @C() {
  172. // CHECK:STDOUT: !entry:
  173. // CHECK:STDOUT: return
  174. // CHECK:STDOUT: }
  175. // CHECK:STDOUT:
  176. // CHECK:STDOUT: --- export_import.carbon
  177. // CHECK:STDOUT:
  178. // CHECK:STDOUT: imports {
  179. // CHECK:STDOUT: %Other.C = import_ref Other//base, C, unloaded
  180. // CHECK:STDOUT: }
  181. // CHECK:STDOUT:
  182. // CHECK:STDOUT: file {
  183. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  184. // CHECK:STDOUT: .C = imports.%Other.C
  185. // CHECK:STDOUT: }
  186. // CHECK:STDOUT: %default.import = import <none>
  187. // CHECK:STDOUT: }
  188. // CHECK:STDOUT:
  189. // CHECK:STDOUT: --- export_import_copy.carbon
  190. // CHECK:STDOUT:
  191. // CHECK:STDOUT: imports {
  192. // CHECK:STDOUT: %Other.C = import_ref Other//base, C, unloaded
  193. // CHECK:STDOUT: }
  194. // CHECK:STDOUT:
  195. // CHECK:STDOUT: file {
  196. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  197. // CHECK:STDOUT: .C = imports.%Other.C
  198. // CHECK:STDOUT: }
  199. // CHECK:STDOUT: %default.import = import <none>
  200. // CHECK:STDOUT: }
  201. // CHECK:STDOUT:
  202. // CHECK:STDOUT: --- export_import_indirect.carbon
  203. // CHECK:STDOUT:
  204. // CHECK:STDOUT: imports {
  205. // CHECK:STDOUT: %Other.C = import_ref Other//base, C, unloaded
  206. // CHECK:STDOUT: }
  207. // CHECK:STDOUT:
  208. // CHECK:STDOUT: file {
  209. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  210. // CHECK:STDOUT: .C = imports.%Other.C
  211. // CHECK:STDOUT: }
  212. // CHECK:STDOUT: %default.import = import <none>
  213. // CHECK:STDOUT: }
  214. // CHECK:STDOUT:
  215. // CHECK:STDOUT: --- export_name.carbon
  216. // CHECK:STDOUT:
  217. // CHECK:STDOUT: constants {
  218. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  219. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  220. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [concrete]
  221. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x [concrete]
  222. // CHECK:STDOUT: }
  223. // CHECK:STDOUT:
  224. // CHECK:STDOUT: imports {
  225. // CHECK:STDOUT: %Other.C: type = import_ref Other//base, C, loaded [concrete = constants.%C]
  226. // CHECK:STDOUT: %Other.import_ref.56d: <witness> = import_ref Other//base, loc6_1, loaded [concrete = constants.%complete_type]
  227. // CHECK:STDOUT: %Other.import_ref.42d = import_ref Other//base, inst{{[0-9A-F]+}} [no loc], unloaded
  228. // CHECK:STDOUT: %Other.import_ref.640 = import_ref Other//base, loc5_8, unloaded
  229. // CHECK:STDOUT: }
  230. // CHECK:STDOUT:
  231. // CHECK:STDOUT: file {
  232. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  233. // CHECK:STDOUT: .C = %C
  234. // CHECK:STDOUT: }
  235. // CHECK:STDOUT: %default.import = import <none>
  236. // CHECK:STDOUT: %C: type = export C, imports.%Other.C [concrete = constants.%C]
  237. // CHECK:STDOUT: }
  238. // CHECK:STDOUT:
  239. // CHECK:STDOUT: class @C [from "base.carbon"] {
  240. // CHECK:STDOUT: complete_type_witness = imports.%Other.import_ref.56d
  241. // CHECK:STDOUT:
  242. // CHECK:STDOUT: !members:
  243. // CHECK:STDOUT: .Self = imports.%Other.import_ref.42d
  244. // CHECK:STDOUT: .x = imports.%Other.import_ref.640
  245. // CHECK:STDOUT: }
  246. // CHECK:STDOUT:
  247. // CHECK:STDOUT: --- export_name_copy.carbon
  248. // CHECK:STDOUT:
  249. // CHECK:STDOUT: constants {
  250. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  251. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  252. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [concrete]
  253. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x [concrete]
  254. // CHECK:STDOUT: }
  255. // CHECK:STDOUT:
  256. // CHECK:STDOUT: imports {
  257. // CHECK:STDOUT: %Other.C: type = import_ref Other//base, C, loaded [concrete = constants.%C]
  258. // CHECK:STDOUT: %Other.import_ref.56d: <witness> = import_ref Other//base, loc6_1, loaded [concrete = constants.%complete_type]
  259. // CHECK:STDOUT: %Other.import_ref.42d = import_ref Other//base, inst{{[0-9A-F]+}} [no loc], unloaded
  260. // CHECK:STDOUT: %Other.import_ref.640 = import_ref Other//base, loc5_8, unloaded
  261. // CHECK:STDOUT: }
  262. // CHECK:STDOUT:
  263. // CHECK:STDOUT: file {
  264. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  265. // CHECK:STDOUT: .C = %C
  266. // CHECK:STDOUT: }
  267. // CHECK:STDOUT: %default.import = import <none>
  268. // CHECK:STDOUT: %C: type = export C, imports.%Other.C [concrete = constants.%C]
  269. // CHECK:STDOUT: }
  270. // CHECK:STDOUT:
  271. // CHECK:STDOUT: class @C [from "base.carbon"] {
  272. // CHECK:STDOUT: complete_type_witness = imports.%Other.import_ref.56d
  273. // CHECK:STDOUT:
  274. // CHECK:STDOUT: !members:
  275. // CHECK:STDOUT: .Self = imports.%Other.import_ref.42d
  276. // CHECK:STDOUT: .x = imports.%Other.import_ref.640
  277. // CHECK:STDOUT: }
  278. // CHECK:STDOUT:
  279. // CHECK:STDOUT: --- export_name_indirect.carbon
  280. // CHECK:STDOUT:
  281. // CHECK:STDOUT: constants {
  282. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  283. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  284. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [concrete]
  285. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x [concrete]
  286. // CHECK:STDOUT: }
  287. // CHECK:STDOUT:
  288. // CHECK:STDOUT: imports {
  289. // CHECK:STDOUT: %Other.C: type = import_ref Other//export_name, C, loaded [concrete = constants.%C]
  290. // CHECK:STDOUT: %Other.import_ref.ad3: <witness> = import_ref Other//export_name, inst{{[0-9A-F]+}} [indirect], loaded [concrete = constants.%complete_type]
  291. // CHECK:STDOUT: %Other.import_ref.3c4 = import_ref Other//export_name, inst{{[0-9A-F]+}} [indirect], unloaded
  292. // CHECK:STDOUT: %Other.import_ref.249 = import_ref Other//export_name, inst{{[0-9A-F]+}} [indirect], unloaded
  293. // CHECK:STDOUT: }
  294. // CHECK:STDOUT:
  295. // CHECK:STDOUT: file {
  296. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  297. // CHECK:STDOUT: .C = %C
  298. // CHECK:STDOUT: }
  299. // CHECK:STDOUT: %default.import = import <none>
  300. // CHECK:STDOUT: %C: type = export C, imports.%Other.C [concrete = constants.%C]
  301. // CHECK:STDOUT: }
  302. // CHECK:STDOUT:
  303. // CHECK:STDOUT: class @C [from "export_name.carbon"] {
  304. // CHECK:STDOUT: complete_type_witness = imports.%Other.import_ref.ad3
  305. // CHECK:STDOUT:
  306. // CHECK:STDOUT: !members:
  307. // CHECK:STDOUT: .Self = imports.%Other.import_ref.3c4
  308. // CHECK:STDOUT: .x = imports.%Other.import_ref.249
  309. // CHECK:STDOUT: }
  310. // CHECK:STDOUT:
  311. // CHECK:STDOUT: --- use_export_import.carbon
  312. // CHECK:STDOUT:
  313. // CHECK:STDOUT: constants {
  314. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  315. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  316. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [concrete]
  317. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x [concrete]
  318. // CHECK:STDOUT: %pattern_type: type = pattern_type %C [concrete]
  319. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  320. // CHECK:STDOUT: %struct: %struct_type.x = struct_value (%empty_tuple) [concrete]
  321. // CHECK:STDOUT: %.dd7: ref %empty_tuple.type = class_element_access file.%c.var, element0 [concrete]
  322. // CHECK:STDOUT: %C.val: %C = struct_value (%empty_tuple) [concrete]
  323. // CHECK:STDOUT: }
  324. // CHECK:STDOUT:
  325. // CHECK:STDOUT: imports {
  326. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  327. // CHECK:STDOUT: .C = %Other.C
  328. // CHECK:STDOUT: import Other//export_import
  329. // CHECK:STDOUT: import Other//base
  330. // CHECK:STDOUT: }
  331. // CHECK:STDOUT: %Other.C: type = import_ref Other//base, C, loaded [concrete = constants.%C]
  332. // CHECK:STDOUT: %Other.import_ref.56d: <witness> = import_ref Other//base, loc6_1, loaded [concrete = constants.%complete_type]
  333. // CHECK:STDOUT: %Other.import_ref.42d = import_ref Other//base, inst{{[0-9A-F]+}} [no loc], unloaded
  334. // CHECK:STDOUT: %Other.import_ref.640 = import_ref Other//base, loc5_8, unloaded
  335. // CHECK:STDOUT: }
  336. // CHECK:STDOUT:
  337. // CHECK:STDOUT: file {
  338. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  339. // CHECK:STDOUT: .Other = imports.%Other
  340. // CHECK:STDOUT: .c = %c
  341. // CHECK:STDOUT: }
  342. // CHECK:STDOUT: %Other.import = import Other
  343. // CHECK:STDOUT: name_binding_decl {
  344. // CHECK:STDOUT: %c.patt: %pattern_type = ref_binding_pattern c [concrete]
  345. // CHECK:STDOUT: %c.var_patt: %pattern_type = var_pattern %c.patt [concrete]
  346. // CHECK:STDOUT: }
  347. // CHECK:STDOUT: %c.var: ref %C = var %c.var_patt [concrete]
  348. // CHECK:STDOUT: %.loc6: type = splice_block %C.ref [concrete = constants.%C] {
  349. // CHECK:STDOUT: %Other.ref: <namespace> = name_ref Other, imports.%Other [concrete = imports.%Other]
  350. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Other.C [concrete = constants.%C]
  351. // CHECK:STDOUT: }
  352. // CHECK:STDOUT: %c: ref %C = ref_binding c, %c.var [concrete = %c.var]
  353. // CHECK:STDOUT: }
  354. // CHECK:STDOUT:
  355. // CHECK:STDOUT: class @C [from "base.carbon"] {
  356. // CHECK:STDOUT: complete_type_witness = imports.%Other.import_ref.56d
  357. // CHECK:STDOUT:
  358. // CHECK:STDOUT: !members:
  359. // CHECK:STDOUT: .Self = imports.%Other.import_ref.42d
  360. // CHECK:STDOUT: .x = imports.%Other.import_ref.640
  361. // CHECK:STDOUT: }
  362. // CHECK:STDOUT:
  363. // CHECK:STDOUT: fn @__global_init() {
  364. // CHECK:STDOUT: !entry:
  365. // CHECK:STDOUT: %.loc6_25.1: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  366. // CHECK:STDOUT: %.loc6_26.1: %struct_type.x = struct_literal (%.loc6_25.1) [concrete = constants.%struct]
  367. // CHECK:STDOUT: %.loc6_26.2: ref %empty_tuple.type = class_element_access file.%c.var, element0 [concrete = constants.%.dd7]
  368. // CHECK:STDOUT: %.loc6_25.2: init %empty_tuple.type = tuple_init () to %.loc6_26.2 [concrete = constants.%empty_tuple]
  369. // CHECK:STDOUT: %.loc6_26.3: init %empty_tuple.type = converted %.loc6_25.1, %.loc6_25.2 [concrete = constants.%empty_tuple]
  370. // CHECK:STDOUT: %.loc6_26.4: init %C = class_init (%.loc6_26.3), file.%c.var [concrete = constants.%C.val]
  371. // CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_26.1, %.loc6_26.4 [concrete = constants.%C.val]
  372. // CHECK:STDOUT: assign file.%c.var, %.loc6_1
  373. // CHECK:STDOUT: return
  374. // CHECK:STDOUT: }
  375. // CHECK:STDOUT:
  376. // CHECK:STDOUT: --- use_export_import_with_copy.carbon
  377. // CHECK:STDOUT:
  378. // CHECK:STDOUT: constants {
  379. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  380. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  381. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [concrete]
  382. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x [concrete]
  383. // CHECK:STDOUT: %pattern_type: type = pattern_type %C [concrete]
  384. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  385. // CHECK:STDOUT: %struct: %struct_type.x = struct_value (%empty_tuple) [concrete]
  386. // CHECK:STDOUT: %.dd7: ref %empty_tuple.type = class_element_access file.%c.var, element0 [concrete]
  387. // CHECK:STDOUT: %C.val: %C = struct_value (%empty_tuple) [concrete]
  388. // CHECK:STDOUT: }
  389. // CHECK:STDOUT:
  390. // CHECK:STDOUT: imports {
  391. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  392. // CHECK:STDOUT: .C = %Other.C
  393. // CHECK:STDOUT: import Other//export_import
  394. // CHECK:STDOUT: import Other//export_import_copy
  395. // CHECK:STDOUT: import Other//base
  396. // CHECK:STDOUT: }
  397. // CHECK:STDOUT: %Other.C: type = import_ref Other//base, C, loaded [concrete = constants.%C]
  398. // CHECK:STDOUT: %Other.import_ref.56d: <witness> = import_ref Other//base, loc6_1, loaded [concrete = constants.%complete_type]
  399. // CHECK:STDOUT: %Other.import_ref.42d = import_ref Other//base, inst{{[0-9A-F]+}} [no loc], unloaded
  400. // CHECK:STDOUT: %Other.import_ref.640 = import_ref Other//base, loc5_8, unloaded
  401. // CHECK:STDOUT: }
  402. // CHECK:STDOUT:
  403. // CHECK:STDOUT: file {
  404. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  405. // CHECK:STDOUT: .Other = imports.%Other
  406. // CHECK:STDOUT: .c = %c
  407. // CHECK:STDOUT: }
  408. // CHECK:STDOUT: %Other.import = import Other
  409. // CHECK:STDOUT: name_binding_decl {
  410. // CHECK:STDOUT: %c.patt: %pattern_type = ref_binding_pattern c [concrete]
  411. // CHECK:STDOUT: %c.var_patt: %pattern_type = var_pattern %c.patt [concrete]
  412. // CHECK:STDOUT: }
  413. // CHECK:STDOUT: %c.var: ref %C = var %c.var_patt [concrete]
  414. // CHECK:STDOUT: %.loc7: type = splice_block %C.ref [concrete = constants.%C] {
  415. // CHECK:STDOUT: %Other.ref: <namespace> = name_ref Other, imports.%Other [concrete = imports.%Other]
  416. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Other.C [concrete = constants.%C]
  417. // CHECK:STDOUT: }
  418. // CHECK:STDOUT: %c: ref %C = ref_binding c, %c.var [concrete = %c.var]
  419. // CHECK:STDOUT: }
  420. // CHECK:STDOUT:
  421. // CHECK:STDOUT: class @C [from "base.carbon"] {
  422. // CHECK:STDOUT: complete_type_witness = imports.%Other.import_ref.56d
  423. // CHECK:STDOUT:
  424. // CHECK:STDOUT: !members:
  425. // CHECK:STDOUT: .Self = imports.%Other.import_ref.42d
  426. // CHECK:STDOUT: .x = imports.%Other.import_ref.640
  427. // CHECK:STDOUT: }
  428. // CHECK:STDOUT:
  429. // CHECK:STDOUT: fn @__global_init() {
  430. // CHECK:STDOUT: !entry:
  431. // CHECK:STDOUT: %.loc7_25.1: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  432. // CHECK:STDOUT: %.loc7_26.1: %struct_type.x = struct_literal (%.loc7_25.1) [concrete = constants.%struct]
  433. // CHECK:STDOUT: %.loc7_26.2: ref %empty_tuple.type = class_element_access file.%c.var, element0 [concrete = constants.%.dd7]
  434. // CHECK:STDOUT: %.loc7_25.2: init %empty_tuple.type = tuple_init () to %.loc7_26.2 [concrete = constants.%empty_tuple]
  435. // CHECK:STDOUT: %.loc7_26.3: init %empty_tuple.type = converted %.loc7_25.1, %.loc7_25.2 [concrete = constants.%empty_tuple]
  436. // CHECK:STDOUT: %.loc7_26.4: init %C = class_init (%.loc7_26.3), file.%c.var [concrete = constants.%C.val]
  437. // CHECK:STDOUT: %.loc7_1: init %C = converted %.loc7_26.1, %.loc7_26.4 [concrete = constants.%C.val]
  438. // CHECK:STDOUT: assign file.%c.var, %.loc7_1
  439. // CHECK:STDOUT: return
  440. // CHECK:STDOUT: }
  441. // CHECK:STDOUT:
  442. // CHECK:STDOUT: --- use_export_import_indirect.carbon
  443. // CHECK:STDOUT:
  444. // CHECK:STDOUT: constants {
  445. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  446. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  447. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [concrete]
  448. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x [concrete]
  449. // CHECK:STDOUT: %pattern_type: type = pattern_type %C [concrete]
  450. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  451. // CHECK:STDOUT: %struct: %struct_type.x = struct_value (%empty_tuple) [concrete]
  452. // CHECK:STDOUT: %.dd7: ref %empty_tuple.type = class_element_access file.%c.var, element0 [concrete]
  453. // CHECK:STDOUT: %C.val: %C = struct_value (%empty_tuple) [concrete]
  454. // CHECK:STDOUT: }
  455. // CHECK:STDOUT:
  456. // CHECK:STDOUT: imports {
  457. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  458. // CHECK:STDOUT: .C = %Other.C
  459. // CHECK:STDOUT: import Other//export_import_indirect
  460. // CHECK:STDOUT: import Other//export_import
  461. // CHECK:STDOUT: import Other//base
  462. // CHECK:STDOUT: }
  463. // CHECK:STDOUT: %Other.C: type = import_ref Other//base, C, loaded [concrete = constants.%C]
  464. // CHECK:STDOUT: %Other.import_ref.56d: <witness> = import_ref Other//base, loc6_1, loaded [concrete = constants.%complete_type]
  465. // CHECK:STDOUT: %Other.import_ref.42d = import_ref Other//base, inst{{[0-9A-F]+}} [no loc], unloaded
  466. // CHECK:STDOUT: %Other.import_ref.640 = import_ref Other//base, loc5_8, unloaded
  467. // CHECK:STDOUT: }
  468. // CHECK:STDOUT:
  469. // CHECK:STDOUT: file {
  470. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  471. // CHECK:STDOUT: .Other = imports.%Other
  472. // CHECK:STDOUT: .c = %c
  473. // CHECK:STDOUT: }
  474. // CHECK:STDOUT: %Other.import = import Other
  475. // CHECK:STDOUT: name_binding_decl {
  476. // CHECK:STDOUT: %c.patt: %pattern_type = ref_binding_pattern c [concrete]
  477. // CHECK:STDOUT: %c.var_patt: %pattern_type = var_pattern %c.patt [concrete]
  478. // CHECK:STDOUT: }
  479. // CHECK:STDOUT: %c.var: ref %C = var %c.var_patt [concrete]
  480. // CHECK:STDOUT: %.loc6: type = splice_block %C.ref [concrete = constants.%C] {
  481. // CHECK:STDOUT: %Other.ref: <namespace> = name_ref Other, imports.%Other [concrete = imports.%Other]
  482. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Other.C [concrete = constants.%C]
  483. // CHECK:STDOUT: }
  484. // CHECK:STDOUT: %c: ref %C = ref_binding c, %c.var [concrete = %c.var]
  485. // CHECK:STDOUT: }
  486. // CHECK:STDOUT:
  487. // CHECK:STDOUT: class @C [from "base.carbon"] {
  488. // CHECK:STDOUT: complete_type_witness = imports.%Other.import_ref.56d
  489. // CHECK:STDOUT:
  490. // CHECK:STDOUT: !members:
  491. // CHECK:STDOUT: .Self = imports.%Other.import_ref.42d
  492. // CHECK:STDOUT: .x = imports.%Other.import_ref.640
  493. // CHECK:STDOUT: }
  494. // CHECK:STDOUT:
  495. // CHECK:STDOUT: fn @__global_init() {
  496. // CHECK:STDOUT: !entry:
  497. // CHECK:STDOUT: %.loc6_25.1: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  498. // CHECK:STDOUT: %.loc6_26.1: %struct_type.x = struct_literal (%.loc6_25.1) [concrete = constants.%struct]
  499. // CHECK:STDOUT: %.loc6_26.2: ref %empty_tuple.type = class_element_access file.%c.var, element0 [concrete = constants.%.dd7]
  500. // CHECK:STDOUT: %.loc6_25.2: init %empty_tuple.type = tuple_init () to %.loc6_26.2 [concrete = constants.%empty_tuple]
  501. // CHECK:STDOUT: %.loc6_26.3: init %empty_tuple.type = converted %.loc6_25.1, %.loc6_25.2 [concrete = constants.%empty_tuple]
  502. // CHECK:STDOUT: %.loc6_26.4: init %C = class_init (%.loc6_26.3), file.%c.var [concrete = constants.%C.val]
  503. // CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_26.1, %.loc6_26.4 [concrete = constants.%C.val]
  504. // CHECK:STDOUT: assign file.%c.var, %.loc6_1
  505. // CHECK:STDOUT: return
  506. // CHECK:STDOUT: }
  507. // CHECK:STDOUT:
  508. // CHECK:STDOUT: --- use_export_name.carbon
  509. // CHECK:STDOUT:
  510. // CHECK:STDOUT: constants {
  511. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  512. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  513. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [concrete]
  514. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x [concrete]
  515. // CHECK:STDOUT: %pattern_type: type = pattern_type %C [concrete]
  516. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  517. // CHECK:STDOUT: %struct: %struct_type.x = struct_value (%empty_tuple) [concrete]
  518. // CHECK:STDOUT: %.dd7: ref %empty_tuple.type = class_element_access file.%c.var, element0 [concrete]
  519. // CHECK:STDOUT: %C.val: %C = struct_value (%empty_tuple) [concrete]
  520. // CHECK:STDOUT: }
  521. // CHECK:STDOUT:
  522. // CHECK:STDOUT: imports {
  523. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  524. // CHECK:STDOUT: .C = %Other.C
  525. // CHECK:STDOUT: import Other//export_name
  526. // CHECK:STDOUT: }
  527. // CHECK:STDOUT: %Other.C: type = import_ref Other//export_name, C, loaded [concrete = constants.%C]
  528. // CHECK:STDOUT: %Other.import_ref.ad3: <witness> = import_ref Other//export_name, inst{{[0-9A-F]+}} [indirect], loaded [concrete = constants.%complete_type]
  529. // CHECK:STDOUT: %Other.import_ref.3c4 = import_ref Other//export_name, inst{{[0-9A-F]+}} [indirect], unloaded
  530. // CHECK:STDOUT: %Other.import_ref.249 = import_ref Other//export_name, inst{{[0-9A-F]+}} [indirect], unloaded
  531. // CHECK:STDOUT: }
  532. // CHECK:STDOUT:
  533. // CHECK:STDOUT: file {
  534. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  535. // CHECK:STDOUT: .Other = imports.%Other
  536. // CHECK:STDOUT: .c = %c
  537. // CHECK:STDOUT: }
  538. // CHECK:STDOUT: %Other.import = import Other
  539. // CHECK:STDOUT: name_binding_decl {
  540. // CHECK:STDOUT: %c.patt: %pattern_type = ref_binding_pattern c [concrete]
  541. // CHECK:STDOUT: %c.var_patt: %pattern_type = var_pattern %c.patt [concrete]
  542. // CHECK:STDOUT: }
  543. // CHECK:STDOUT: %c.var: ref %C = var %c.var_patt [concrete]
  544. // CHECK:STDOUT: %.loc6: type = splice_block %C.ref [concrete = constants.%C] {
  545. // CHECK:STDOUT: %Other.ref: <namespace> = name_ref Other, imports.%Other [concrete = imports.%Other]
  546. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Other.C [concrete = constants.%C]
  547. // CHECK:STDOUT: }
  548. // CHECK:STDOUT: %c: ref %C = ref_binding c, %c.var [concrete = %c.var]
  549. // CHECK:STDOUT: }
  550. // CHECK:STDOUT:
  551. // CHECK:STDOUT: class @C [from "export_name.carbon"] {
  552. // CHECK:STDOUT: complete_type_witness = imports.%Other.import_ref.ad3
  553. // CHECK:STDOUT:
  554. // CHECK:STDOUT: !members:
  555. // CHECK:STDOUT: .Self = imports.%Other.import_ref.3c4
  556. // CHECK:STDOUT: .x = imports.%Other.import_ref.249
  557. // CHECK:STDOUT: }
  558. // CHECK:STDOUT:
  559. // CHECK:STDOUT: fn @__global_init() {
  560. // CHECK:STDOUT: !entry:
  561. // CHECK:STDOUT: %.loc6_25.1: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  562. // CHECK:STDOUT: %.loc6_26.1: %struct_type.x = struct_literal (%.loc6_25.1) [concrete = constants.%struct]
  563. // CHECK:STDOUT: %.loc6_26.2: ref %empty_tuple.type = class_element_access file.%c.var, element0 [concrete = constants.%.dd7]
  564. // CHECK:STDOUT: %.loc6_25.2: init %empty_tuple.type = tuple_init () to %.loc6_26.2 [concrete = constants.%empty_tuple]
  565. // CHECK:STDOUT: %.loc6_26.3: init %empty_tuple.type = converted %.loc6_25.1, %.loc6_25.2 [concrete = constants.%empty_tuple]
  566. // CHECK:STDOUT: %.loc6_26.4: init %C = class_init (%.loc6_26.3), file.%c.var [concrete = constants.%C.val]
  567. // CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_26.1, %.loc6_26.4 [concrete = constants.%C.val]
  568. // CHECK:STDOUT: assign file.%c.var, %.loc6_1
  569. // CHECK:STDOUT: return
  570. // CHECK:STDOUT: }
  571. // CHECK:STDOUT:
  572. // CHECK:STDOUT: --- use_export_name_with_copy.carbon
  573. // CHECK:STDOUT:
  574. // CHECK:STDOUT: constants {
  575. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  576. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  577. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [concrete]
  578. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x [concrete]
  579. // CHECK:STDOUT: %pattern_type: type = pattern_type %C [concrete]
  580. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  581. // CHECK:STDOUT: %struct: %struct_type.x = struct_value (%empty_tuple) [concrete]
  582. // CHECK:STDOUT: %.dd7: ref %empty_tuple.type = class_element_access file.%c.var, element0 [concrete]
  583. // CHECK:STDOUT: %C.val: %C = struct_value (%empty_tuple) [concrete]
  584. // CHECK:STDOUT: }
  585. // CHECK:STDOUT:
  586. // CHECK:STDOUT: imports {
  587. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  588. // CHECK:STDOUT: .C = %Other.C
  589. // CHECK:STDOUT: import Other//export_name
  590. // CHECK:STDOUT: import Other//export_name_copy
  591. // CHECK:STDOUT: }
  592. // CHECK:STDOUT: %Other.C: type = import_ref Other//export_name, C, loaded [concrete = constants.%C]
  593. // CHECK:STDOUT: %Other.import_ref.ad3: <witness> = import_ref Other//export_name, inst{{[0-9A-F]+}} [indirect], loaded [concrete = constants.%complete_type]
  594. // CHECK:STDOUT: %Other.import_ref.3c4 = import_ref Other//export_name, inst{{[0-9A-F]+}} [indirect], unloaded
  595. // CHECK:STDOUT: %Other.import_ref.249 = import_ref Other//export_name, inst{{[0-9A-F]+}} [indirect], unloaded
  596. // CHECK:STDOUT: }
  597. // CHECK:STDOUT:
  598. // CHECK:STDOUT: file {
  599. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  600. // CHECK:STDOUT: .Other = imports.%Other
  601. // CHECK:STDOUT: .c = %c
  602. // CHECK:STDOUT: }
  603. // CHECK:STDOUT: %Other.import = import Other
  604. // CHECK:STDOUT: name_binding_decl {
  605. // CHECK:STDOUT: %c.patt: %pattern_type = ref_binding_pattern c [concrete]
  606. // CHECK:STDOUT: %c.var_patt: %pattern_type = var_pattern %c.patt [concrete]
  607. // CHECK:STDOUT: }
  608. // CHECK:STDOUT: %c.var: ref %C = var %c.var_patt [concrete]
  609. // CHECK:STDOUT: %.loc7: type = splice_block %C.ref [concrete = constants.%C] {
  610. // CHECK:STDOUT: %Other.ref: <namespace> = name_ref Other, imports.%Other [concrete = imports.%Other]
  611. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Other.C [concrete = constants.%C]
  612. // CHECK:STDOUT: }
  613. // CHECK:STDOUT: %c: ref %C = ref_binding c, %c.var [concrete = %c.var]
  614. // CHECK:STDOUT: }
  615. // CHECK:STDOUT:
  616. // CHECK:STDOUT: class @C [from "export_name.carbon"] {
  617. // CHECK:STDOUT: complete_type_witness = imports.%Other.import_ref.ad3
  618. // CHECK:STDOUT:
  619. // CHECK:STDOUT: !members:
  620. // CHECK:STDOUT: .Self = imports.%Other.import_ref.3c4
  621. // CHECK:STDOUT: .x = imports.%Other.import_ref.249
  622. // CHECK:STDOUT: }
  623. // CHECK:STDOUT:
  624. // CHECK:STDOUT: fn @__global_init() {
  625. // CHECK:STDOUT: !entry:
  626. // CHECK:STDOUT: %.loc7_25.1: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  627. // CHECK:STDOUT: %.loc7_26.1: %struct_type.x = struct_literal (%.loc7_25.1) [concrete = constants.%struct]
  628. // CHECK:STDOUT: %.loc7_26.2: ref %empty_tuple.type = class_element_access file.%c.var, element0 [concrete = constants.%.dd7]
  629. // CHECK:STDOUT: %.loc7_25.2: init %empty_tuple.type = tuple_init () to %.loc7_26.2 [concrete = constants.%empty_tuple]
  630. // CHECK:STDOUT: %.loc7_26.3: init %empty_tuple.type = converted %.loc7_25.1, %.loc7_25.2 [concrete = constants.%empty_tuple]
  631. // CHECK:STDOUT: %.loc7_26.4: init %C = class_init (%.loc7_26.3), file.%c.var [concrete = constants.%C.val]
  632. // CHECK:STDOUT: %.loc7_1: init %C = converted %.loc7_26.1, %.loc7_26.4 [concrete = constants.%C.val]
  633. // CHECK:STDOUT: assign file.%c.var, %.loc7_1
  634. // CHECK:STDOUT: return
  635. // CHECK:STDOUT: }
  636. // CHECK:STDOUT:
  637. // CHECK:STDOUT: --- use_export_name_indirect.carbon
  638. // CHECK:STDOUT:
  639. // CHECK:STDOUT: constants {
  640. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  641. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  642. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [concrete]
  643. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x [concrete]
  644. // CHECK:STDOUT: %pattern_type: type = pattern_type %C [concrete]
  645. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  646. // CHECK:STDOUT: %struct: %struct_type.x = struct_value (%empty_tuple) [concrete]
  647. // CHECK:STDOUT: %.dd7: ref %empty_tuple.type = class_element_access file.%c.var, element0 [concrete]
  648. // CHECK:STDOUT: %C.val: %C = struct_value (%empty_tuple) [concrete]
  649. // CHECK:STDOUT: }
  650. // CHECK:STDOUT:
  651. // CHECK:STDOUT: imports {
  652. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  653. // CHECK:STDOUT: .C = %Other.C
  654. // CHECK:STDOUT: import Other//export_name_indirect
  655. // CHECK:STDOUT: }
  656. // CHECK:STDOUT: %Other.C: type = import_ref Other//export_name_indirect, C, loaded [concrete = constants.%C]
  657. // CHECK:STDOUT: %Other.import_ref.328: <witness> = import_ref Other//export_name_indirect, inst{{[0-9A-F]+}} [indirect], loaded [concrete = constants.%complete_type]
  658. // CHECK:STDOUT: %Other.import_ref.c1f = import_ref Other//export_name_indirect, inst{{[0-9A-F]+}} [indirect], unloaded
  659. // CHECK:STDOUT: %Other.import_ref.3e3 = import_ref Other//export_name_indirect, inst{{[0-9A-F]+}} [indirect], unloaded
  660. // CHECK:STDOUT: }
  661. // CHECK:STDOUT:
  662. // CHECK:STDOUT: file {
  663. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  664. // CHECK:STDOUT: .Other = imports.%Other
  665. // CHECK:STDOUT: .c = %c
  666. // CHECK:STDOUT: }
  667. // CHECK:STDOUT: %Other.import = import Other
  668. // CHECK:STDOUT: name_binding_decl {
  669. // CHECK:STDOUT: %c.patt: %pattern_type = ref_binding_pattern c [concrete]
  670. // CHECK:STDOUT: %c.var_patt: %pattern_type = var_pattern %c.patt [concrete]
  671. // CHECK:STDOUT: }
  672. // CHECK:STDOUT: %c.var: ref %C = var %c.var_patt [concrete]
  673. // CHECK:STDOUT: %.loc6: type = splice_block %C.ref [concrete = constants.%C] {
  674. // CHECK:STDOUT: %Other.ref: <namespace> = name_ref Other, imports.%Other [concrete = imports.%Other]
  675. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Other.C [concrete = constants.%C]
  676. // CHECK:STDOUT: }
  677. // CHECK:STDOUT: %c: ref %C = ref_binding c, %c.var [concrete = %c.var]
  678. // CHECK:STDOUT: }
  679. // CHECK:STDOUT:
  680. // CHECK:STDOUT: class @C [from "export_name_indirect.carbon"] {
  681. // CHECK:STDOUT: complete_type_witness = imports.%Other.import_ref.328
  682. // CHECK:STDOUT:
  683. // CHECK:STDOUT: !members:
  684. // CHECK:STDOUT: .Self = imports.%Other.import_ref.c1f
  685. // CHECK:STDOUT: .x = imports.%Other.import_ref.3e3
  686. // CHECK:STDOUT: }
  687. // CHECK:STDOUT:
  688. // CHECK:STDOUT: fn @__global_init() {
  689. // CHECK:STDOUT: !entry:
  690. // CHECK:STDOUT: %.loc6_25.1: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  691. // CHECK:STDOUT: %.loc6_26.1: %struct_type.x = struct_literal (%.loc6_25.1) [concrete = constants.%struct]
  692. // CHECK:STDOUT: %.loc6_26.2: ref %empty_tuple.type = class_element_access file.%c.var, element0 [concrete = constants.%.dd7]
  693. // CHECK:STDOUT: %.loc6_25.2: init %empty_tuple.type = tuple_init () to %.loc6_26.2 [concrete = constants.%empty_tuple]
  694. // CHECK:STDOUT: %.loc6_26.3: init %empty_tuple.type = converted %.loc6_25.1, %.loc6_25.2 [concrete = constants.%empty_tuple]
  695. // CHECK:STDOUT: %.loc6_26.4: init %C = class_init (%.loc6_26.3), file.%c.var [concrete = constants.%C.val]
  696. // CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_26.1, %.loc6_26.4 [concrete = constants.%C.val]
  697. // CHECK:STDOUT: assign file.%c.var, %.loc6_1
  698. // CHECK:STDOUT: return
  699. // CHECK:STDOUT: }
  700. // CHECK:STDOUT:
  701. // CHECK:STDOUT: --- use_export_all.carbon
  702. // CHECK:STDOUT:
  703. // CHECK:STDOUT: constants {
  704. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  705. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  706. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [concrete]
  707. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x [concrete]
  708. // CHECK:STDOUT: %pattern_type: type = pattern_type %C [concrete]
  709. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  710. // CHECK:STDOUT: %struct: %struct_type.x = struct_value (%empty_tuple) [concrete]
  711. // CHECK:STDOUT: %.dd7: ref %empty_tuple.type = class_element_access file.%c.var, element0 [concrete]
  712. // CHECK:STDOUT: %C.val: %C = struct_value (%empty_tuple) [concrete]
  713. // CHECK:STDOUT: }
  714. // CHECK:STDOUT:
  715. // CHECK:STDOUT: imports {
  716. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  717. // CHECK:STDOUT: .C = %Other.C
  718. // CHECK:STDOUT: import Other//export_import
  719. // CHECK:STDOUT: import Other//export_name
  720. // CHECK:STDOUT: import Other//export_import_copy
  721. // CHECK:STDOUT: import Other//export_name_copy
  722. // CHECK:STDOUT: import Other//export_import_indirect
  723. // CHECK:STDOUT: import Other//export_name_indirect
  724. // CHECK:STDOUT: import Other//base
  725. // CHECK:STDOUT: }
  726. // CHECK:STDOUT: %Other.C: type = import_ref Other//export_name, C, loaded [concrete = constants.%C]
  727. // CHECK:STDOUT: %Other.import_ref.ad3: <witness> = import_ref Other//export_name, inst{{[0-9A-F]+}} [indirect], loaded [concrete = constants.%complete_type]
  728. // CHECK:STDOUT: %Other.import_ref.3c4 = import_ref Other//export_name, inst{{[0-9A-F]+}} [indirect], unloaded
  729. // CHECK:STDOUT: %Other.import_ref.249 = import_ref Other//export_name, inst{{[0-9A-F]+}} [indirect], unloaded
  730. // CHECK:STDOUT: }
  731. // CHECK:STDOUT:
  732. // CHECK:STDOUT: file {
  733. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  734. // CHECK:STDOUT: .Other = imports.%Other
  735. // CHECK:STDOUT: .c = %c
  736. // CHECK:STDOUT: }
  737. // CHECK:STDOUT: %Other.import = import Other
  738. // CHECK:STDOUT: name_binding_decl {
  739. // CHECK:STDOUT: %c.patt: %pattern_type = ref_binding_pattern c [concrete]
  740. // CHECK:STDOUT: %c.var_patt: %pattern_type = var_pattern %c.patt [concrete]
  741. // CHECK:STDOUT: }
  742. // CHECK:STDOUT: %c.var: ref %C = var %c.var_patt [concrete]
  743. // CHECK:STDOUT: %.loc11: type = splice_block %C.ref [concrete = constants.%C] {
  744. // CHECK:STDOUT: %Other.ref: <namespace> = name_ref Other, imports.%Other [concrete = imports.%Other]
  745. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Other.C [concrete = constants.%C]
  746. // CHECK:STDOUT: }
  747. // CHECK:STDOUT: %c: ref %C = ref_binding c, %c.var [concrete = %c.var]
  748. // CHECK:STDOUT: }
  749. // CHECK:STDOUT:
  750. // CHECK:STDOUT: class @C [from "export_name.carbon"] {
  751. // CHECK:STDOUT: complete_type_witness = imports.%Other.import_ref.ad3
  752. // CHECK:STDOUT:
  753. // CHECK:STDOUT: !members:
  754. // CHECK:STDOUT: .Self = imports.%Other.import_ref.3c4
  755. // CHECK:STDOUT: .x = imports.%Other.import_ref.249
  756. // CHECK:STDOUT: }
  757. // CHECK:STDOUT:
  758. // CHECK:STDOUT: fn @__global_init() {
  759. // CHECK:STDOUT: !entry:
  760. // CHECK:STDOUT: %.loc11_25.1: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  761. // CHECK:STDOUT: %.loc11_26.1: %struct_type.x = struct_literal (%.loc11_25.1) [concrete = constants.%struct]
  762. // CHECK:STDOUT: %.loc11_26.2: ref %empty_tuple.type = class_element_access file.%c.var, element0 [concrete = constants.%.dd7]
  763. // CHECK:STDOUT: %.loc11_25.2: init %empty_tuple.type = tuple_init () to %.loc11_26.2 [concrete = constants.%empty_tuple]
  764. // CHECK:STDOUT: %.loc11_26.3: init %empty_tuple.type = converted %.loc11_25.1, %.loc11_25.2 [concrete = constants.%empty_tuple]
  765. // CHECK:STDOUT: %.loc11_26.4: init %C = class_init (%.loc11_26.3), file.%c.var [concrete = constants.%C.val]
  766. // CHECK:STDOUT: %.loc11_1: init %C = converted %.loc11_26.1, %.loc11_26.4 [concrete = constants.%C.val]
  767. // CHECK:STDOUT: assign file.%c.var, %.loc11_1
  768. // CHECK:STDOUT: return
  769. // CHECK:STDOUT: }
  770. // CHECK:STDOUT:
  771. // CHECK:STDOUT: --- unused_conflict_on_export_import.carbon
  772. // CHECK:STDOUT:
  773. // CHECK:STDOUT: imports {
  774. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  775. // CHECK:STDOUT: import Other//export_import
  776. // CHECK:STDOUT: import Other//conflict
  777. // CHECK:STDOUT: import Other//base
  778. // CHECK:STDOUT: }
  779. // CHECK:STDOUT: }
  780. // CHECK:STDOUT:
  781. // CHECK:STDOUT: file {
  782. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  783. // CHECK:STDOUT: .Other = imports.%Other
  784. // CHECK:STDOUT: }
  785. // CHECK:STDOUT: %Other.import = import Other
  786. // CHECK:STDOUT: }
  787. // CHECK:STDOUT:
  788. // CHECK:STDOUT: --- unused_conflict_on_export_name.carbon
  789. // CHECK:STDOUT:
  790. // CHECK:STDOUT: imports {
  791. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  792. // CHECK:STDOUT: import Other//export_name
  793. // CHECK:STDOUT: import Other//conflict
  794. // CHECK:STDOUT: }
  795. // CHECK:STDOUT: }
  796. // CHECK:STDOUT:
  797. // CHECK:STDOUT: file {
  798. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  799. // CHECK:STDOUT: .Other = imports.%Other
  800. // CHECK:STDOUT: }
  801. // CHECK:STDOUT: %Other.import = import Other
  802. // CHECK:STDOUT: }
  803. // CHECK:STDOUT:
  804. // CHECK:STDOUT: --- fail_conflict_on_export_import.carbon
  805. // CHECK:STDOUT:
  806. // CHECK:STDOUT: constants {
  807. // CHECK:STDOUT: %C.type: type = fn_type @C [concrete]
  808. // CHECK:STDOUT: %C: %C.type = struct_value () [concrete]
  809. // CHECK:STDOUT: }
  810. // CHECK:STDOUT:
  811. // CHECK:STDOUT: imports {
  812. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  813. // CHECK:STDOUT: .C = %Other.C
  814. // CHECK:STDOUT: import Other//export_import
  815. // CHECK:STDOUT: import Other//conflict
  816. // CHECK:STDOUT: import Other//base
  817. // CHECK:STDOUT: }
  818. // CHECK:STDOUT: %Other.C: %C.type = import_ref Other//conflict, C, loaded [concrete = constants.%C]
  819. // CHECK:STDOUT: }
  820. // CHECK:STDOUT:
  821. // CHECK:STDOUT: file {
  822. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  823. // CHECK:STDOUT: .Other = imports.%Other
  824. // CHECK:STDOUT: .C = %C
  825. // CHECK:STDOUT: }
  826. // CHECK:STDOUT: %Other.import = import Other
  827. // CHECK:STDOUT: %Other.ref: <namespace> = name_ref Other, imports.%Other [concrete = imports.%Other]
  828. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%Other.C [concrete = constants.%C]
  829. // CHECK:STDOUT: %C: %C.type = alias_binding C, imports.%Other.C [concrete = constants.%C]
  830. // CHECK:STDOUT: }
  831. // CHECK:STDOUT:
  832. // CHECK:STDOUT: fn @C [from "conflict.carbon"];
  833. // CHECK:STDOUT:
  834. // CHECK:STDOUT: --- fail_conflict_on_export_name.carbon
  835. // CHECK:STDOUT:
  836. // CHECK:STDOUT: constants {
  837. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  838. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  839. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [concrete]
  840. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x [concrete]
  841. // CHECK:STDOUT: }
  842. // CHECK:STDOUT:
  843. // CHECK:STDOUT: imports {
  844. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [concrete] {
  845. // CHECK:STDOUT: .C = %Other.C
  846. // CHECK:STDOUT: import Other//export_name
  847. // CHECK:STDOUT: import Other//conflict
  848. // CHECK:STDOUT: }
  849. // CHECK:STDOUT: %Other.C: type = import_ref Other//export_name, C, loaded [concrete = constants.%C]
  850. // CHECK:STDOUT: %Other.import_ref.ad3: <witness> = import_ref Other//export_name, inst{{[0-9A-F]+}} [indirect], loaded [concrete = constants.%complete_type]
  851. // CHECK:STDOUT: %Other.import_ref.3c4 = import_ref Other//export_name, inst{{[0-9A-F]+}} [indirect], unloaded
  852. // CHECK:STDOUT: %Other.import_ref.249 = import_ref Other//export_name, inst{{[0-9A-F]+}} [indirect], unloaded
  853. // CHECK:STDOUT: }
  854. // CHECK:STDOUT:
  855. // CHECK:STDOUT: file {
  856. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  857. // CHECK:STDOUT: .Other = imports.%Other
  858. // CHECK:STDOUT: .C = %C
  859. // CHECK:STDOUT: }
  860. // CHECK:STDOUT: %Other.import = import Other
  861. // CHECK:STDOUT: %Other.ref: <namespace> = name_ref Other, imports.%Other [concrete = imports.%Other]
  862. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Other.C [concrete = constants.%C]
  863. // CHECK:STDOUT: %C: type = alias_binding C, imports.%Other.C [concrete = constants.%C]
  864. // CHECK:STDOUT: }
  865. // CHECK:STDOUT:
  866. // CHECK:STDOUT: class @C [from "export_name.carbon"] {
  867. // CHECK:STDOUT: complete_type_witness = imports.%Other.import_ref.ad3
  868. // CHECK:STDOUT:
  869. // CHECK:STDOUT: !members:
  870. // CHECK:STDOUT: .Self = imports.%Other.import_ref.3c4
  871. // CHECK:STDOUT: .x = imports.%Other.import_ref.249
  872. // CHECK:STDOUT: }
  873. // CHECK:STDOUT: