cross_package_export.carbon 40 KB

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