export_import.carbon 36 KB

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