export_name.carbon 38 KB

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