export_name.carbon 42 KB

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