export_name.carbon 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976
  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: %C.elem: type = unbound_element_type %C, %empty_tuple.type [template]
  144. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [template]
  145. // CHECK:STDOUT: %complete_type.9be: <witness> = complete_type_witness %struct_type.x [template]
  146. // CHECK:STDOUT: %NSC: type = class_type @NSC [template]
  147. // CHECK:STDOUT: %NSC.elem: type = unbound_element_type %NSC, %empty_tuple.type [template]
  148. // CHECK:STDOUT: %struct_type.y: type = struct_type {.y: %empty_tuple.type} [template]
  149. // CHECK:STDOUT: %complete_type.9f4: <witness> = complete_type_witness %struct_type.y [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: %C.elem = field_decl x, element0 [template]
  166. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x [template = constants.%complete_type.9be]
  167. // CHECK:STDOUT:
  168. // CHECK:STDOUT: !members:
  169. // CHECK:STDOUT: .Self = constants.%C
  170. // CHECK:STDOUT: .x = %.loc5
  171. // CHECK:STDOUT: complete_type_witness = %complete_type
  172. // CHECK:STDOUT: }
  173. // CHECK:STDOUT:
  174. // CHECK:STDOUT: class @NSC {
  175. // CHECK:STDOUT: %.loc10: %NSC.elem = field_decl y, element0 [template]
  176. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.y [template = constants.%complete_type.9f4]
  177. // CHECK:STDOUT:
  178. // CHECK:STDOUT: !members:
  179. // CHECK:STDOUT: .Self = constants.%NSC
  180. // CHECK:STDOUT: .y = %.loc10
  181. // CHECK:STDOUT: complete_type_witness = %complete_type
  182. // CHECK:STDOUT: }
  183. // CHECK:STDOUT:
  184. // CHECK:STDOUT: --- export.carbon
  185. // CHECK:STDOUT:
  186. // CHECK:STDOUT: constants {
  187. // CHECK:STDOUT: %C: type = class_type @C [template]
  188. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  189. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [template]
  190. // CHECK:STDOUT: %complete_type.9be: <witness> = complete_type_witness %struct_type.x [template]
  191. // CHECK:STDOUT: %NSC: type = class_type @NSC [template]
  192. // CHECK:STDOUT: %struct_type.y: type = struct_type {.y: %empty_tuple.type} [template]
  193. // CHECK:STDOUT: %complete_type.9f4: <witness> = complete_type_witness %struct_type.y [template]
  194. // CHECK:STDOUT: }
  195. // CHECK:STDOUT:
  196. // CHECK:STDOUT: imports {
  197. // CHECK:STDOUT: %import_ref.0ac: type = import_ref Main//base, C, loaded [template = constants.%C]
  198. // CHECK:STDOUT: %import_ref.d58: <namespace> = import_ref Main//base, NS, loaded
  199. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.d58, [template] {
  200. // CHECK:STDOUT: .NSC = file.%NSC
  201. // CHECK:STDOUT: }
  202. // CHECK:STDOUT: %import_ref.88a: type = import_ref Main//base, NSC, loaded [template = constants.%NSC]
  203. // CHECK:STDOUT: %import_ref.56d: <witness> = import_ref Main//base, loc6_1, loaded [template = constants.%complete_type.9be]
  204. // CHECK:STDOUT: %import_ref.2c4 = import_ref Main//base, inst14 [no loc], unloaded
  205. // CHECK:STDOUT: %import_ref.276 = import_ref Main//base, loc5_8, unloaded
  206. // CHECK:STDOUT: %import_ref.5ab: <witness> = import_ref Main//base, loc11_1, loaded [template = constants.%complete_type.9f4]
  207. // CHECK:STDOUT: %import_ref.31c = import_ref Main//base, inst25 [no loc], unloaded
  208. // CHECK:STDOUT: %import_ref.be6 = import_ref Main//base, loc10_8, unloaded
  209. // CHECK:STDOUT: }
  210. // CHECK:STDOUT:
  211. // CHECK:STDOUT: file {
  212. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  213. // CHECK:STDOUT: .C = %C
  214. // CHECK:STDOUT: .NS = imports.%NS
  215. // CHECK:STDOUT: }
  216. // CHECK:STDOUT: %default.import = import <invalid>
  217. // CHECK:STDOUT: %C: type = export C, imports.%import_ref.0ac [template = constants.%C]
  218. // CHECK:STDOUT: %NSC: type = export NSC, imports.%import_ref.88a [template = constants.%NSC]
  219. // CHECK:STDOUT: }
  220. // CHECK:STDOUT:
  221. // CHECK:STDOUT: class @C [from "base.carbon"] {
  222. // CHECK:STDOUT: !members:
  223. // CHECK:STDOUT: .Self = imports.%import_ref.2c4
  224. // CHECK:STDOUT: .x = imports.%import_ref.276
  225. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.56d
  226. // CHECK:STDOUT: }
  227. // CHECK:STDOUT:
  228. // CHECK:STDOUT: class @NSC [from "base.carbon"] {
  229. // CHECK:STDOUT: !members:
  230. // CHECK:STDOUT: .Self = imports.%import_ref.31c
  231. // CHECK:STDOUT: .y = imports.%import_ref.be6
  232. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.5ab
  233. // CHECK:STDOUT: }
  234. // CHECK:STDOUT:
  235. // CHECK:STDOUT: --- not_reexporting.carbon
  236. // CHECK:STDOUT:
  237. // CHECK:STDOUT: imports {
  238. // CHECK:STDOUT: %import_ref.ec9 = import_ref Main//export, C, unloaded
  239. // CHECK:STDOUT: %import_ref.0f6: <namespace> = import_ref Main//export, NS, loaded
  240. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.0f6, [template] {
  241. // CHECK:STDOUT: .NSC = %import_ref.4ef
  242. // CHECK:STDOUT: }
  243. // CHECK:STDOUT: }
  244. // CHECK:STDOUT:
  245. // CHECK:STDOUT: file {
  246. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  247. // CHECK:STDOUT: .C = imports.%import_ref.ec9
  248. // CHECK:STDOUT: .NS = imports.%NS
  249. // CHECK:STDOUT: }
  250. // CHECK:STDOUT: %default.import = import <invalid>
  251. // CHECK:STDOUT: }
  252. // CHECK:STDOUT:
  253. // CHECK:STDOUT: --- export_export.carbon
  254. // CHECK:STDOUT:
  255. // CHECK:STDOUT: constants {
  256. // CHECK:STDOUT: %C: type = class_type @C [template]
  257. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  258. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [template]
  259. // CHECK:STDOUT: %complete_type.9be: <witness> = complete_type_witness %struct_type.x [template]
  260. // CHECK:STDOUT: %NSC: type = class_type @NSC [template]
  261. // CHECK:STDOUT: %struct_type.y: type = struct_type {.y: %empty_tuple.type} [template]
  262. // CHECK:STDOUT: %complete_type.9f4: <witness> = complete_type_witness %struct_type.y [template]
  263. // CHECK:STDOUT: }
  264. // CHECK:STDOUT:
  265. // CHECK:STDOUT: imports {
  266. // CHECK:STDOUT: %import_ref.4a7: type = import_ref Main//export, C, loaded [template = constants.%C]
  267. // CHECK:STDOUT: %import_ref.0f6: <namespace> = import_ref Main//export, NS, loaded
  268. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.0f6, [template] {
  269. // CHECK:STDOUT: .NSC = file.%NSC
  270. // CHECK:STDOUT: }
  271. // CHECK:STDOUT: %import_ref.833: type = import_ref Main//export, NSC, loaded [template = constants.%NSC]
  272. // CHECK:STDOUT: %import_ref.ad3: <witness> = import_ref Main//export, inst23 [indirect], loaded [template = constants.%complete_type.9be]
  273. // CHECK:STDOUT: %import_ref.6a9 = import_ref Main//export, inst24 [indirect], unloaded
  274. // CHECK:STDOUT: %import_ref.f67 = import_ref Main//export, inst25 [indirect], unloaded
  275. // CHECK:STDOUT: %import_ref.63c: <witness> = import_ref Main//export, inst31 [indirect], loaded [template = constants.%complete_type.9f4]
  276. // CHECK:STDOUT: %import_ref.f0b = import_ref Main//export, inst32 [indirect], unloaded
  277. // CHECK:STDOUT: %import_ref.ebc = import_ref Main//export, inst33 [indirect], unloaded
  278. // CHECK:STDOUT: }
  279. // CHECK:STDOUT:
  280. // CHECK:STDOUT: file {
  281. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  282. // CHECK:STDOUT: .C = %C
  283. // CHECK:STDOUT: .NS = imports.%NS
  284. // CHECK:STDOUT: }
  285. // CHECK:STDOUT: %default.import = import <invalid>
  286. // CHECK:STDOUT: %C: type = export C, imports.%import_ref.4a7 [template = constants.%C]
  287. // CHECK:STDOUT: %NSC: type = export NSC, imports.%import_ref.833 [template = constants.%NSC]
  288. // CHECK:STDOUT: }
  289. // CHECK:STDOUT:
  290. // CHECK:STDOUT: class @C [from "export.carbon"] {
  291. // CHECK:STDOUT: !members:
  292. // CHECK:STDOUT: .Self = imports.%import_ref.6a9
  293. // CHECK:STDOUT: .x = imports.%import_ref.f67
  294. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.ad3
  295. // CHECK:STDOUT: }
  296. // CHECK:STDOUT:
  297. // CHECK:STDOUT: class @NSC [from "export.carbon"] {
  298. // CHECK:STDOUT: !members:
  299. // CHECK:STDOUT: .Self = imports.%import_ref.f0b
  300. // CHECK:STDOUT: .y = imports.%import_ref.ebc
  301. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.63c
  302. // CHECK:STDOUT: }
  303. // CHECK:STDOUT:
  304. // CHECK:STDOUT: --- export_in_impl.carbon
  305. // CHECK:STDOUT:
  306. // CHECK:STDOUT: file {
  307. // CHECK:STDOUT: package: <namespace> = namespace [template] {}
  308. // CHECK:STDOUT: }
  309. // CHECK:STDOUT:
  310. // CHECK:STDOUT: --- use_export.carbon
  311. // CHECK:STDOUT:
  312. // CHECK:STDOUT: constants {
  313. // CHECK:STDOUT: %C: type = class_type @C [template]
  314. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  315. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [template]
  316. // CHECK:STDOUT: %complete_type.9be: <witness> = complete_type_witness %struct_type.x [template]
  317. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
  318. // CHECK:STDOUT: %C.val: %C = struct_value (%empty_tuple) [template]
  319. // CHECK:STDOUT: %NSC: type = class_type @NSC [template]
  320. // CHECK:STDOUT: %struct_type.y: type = struct_type {.y: %empty_tuple.type} [template]
  321. // CHECK:STDOUT: %complete_type.9f4: <witness> = complete_type_witness %struct_type.y [template]
  322. // CHECK:STDOUT: %NSC.val: %NSC = struct_value (%empty_tuple) [template]
  323. // CHECK:STDOUT: }
  324. // CHECK:STDOUT:
  325. // CHECK:STDOUT: imports {
  326. // CHECK:STDOUT: %import_ref.4a7: type = import_ref Main//export, C, loaded [template = constants.%C]
  327. // CHECK:STDOUT: %import_ref.0f6: <namespace> = import_ref Main//export, NS, loaded
  328. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.0f6, [template] {
  329. // CHECK:STDOUT: .NSC = %import_ref.833
  330. // CHECK:STDOUT: }
  331. // CHECK:STDOUT: %import_ref.ad3: <witness> = import_ref Main//export, inst23 [indirect], loaded [template = constants.%complete_type.9be]
  332. // CHECK:STDOUT: %import_ref.6a9 = import_ref Main//export, inst24 [indirect], unloaded
  333. // CHECK:STDOUT: %import_ref.f67 = import_ref Main//export, inst25 [indirect], unloaded
  334. // CHECK:STDOUT: %import_ref.63c: <witness> = import_ref Main//export, inst31 [indirect], loaded [template = constants.%complete_type.9f4]
  335. // CHECK:STDOUT: %import_ref.f0b = import_ref Main//export, inst32 [indirect], unloaded
  336. // CHECK:STDOUT: %import_ref.ebc = import_ref Main//export, inst33 [indirect], unloaded
  337. // CHECK:STDOUT: }
  338. // CHECK:STDOUT:
  339. // CHECK:STDOUT: file {
  340. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  341. // CHECK:STDOUT: .C = imports.%import_ref.4a7
  342. // CHECK:STDOUT: .NS = imports.%NS
  343. // CHECK:STDOUT: .c = %c
  344. // CHECK:STDOUT: .nsc = %nsc
  345. // CHECK:STDOUT: }
  346. // CHECK:STDOUT: %default.import = import <invalid>
  347. // CHECK:STDOUT: %c.var: ref %C = var c
  348. // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var
  349. // CHECK:STDOUT: %nsc.var: ref %NSC = var nsc
  350. // CHECK:STDOUT: %nsc: ref %NSC = bind_name nsc, %nsc.var
  351. // CHECK:STDOUT: }
  352. // CHECK:STDOUT:
  353. // CHECK:STDOUT: class @C [from "export.carbon"] {
  354. // CHECK:STDOUT: !members:
  355. // CHECK:STDOUT: .Self = imports.%import_ref.6a9
  356. // CHECK:STDOUT: .x = imports.%import_ref.f67
  357. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.ad3
  358. // CHECK:STDOUT: }
  359. // CHECK:STDOUT:
  360. // CHECK:STDOUT: class @NSC [from "export.carbon"] {
  361. // CHECK:STDOUT: !members:
  362. // CHECK:STDOUT: .Self = imports.%import_ref.f0b
  363. // CHECK:STDOUT: .y = imports.%import_ref.ebc
  364. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.63c
  365. // CHECK:STDOUT: }
  366. // CHECK:STDOUT:
  367. // CHECK:STDOUT: fn @__global_init() {
  368. // CHECK:STDOUT: !entry:
  369. // CHECK:STDOUT: %.loc6_19.1: %empty_tuple.type = tuple_literal ()
  370. // CHECK:STDOUT: %.loc6_20.1: %struct_type.x = struct_literal (%.loc6_19.1)
  371. // CHECK:STDOUT: %.loc6_20.2: ref %empty_tuple.type = class_element_access file.%c.var, element0
  372. // CHECK:STDOUT: %.loc6_19.2: init %empty_tuple.type = tuple_init () to %.loc6_20.2 [template = constants.%empty_tuple]
  373. // CHECK:STDOUT: %.loc6_20.3: init %empty_tuple.type = converted %.loc6_19.1, %.loc6_19.2 [template = constants.%empty_tuple]
  374. // CHECK:STDOUT: %.loc6_20.4: init %C = class_init (%.loc6_20.3), file.%c.var [template = constants.%C.val]
  375. // CHECK:STDOUT: %.loc6_21: init %C = converted %.loc6_20.1, %.loc6_20.4 [template = constants.%C.val]
  376. // CHECK:STDOUT: assign file.%c.var, %.loc6_21
  377. // CHECK:STDOUT: %.loc7_26.1: %empty_tuple.type = tuple_literal ()
  378. // CHECK:STDOUT: %.loc7_27.1: %struct_type.y = struct_literal (%.loc7_26.1)
  379. // CHECK:STDOUT: %.loc7_27.2: ref %empty_tuple.type = class_element_access file.%nsc.var, element0
  380. // CHECK:STDOUT: %.loc7_26.2: init %empty_tuple.type = tuple_init () to %.loc7_27.2 [template = constants.%empty_tuple]
  381. // CHECK:STDOUT: %.loc7_27.3: init %empty_tuple.type = converted %.loc7_26.1, %.loc7_26.2 [template = constants.%empty_tuple]
  382. // CHECK:STDOUT: %.loc7_27.4: init %NSC = class_init (%.loc7_27.3), file.%nsc.var [template = constants.%NSC.val]
  383. // CHECK:STDOUT: %.loc7_28: init %NSC = converted %.loc7_27.1, %.loc7_27.4 [template = constants.%NSC.val]
  384. // CHECK:STDOUT: assign file.%nsc.var, %.loc7_28
  385. // CHECK:STDOUT: return
  386. // CHECK:STDOUT: }
  387. // CHECK:STDOUT:
  388. // CHECK:STDOUT: --- export_export.impl.carbon
  389. // CHECK:STDOUT:
  390. // CHECK:STDOUT: constants {
  391. // CHECK:STDOUT: %C: type = class_type @C [template]
  392. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  393. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [template]
  394. // CHECK:STDOUT: %complete_type.9be: <witness> = complete_type_witness %struct_type.x [template]
  395. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
  396. // CHECK:STDOUT: %C.val: %C = struct_value (%empty_tuple) [template]
  397. // CHECK:STDOUT: %NSC: type = class_type @NSC [template]
  398. // CHECK:STDOUT: %struct_type.y: type = struct_type {.y: %empty_tuple.type} [template]
  399. // CHECK:STDOUT: %complete_type.9f4: <witness> = complete_type_witness %struct_type.y [template]
  400. // CHECK:STDOUT: %NSC.val: %NSC = struct_value (%empty_tuple) [template]
  401. // CHECK:STDOUT: }
  402. // CHECK:STDOUT:
  403. // CHECK:STDOUT: imports {
  404. // CHECK:STDOUT: %import_ref.050: type = import_ref Main//export_export, C, loaded [template = constants.%C]
  405. // CHECK:STDOUT: %import_ref.06f: <namespace> = import_ref Main//export_export, NS, loaded
  406. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.06f, [template] {
  407. // CHECK:STDOUT: .NSC = %import_ref.17e
  408. // CHECK:STDOUT: }
  409. // CHECK:STDOUT: %import_ref.328: <witness> = import_ref Main//export_export, inst23 [indirect], loaded [template = constants.%complete_type.9be]
  410. // CHECK:STDOUT: %import_ref.db8 = import_ref Main//export_export, inst24 [indirect], unloaded
  411. // CHECK:STDOUT: %import_ref.3ef = import_ref Main//export_export, inst25 [indirect], unloaded
  412. // CHECK:STDOUT: %import_ref.c12: <witness> = import_ref Main//export_export, inst31 [indirect], loaded [template = constants.%complete_type.9f4]
  413. // CHECK:STDOUT: %import_ref.1cb = import_ref Main//export_export, inst32 [indirect], unloaded
  414. // CHECK:STDOUT: %import_ref.b18 = import_ref Main//export_export, inst33 [indirect], unloaded
  415. // CHECK:STDOUT: }
  416. // CHECK:STDOUT:
  417. // CHECK:STDOUT: file {
  418. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  419. // CHECK:STDOUT: .C = imports.%import_ref.050
  420. // CHECK:STDOUT: .NS = imports.%NS
  421. // CHECK:STDOUT: .c = %c
  422. // CHECK:STDOUT: .nsc = %nsc
  423. // CHECK:STDOUT: }
  424. // CHECK:STDOUT: %default.import.loc2_6.1 = import <invalid>
  425. // CHECK:STDOUT: %default.import.loc2_6.2 = import <invalid>
  426. // CHECK:STDOUT: %c.var: ref %C = var c
  427. // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var
  428. // CHECK:STDOUT: %nsc.var: ref %NSC = var nsc
  429. // CHECK:STDOUT: %nsc: ref %NSC = bind_name nsc, %nsc.var
  430. // CHECK:STDOUT: }
  431. // CHECK:STDOUT:
  432. // CHECK:STDOUT: class @C [from "export_export.carbon"] {
  433. // CHECK:STDOUT: !members:
  434. // CHECK:STDOUT: .Self = imports.%import_ref.db8
  435. // CHECK:STDOUT: .x = imports.%import_ref.3ef
  436. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.328
  437. // CHECK:STDOUT: }
  438. // CHECK:STDOUT:
  439. // CHECK:STDOUT: class @NSC [from "export_export.carbon"] {
  440. // CHECK:STDOUT: !members:
  441. // CHECK:STDOUT: .Self = imports.%import_ref.1cb
  442. // CHECK:STDOUT: .y = imports.%import_ref.b18
  443. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.c12
  444. // CHECK:STDOUT: }
  445. // CHECK:STDOUT:
  446. // CHECK:STDOUT: fn @__global_init() {
  447. // CHECK:STDOUT: !entry:
  448. // CHECK:STDOUT: %.loc4_19.1: %empty_tuple.type = tuple_literal ()
  449. // CHECK:STDOUT: %.loc4_20.1: %struct_type.x = struct_literal (%.loc4_19.1)
  450. // CHECK:STDOUT: %.loc4_20.2: ref %empty_tuple.type = class_element_access file.%c.var, element0
  451. // CHECK:STDOUT: %.loc4_19.2: init %empty_tuple.type = tuple_init () to %.loc4_20.2 [template = constants.%empty_tuple]
  452. // CHECK:STDOUT: %.loc4_20.3: init %empty_tuple.type = converted %.loc4_19.1, %.loc4_19.2 [template = constants.%empty_tuple]
  453. // CHECK:STDOUT: %.loc4_20.4: init %C = class_init (%.loc4_20.3), file.%c.var [template = constants.%C.val]
  454. // CHECK:STDOUT: %.loc4_21: init %C = converted %.loc4_20.1, %.loc4_20.4 [template = constants.%C.val]
  455. // CHECK:STDOUT: assign file.%c.var, %.loc4_21
  456. // CHECK:STDOUT: %.loc5_26.1: %empty_tuple.type = tuple_literal ()
  457. // CHECK:STDOUT: %.loc5_27.1: %struct_type.y = struct_literal (%.loc5_26.1)
  458. // CHECK:STDOUT: %.loc5_27.2: ref %empty_tuple.type = class_element_access file.%nsc.var, element0
  459. // CHECK:STDOUT: %.loc5_26.2: init %empty_tuple.type = tuple_init () to %.loc5_27.2 [template = constants.%empty_tuple]
  460. // CHECK:STDOUT: %.loc5_27.3: init %empty_tuple.type = converted %.loc5_26.1, %.loc5_26.2 [template = constants.%empty_tuple]
  461. // CHECK:STDOUT: %.loc5_27.4: init %NSC = class_init (%.loc5_27.3), file.%nsc.var [template = constants.%NSC.val]
  462. // CHECK:STDOUT: %.loc5_28: init %NSC = converted %.loc5_27.1, %.loc5_27.4 [template = constants.%NSC.val]
  463. // CHECK:STDOUT: assign file.%nsc.var, %.loc5_28
  464. // CHECK:STDOUT: return
  465. // CHECK:STDOUT: }
  466. // CHECK:STDOUT:
  467. // CHECK:STDOUT: --- use_export_export.carbon
  468. // CHECK:STDOUT:
  469. // CHECK:STDOUT: constants {
  470. // CHECK:STDOUT: %C: type = class_type @C [template]
  471. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  472. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [template]
  473. // CHECK:STDOUT: %complete_type.9be: <witness> = complete_type_witness %struct_type.x [template]
  474. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
  475. // CHECK:STDOUT: %C.val: %C = struct_value (%empty_tuple) [template]
  476. // CHECK:STDOUT: %NSC: type = class_type @NSC [template]
  477. // CHECK:STDOUT: %struct_type.y: type = struct_type {.y: %empty_tuple.type} [template]
  478. // CHECK:STDOUT: %complete_type.9f4: <witness> = complete_type_witness %struct_type.y [template]
  479. // CHECK:STDOUT: %NSC.val: %NSC = struct_value (%empty_tuple) [template]
  480. // CHECK:STDOUT: }
  481. // CHECK:STDOUT:
  482. // CHECK:STDOUT: imports {
  483. // CHECK:STDOUT: %import_ref.050: type = import_ref Main//export_export, C, loaded [template = constants.%C]
  484. // CHECK:STDOUT: %import_ref.06f: <namespace> = import_ref Main//export_export, NS, loaded
  485. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.06f, [template] {
  486. // CHECK:STDOUT: .NSC = %import_ref.17e
  487. // CHECK:STDOUT: }
  488. // CHECK:STDOUT: %import_ref.328: <witness> = import_ref Main//export_export, inst23 [indirect], loaded [template = constants.%complete_type.9be]
  489. // CHECK:STDOUT: %import_ref.db8 = import_ref Main//export_export, inst24 [indirect], unloaded
  490. // CHECK:STDOUT: %import_ref.3ef = import_ref Main//export_export, inst25 [indirect], unloaded
  491. // CHECK:STDOUT: %import_ref.c12: <witness> = import_ref Main//export_export, inst31 [indirect], loaded [template = constants.%complete_type.9f4]
  492. // CHECK:STDOUT: %import_ref.1cb = import_ref Main//export_export, inst32 [indirect], unloaded
  493. // CHECK:STDOUT: %import_ref.b18 = import_ref Main//export_export, inst33 [indirect], unloaded
  494. // CHECK:STDOUT: }
  495. // CHECK:STDOUT:
  496. // CHECK:STDOUT: file {
  497. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  498. // CHECK:STDOUT: .C = imports.%import_ref.050
  499. // CHECK:STDOUT: .NS = imports.%NS
  500. // CHECK:STDOUT: .c = %c
  501. // CHECK:STDOUT: .nsc = %nsc
  502. // CHECK:STDOUT: }
  503. // CHECK:STDOUT: %default.import = import <invalid>
  504. // CHECK:STDOUT: %c.var: ref %C = var c
  505. // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var
  506. // CHECK:STDOUT: %nsc.var: ref %NSC = var nsc
  507. // CHECK:STDOUT: %nsc: ref %NSC = bind_name nsc, %nsc.var
  508. // CHECK:STDOUT: }
  509. // CHECK:STDOUT:
  510. // CHECK:STDOUT: class @C [from "export_export.carbon"] {
  511. // CHECK:STDOUT: !members:
  512. // CHECK:STDOUT: .Self = imports.%import_ref.db8
  513. // CHECK:STDOUT: .x = imports.%import_ref.3ef
  514. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.328
  515. // CHECK:STDOUT: }
  516. // CHECK:STDOUT:
  517. // CHECK:STDOUT: class @NSC [from "export_export.carbon"] {
  518. // CHECK:STDOUT: !members:
  519. // CHECK:STDOUT: .Self = imports.%import_ref.1cb
  520. // CHECK:STDOUT: .y = imports.%import_ref.b18
  521. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.c12
  522. // CHECK:STDOUT: }
  523. // CHECK:STDOUT:
  524. // CHECK:STDOUT: fn @__global_init() {
  525. // CHECK:STDOUT: !entry:
  526. // CHECK:STDOUT: %.loc6_19.1: %empty_tuple.type = tuple_literal ()
  527. // CHECK:STDOUT: %.loc6_20.1: %struct_type.x = struct_literal (%.loc6_19.1)
  528. // CHECK:STDOUT: %.loc6_20.2: ref %empty_tuple.type = class_element_access file.%c.var, element0
  529. // CHECK:STDOUT: %.loc6_19.2: init %empty_tuple.type = tuple_init () to %.loc6_20.2 [template = constants.%empty_tuple]
  530. // CHECK:STDOUT: %.loc6_20.3: init %empty_tuple.type = converted %.loc6_19.1, %.loc6_19.2 [template = constants.%empty_tuple]
  531. // CHECK:STDOUT: %.loc6_20.4: init %C = class_init (%.loc6_20.3), file.%c.var [template = constants.%C.val]
  532. // CHECK:STDOUT: %.loc6_21: init %C = converted %.loc6_20.1, %.loc6_20.4 [template = constants.%C.val]
  533. // CHECK:STDOUT: assign file.%c.var, %.loc6_21
  534. // CHECK:STDOUT: %.loc7_26.1: %empty_tuple.type = tuple_literal ()
  535. // CHECK:STDOUT: %.loc7_27.1: %struct_type.y = struct_literal (%.loc7_26.1)
  536. // CHECK:STDOUT: %.loc7_27.2: ref %empty_tuple.type = class_element_access file.%nsc.var, element0
  537. // CHECK:STDOUT: %.loc7_26.2: init %empty_tuple.type = tuple_init () to %.loc7_27.2 [template = constants.%empty_tuple]
  538. // CHECK:STDOUT: %.loc7_27.3: init %empty_tuple.type = converted %.loc7_26.1, %.loc7_26.2 [template = constants.%empty_tuple]
  539. // CHECK:STDOUT: %.loc7_27.4: init %NSC = class_init (%.loc7_27.3), file.%nsc.var [template = constants.%NSC.val]
  540. // CHECK:STDOUT: %.loc7_28: init %NSC = converted %.loc7_27.1, %.loc7_27.4 [template = constants.%NSC.val]
  541. // CHECK:STDOUT: assign file.%nsc.var, %.loc7_28
  542. // CHECK:STDOUT: return
  543. // CHECK:STDOUT: }
  544. // CHECK:STDOUT:
  545. // CHECK:STDOUT: --- fail_export_ns.carbon
  546. // CHECK:STDOUT:
  547. // CHECK:STDOUT: imports {
  548. // CHECK:STDOUT: %import_ref.85d = import_ref Main//base, C, unloaded
  549. // CHECK:STDOUT: %import_ref.d58: <namespace> = import_ref Main//base, NS, loaded
  550. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.d58, [template] {
  551. // CHECK:STDOUT: .NSC = %import_ref.d31
  552. // CHECK:STDOUT: }
  553. // CHECK:STDOUT: }
  554. // CHECK:STDOUT:
  555. // CHECK:STDOUT: file {
  556. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  557. // CHECK:STDOUT: .C = imports.%import_ref.85d
  558. // CHECK:STDOUT: .NS = imports.%NS
  559. // CHECK:STDOUT: }
  560. // CHECK:STDOUT: %default.import = import <invalid>
  561. // CHECK:STDOUT: }
  562. // CHECK:STDOUT:
  563. // CHECK:STDOUT: --- fail_export_decl.carbon
  564. // CHECK:STDOUT:
  565. // CHECK:STDOUT: constants {
  566. // CHECK:STDOUT: %Local: type = class_type @Local [template]
  567. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  568. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  569. // CHECK:STDOUT: }
  570. // CHECK:STDOUT:
  571. // CHECK:STDOUT: file {
  572. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  573. // CHECK:STDOUT: .Local = %Local.decl
  574. // CHECK:STDOUT: }
  575. // CHECK:STDOUT: %Local.decl: type = class_decl @Local [template = constants.%Local] {} {}
  576. // CHECK:STDOUT: }
  577. // CHECK:STDOUT:
  578. // CHECK:STDOUT: class @Local {
  579. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  580. // CHECK:STDOUT:
  581. // CHECK:STDOUT: !members:
  582. // CHECK:STDOUT: .Self = constants.%Local
  583. // CHECK:STDOUT: complete_type_witness = %complete_type
  584. // CHECK:STDOUT: }
  585. // CHECK:STDOUT:
  586. // CHECK:STDOUT: --- fail_export_member.carbon
  587. // CHECK:STDOUT:
  588. // CHECK:STDOUT: constants {
  589. // CHECK:STDOUT: %C: type = class_type @C [template]
  590. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  591. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [template]
  592. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x [template]
  593. // CHECK:STDOUT: }
  594. // CHECK:STDOUT:
  595. // CHECK:STDOUT: imports {
  596. // CHECK:STDOUT: %import_ref.0ac: type = import_ref Main//base, C, loaded [template = constants.%C]
  597. // CHECK:STDOUT: %import_ref.d58: <namespace> = import_ref Main//base, NS, loaded
  598. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.d58, [template] {
  599. // CHECK:STDOUT: .NSC = %import_ref.d31
  600. // CHECK:STDOUT: }
  601. // CHECK:STDOUT: %import_ref.56d: <witness> = import_ref Main//base, loc6_1, loaded [template = constants.%complete_type]
  602. // CHECK:STDOUT: %import_ref.2c4 = import_ref Main//base, inst14 [no loc], unloaded
  603. // CHECK:STDOUT: %import_ref.276 = import_ref Main//base, loc5_8, unloaded
  604. // CHECK:STDOUT: }
  605. // CHECK:STDOUT:
  606. // CHECK:STDOUT: file {
  607. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  608. // CHECK:STDOUT: .C = imports.%import_ref.0ac
  609. // CHECK:STDOUT: .NS = imports.%NS
  610. // CHECK:STDOUT: }
  611. // CHECK:STDOUT: %default.import = import <invalid>
  612. // CHECK:STDOUT: }
  613. // CHECK:STDOUT:
  614. // CHECK:STDOUT: class @C [from "base.carbon"] {
  615. // CHECK:STDOUT: !members:
  616. // CHECK:STDOUT: .Self = imports.%import_ref.2c4
  617. // CHECK:STDOUT: .x = imports.%import_ref.276
  618. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.56d
  619. // CHECK:STDOUT: }
  620. // CHECK:STDOUT:
  621. // CHECK:STDOUT: --- import_both.carbon
  622. // CHECK:STDOUT:
  623. // CHECK:STDOUT: constants {
  624. // CHECK:STDOUT: %C: type = class_type @C [template]
  625. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  626. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [template]
  627. // CHECK:STDOUT: %complete_type.9be: <witness> = complete_type_witness %struct_type.x [template]
  628. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
  629. // CHECK:STDOUT: %C.val: %C = struct_value (%empty_tuple) [template]
  630. // CHECK:STDOUT: %NSC: type = class_type @NSC [template]
  631. // CHECK:STDOUT: %struct_type.y: type = struct_type {.y: %empty_tuple.type} [template]
  632. // CHECK:STDOUT: %complete_type.9f4: <witness> = complete_type_witness %struct_type.y [template]
  633. // CHECK:STDOUT: %NSC.val: %NSC = struct_value (%empty_tuple) [template]
  634. // CHECK:STDOUT: }
  635. // CHECK:STDOUT:
  636. // CHECK:STDOUT: imports {
  637. // CHECK:STDOUT: %import_ref.0ac: type = import_ref Main//base, C, loaded [template = constants.%C]
  638. // CHECK:STDOUT: %import_ref.d58: <namespace> = import_ref Main//base, NS, loaded
  639. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.d58, [template] {
  640. // CHECK:STDOUT: .NSC = %import_ref.88a
  641. // CHECK:STDOUT: }
  642. // CHECK:STDOUT: %import_ref.56d: <witness> = import_ref Main//base, loc6_1, loaded [template = constants.%complete_type.9be]
  643. // CHECK:STDOUT: %import_ref.2c4 = import_ref Main//base, inst14 [no loc], unloaded
  644. // CHECK:STDOUT: %import_ref.276 = import_ref Main//base, loc5_8, unloaded
  645. // CHECK:STDOUT: %import_ref.5ab: <witness> = import_ref Main//base, loc11_1, loaded [template = constants.%complete_type.9f4]
  646. // CHECK:STDOUT: %import_ref.31c = import_ref Main//base, inst25 [no loc], unloaded
  647. // CHECK:STDOUT: %import_ref.be6 = import_ref Main//base, loc10_8, unloaded
  648. // CHECK:STDOUT: }
  649. // CHECK:STDOUT:
  650. // CHECK:STDOUT: file {
  651. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  652. // CHECK:STDOUT: .C = imports.%import_ref.0ac
  653. // CHECK:STDOUT: .NS = imports.%NS
  654. // CHECK:STDOUT: .c = %c
  655. // CHECK:STDOUT: .nsc = %nsc
  656. // CHECK:STDOUT: }
  657. // CHECK:STDOUT: %default.import = import <invalid>
  658. // CHECK:STDOUT: %c.var: ref %C = var c
  659. // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var
  660. // CHECK:STDOUT: %nsc.var: ref %NSC = var nsc
  661. // CHECK:STDOUT: %nsc: ref %NSC = bind_name nsc, %nsc.var
  662. // CHECK:STDOUT: }
  663. // CHECK:STDOUT:
  664. // CHECK:STDOUT: class @C [from "base.carbon"] {
  665. // CHECK:STDOUT: !members:
  666. // CHECK:STDOUT: .Self = imports.%import_ref.2c4
  667. // CHECK:STDOUT: .x = imports.%import_ref.276
  668. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.56d
  669. // CHECK:STDOUT: }
  670. // CHECK:STDOUT:
  671. // CHECK:STDOUT: class @NSC [from "base.carbon"] {
  672. // CHECK:STDOUT: !members:
  673. // CHECK:STDOUT: .Self = imports.%import_ref.31c
  674. // CHECK:STDOUT: .y = imports.%import_ref.be6
  675. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.5ab
  676. // CHECK:STDOUT: }
  677. // CHECK:STDOUT:
  678. // CHECK:STDOUT: fn @__global_init() {
  679. // CHECK:STDOUT: !entry:
  680. // CHECK:STDOUT: %.loc7_19.1: %empty_tuple.type = tuple_literal ()
  681. // CHECK:STDOUT: %.loc7_20.1: %struct_type.x = struct_literal (%.loc7_19.1)
  682. // CHECK:STDOUT: %.loc7_20.2: ref %empty_tuple.type = class_element_access file.%c.var, element0
  683. // CHECK:STDOUT: %.loc7_19.2: init %empty_tuple.type = tuple_init () to %.loc7_20.2 [template = constants.%empty_tuple]
  684. // CHECK:STDOUT: %.loc7_20.3: init %empty_tuple.type = converted %.loc7_19.1, %.loc7_19.2 [template = constants.%empty_tuple]
  685. // CHECK:STDOUT: %.loc7_20.4: init %C = class_init (%.loc7_20.3), file.%c.var [template = constants.%C.val]
  686. // CHECK:STDOUT: %.loc7_21: init %C = converted %.loc7_20.1, %.loc7_20.4 [template = constants.%C.val]
  687. // CHECK:STDOUT: assign file.%c.var, %.loc7_21
  688. // CHECK:STDOUT: %.loc8_26.1: %empty_tuple.type = tuple_literal ()
  689. // CHECK:STDOUT: %.loc8_27.1: %struct_type.y = struct_literal (%.loc8_26.1)
  690. // CHECK:STDOUT: %.loc8_27.2: ref %empty_tuple.type = class_element_access file.%nsc.var, element0
  691. // CHECK:STDOUT: %.loc8_26.2: init %empty_tuple.type = tuple_init () to %.loc8_27.2 [template = constants.%empty_tuple]
  692. // CHECK:STDOUT: %.loc8_27.3: init %empty_tuple.type = converted %.loc8_26.1, %.loc8_26.2 [template = constants.%empty_tuple]
  693. // CHECK:STDOUT: %.loc8_27.4: init %NSC = class_init (%.loc8_27.3), file.%nsc.var [template = constants.%NSC.val]
  694. // CHECK:STDOUT: %.loc8_28: init %NSC = converted %.loc8_27.1, %.loc8_27.4 [template = constants.%NSC.val]
  695. // CHECK:STDOUT: assign file.%nsc.var, %.loc8_28
  696. // CHECK:STDOUT: return
  697. // CHECK:STDOUT: }
  698. // CHECK:STDOUT:
  699. // CHECK:STDOUT: --- import_both_reversed.carbon
  700. // CHECK:STDOUT:
  701. // CHECK:STDOUT: constants {
  702. // CHECK:STDOUT: %C: type = class_type @C [template]
  703. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  704. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [template]
  705. // CHECK:STDOUT: %complete_type.9be: <witness> = complete_type_witness %struct_type.x [template]
  706. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
  707. // CHECK:STDOUT: %C.val: %C = struct_value (%empty_tuple) [template]
  708. // CHECK:STDOUT: %NSC: type = class_type @NSC [template]
  709. // CHECK:STDOUT: %struct_type.y: type = struct_type {.y: %empty_tuple.type} [template]
  710. // CHECK:STDOUT: %complete_type.9f4: <witness> = complete_type_witness %struct_type.y [template]
  711. // CHECK:STDOUT: %NSC.val: %NSC = struct_value (%empty_tuple) [template]
  712. // CHECK:STDOUT: }
  713. // CHECK:STDOUT:
  714. // CHECK:STDOUT: imports {
  715. // CHECK:STDOUT: %import_ref.4a7: type = import_ref Main//export, C, loaded [template = constants.%C]
  716. // CHECK:STDOUT: %import_ref.0f6: <namespace> = import_ref Main//export, NS, loaded
  717. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.0f6, [template] {
  718. // CHECK:STDOUT: .NSC = %import_ref.833
  719. // CHECK:STDOUT: }
  720. // CHECK:STDOUT: %import_ref.ad3: <witness> = import_ref Main//export, inst23 [indirect], loaded [template = constants.%complete_type.9be]
  721. // CHECK:STDOUT: %import_ref.6a9 = import_ref Main//export, inst24 [indirect], unloaded
  722. // CHECK:STDOUT: %import_ref.f67 = import_ref Main//export, inst25 [indirect], unloaded
  723. // CHECK:STDOUT: %import_ref.63c: <witness> = import_ref Main//export, inst31 [indirect], loaded [template = constants.%complete_type.9f4]
  724. // CHECK:STDOUT: %import_ref.f0b = import_ref Main//export, inst32 [indirect], unloaded
  725. // CHECK:STDOUT: %import_ref.ebc = import_ref Main//export, inst33 [indirect], unloaded
  726. // CHECK:STDOUT: }
  727. // CHECK:STDOUT:
  728. // CHECK:STDOUT: file {
  729. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  730. // CHECK:STDOUT: .C = imports.%import_ref.4a7
  731. // CHECK:STDOUT: .NS = imports.%NS
  732. // CHECK:STDOUT: .c = %c
  733. // CHECK:STDOUT: .nsc = %nsc
  734. // CHECK:STDOUT: }
  735. // CHECK:STDOUT: %default.import = import <invalid>
  736. // CHECK:STDOUT: %c.var: ref %C = var c
  737. // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var
  738. // CHECK:STDOUT: %nsc.var: ref %NSC = var nsc
  739. // CHECK:STDOUT: %nsc: ref %NSC = bind_name nsc, %nsc.var
  740. // CHECK:STDOUT: }
  741. // CHECK:STDOUT:
  742. // CHECK:STDOUT: class @C [from "export.carbon"] {
  743. // CHECK:STDOUT: !members:
  744. // CHECK:STDOUT: .Self = imports.%import_ref.6a9
  745. // CHECK:STDOUT: .x = imports.%import_ref.f67
  746. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.ad3
  747. // CHECK:STDOUT: }
  748. // CHECK:STDOUT:
  749. // CHECK:STDOUT: class @NSC [from "export.carbon"] {
  750. // CHECK:STDOUT: !members:
  751. // CHECK:STDOUT: .Self = imports.%import_ref.f0b
  752. // CHECK:STDOUT: .y = imports.%import_ref.ebc
  753. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.63c
  754. // CHECK:STDOUT: }
  755. // CHECK:STDOUT:
  756. // CHECK:STDOUT: fn @__global_init() {
  757. // CHECK:STDOUT: !entry:
  758. // CHECK:STDOUT: %.loc7_19.1: %empty_tuple.type = tuple_literal ()
  759. // CHECK:STDOUT: %.loc7_20.1: %struct_type.x = struct_literal (%.loc7_19.1)
  760. // CHECK:STDOUT: %.loc7_20.2: ref %empty_tuple.type = class_element_access file.%c.var, element0
  761. // CHECK:STDOUT: %.loc7_19.2: init %empty_tuple.type = tuple_init () to %.loc7_20.2 [template = constants.%empty_tuple]
  762. // CHECK:STDOUT: %.loc7_20.3: init %empty_tuple.type = converted %.loc7_19.1, %.loc7_19.2 [template = constants.%empty_tuple]
  763. // CHECK:STDOUT: %.loc7_20.4: init %C = class_init (%.loc7_20.3), file.%c.var [template = constants.%C.val]
  764. // CHECK:STDOUT: %.loc7_21: init %C = converted %.loc7_20.1, %.loc7_20.4 [template = constants.%C.val]
  765. // CHECK:STDOUT: assign file.%c.var, %.loc7_21
  766. // CHECK:STDOUT: %.loc8_26.1: %empty_tuple.type = tuple_literal ()
  767. // CHECK:STDOUT: %.loc8_27.1: %struct_type.y = struct_literal (%.loc8_26.1)
  768. // CHECK:STDOUT: %.loc8_27.2: ref %empty_tuple.type = class_element_access file.%nsc.var, element0
  769. // CHECK:STDOUT: %.loc8_26.2: init %empty_tuple.type = tuple_init () to %.loc8_27.2 [template = constants.%empty_tuple]
  770. // CHECK:STDOUT: %.loc8_27.3: init %empty_tuple.type = converted %.loc8_26.1, %.loc8_26.2 [template = constants.%empty_tuple]
  771. // CHECK:STDOUT: %.loc8_27.4: init %NSC = class_init (%.loc8_27.3), file.%nsc.var [template = constants.%NSC.val]
  772. // CHECK:STDOUT: %.loc8_28: init %NSC = converted %.loc8_27.1, %.loc8_27.4 [template = constants.%NSC.val]
  773. // CHECK:STDOUT: assign file.%nsc.var, %.loc8_28
  774. // CHECK:STDOUT: return
  775. // CHECK:STDOUT: }
  776. // CHECK:STDOUT:
  777. // CHECK:STDOUT: --- fail_use_not_reexporting.carbon
  778. // CHECK:STDOUT:
  779. // CHECK:STDOUT: file {
  780. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  781. // CHECK:STDOUT: .Local = %Local
  782. // CHECK:STDOUT: .NSLocal = %NSLocal
  783. // CHECK:STDOUT: }
  784. // CHECK:STDOUT: %default.import = import <invalid>
  785. // CHECK:STDOUT: %C.ref: <error> = name_ref C, <error> [template = <error>]
  786. // CHECK:STDOUT: %Local: <error> = bind_alias Local, <error> [template = <error>]
  787. // CHECK:STDOUT: %NS.ref: <error> = name_ref NS, <error> [template = <error>]
  788. // CHECK:STDOUT: %NSC.ref: <error> = name_ref NSC, <error> [template = <error>]
  789. // CHECK:STDOUT: %NSLocal: <error> = bind_alias NSLocal, <error> [template = <error>]
  790. // CHECK:STDOUT: }
  791. // CHECK:STDOUT:
  792. // CHECK:STDOUT: --- repeat_export.carbon
  793. // CHECK:STDOUT:
  794. // CHECK:STDOUT: constants {
  795. // CHECK:STDOUT: %C: type = class_type @C [template]
  796. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  797. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [template]
  798. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x [template]
  799. // CHECK:STDOUT: }
  800. // CHECK:STDOUT:
  801. // CHECK:STDOUT: imports {
  802. // CHECK:STDOUT: %import_ref.0ac: type = import_ref Main//base, C, loaded [template = constants.%C]
  803. // CHECK:STDOUT: %import_ref.d58: <namespace> = import_ref Main//base, NS, loaded
  804. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.d58, [template] {
  805. // CHECK:STDOUT: .NSC = %import_ref.d31
  806. // CHECK:STDOUT: }
  807. // CHECK:STDOUT: %import_ref.56d: <witness> = import_ref Main//base, loc6_1, loaded [template = constants.%complete_type]
  808. // CHECK:STDOUT: %import_ref.2c4 = import_ref Main//base, inst14 [no loc], unloaded
  809. // CHECK:STDOUT: %import_ref.276 = import_ref Main//base, loc5_8, unloaded
  810. // CHECK:STDOUT: }
  811. // CHECK:STDOUT:
  812. // CHECK:STDOUT: file {
  813. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  814. // CHECK:STDOUT: .C = %C
  815. // CHECK:STDOUT: .NS = imports.%NS
  816. // CHECK:STDOUT: }
  817. // CHECK:STDOUT: %default.import = import <invalid>
  818. // CHECK:STDOUT: %C: type = export C, imports.%import_ref.0ac [template = constants.%C]
  819. // CHECK:STDOUT: }
  820. // CHECK:STDOUT:
  821. // CHECK:STDOUT: class @C [from "base.carbon"] {
  822. // CHECK:STDOUT: !members:
  823. // CHECK:STDOUT: .Self = imports.%import_ref.2c4
  824. // CHECK:STDOUT: .x = imports.%import_ref.276
  825. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.56d
  826. // CHECK:STDOUT: }
  827. // CHECK:STDOUT:
  828. // CHECK:STDOUT: --- use_repeat_export.carbon
  829. // CHECK:STDOUT:
  830. // CHECK:STDOUT: constants {
  831. // CHECK:STDOUT: %C: type = class_type @C [template]
  832. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  833. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [template]
  834. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x [template]
  835. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
  836. // CHECK:STDOUT: %C.val: %C = struct_value (%empty_tuple) [template]
  837. // CHECK:STDOUT: }
  838. // CHECK:STDOUT:
  839. // CHECK:STDOUT: imports {
  840. // CHECK:STDOUT: %import_ref.4a7: type = import_ref Main//repeat_export, C, loaded [template = constants.%C]
  841. // CHECK:STDOUT: %import_ref.ad3: <witness> = import_ref Main//repeat_export, inst23 [indirect], loaded [template = constants.%complete_type]
  842. // CHECK:STDOUT: %import_ref.6a9 = import_ref Main//repeat_export, inst24 [indirect], unloaded
  843. // CHECK:STDOUT: %import_ref.f67 = import_ref Main//repeat_export, inst25 [indirect], unloaded
  844. // CHECK:STDOUT: }
  845. // CHECK:STDOUT:
  846. // CHECK:STDOUT: file {
  847. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  848. // CHECK:STDOUT: .C = imports.%import_ref.4a7
  849. // CHECK:STDOUT: .c = %c
  850. // CHECK:STDOUT: }
  851. // CHECK:STDOUT: %default.import = import <invalid>
  852. // CHECK:STDOUT: %c.var: ref %C = var c
  853. // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var
  854. // CHECK:STDOUT: }
  855. // CHECK:STDOUT:
  856. // CHECK:STDOUT: class @C [from "repeat_export.carbon"] {
  857. // CHECK:STDOUT: !members:
  858. // CHECK:STDOUT: .Self = imports.%import_ref.6a9
  859. // CHECK:STDOUT: .x = imports.%import_ref.f67
  860. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.ad3
  861. // CHECK:STDOUT: }
  862. // CHECK:STDOUT:
  863. // CHECK:STDOUT: fn @__global_init() {
  864. // CHECK:STDOUT: !entry:
  865. // CHECK:STDOUT: %.loc6_19.1: %empty_tuple.type = tuple_literal ()
  866. // CHECK:STDOUT: %.loc6_20.1: %struct_type.x = struct_literal (%.loc6_19.1)
  867. // CHECK:STDOUT: %.loc6_20.2: ref %empty_tuple.type = class_element_access file.%c.var, element0
  868. // CHECK:STDOUT: %.loc6_19.2: init %empty_tuple.type = tuple_init () to %.loc6_20.2 [template = constants.%empty_tuple]
  869. // CHECK:STDOUT: %.loc6_20.3: init %empty_tuple.type = converted %.loc6_19.1, %.loc6_19.2 [template = constants.%empty_tuple]
  870. // CHECK:STDOUT: %.loc6_20.4: init %C = class_init (%.loc6_20.3), file.%c.var [template = constants.%C.val]
  871. // CHECK:STDOUT: %.loc6_21: init %C = converted %.loc6_20.1, %.loc6_20.4 [template = constants.%C.val]
  872. // CHECK:STDOUT: assign file.%c.var, %.loc6_21
  873. // CHECK:STDOUT: return
  874. // CHECK:STDOUT: }
  875. // CHECK:STDOUT:
  876. // CHECK:STDOUT: --- fail_modifiers.carbon
  877. // CHECK:STDOUT:
  878. // CHECK:STDOUT: constants {
  879. // CHECK:STDOUT: %C: type = class_type @C [template]
  880. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  881. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %empty_tuple.type} [template]
  882. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %struct_type.x [template]
  883. // CHECK:STDOUT: }
  884. // CHECK:STDOUT:
  885. // CHECK:STDOUT: imports {
  886. // CHECK:STDOUT: %import_ref.0ac: type = import_ref Main//base, C, loaded [template = constants.%C]
  887. // CHECK:STDOUT: %import_ref.d58: <namespace> = import_ref Main//base, NS, loaded
  888. // CHECK:STDOUT: %NS: <namespace> = namespace %import_ref.d58, [template] {
  889. // CHECK:STDOUT: .NSC = %import_ref.d31
  890. // CHECK:STDOUT: }
  891. // CHECK:STDOUT: %import_ref.56d: <witness> = import_ref Main//base, loc6_1, loaded [template = constants.%complete_type]
  892. // CHECK:STDOUT: %import_ref.2c4 = import_ref Main//base, inst14 [no loc], unloaded
  893. // CHECK:STDOUT: %import_ref.276 = import_ref Main//base, loc5_8, unloaded
  894. // CHECK:STDOUT: }
  895. // CHECK:STDOUT:
  896. // CHECK:STDOUT: file {
  897. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  898. // CHECK:STDOUT: .C = %C
  899. // CHECK:STDOUT: .NS = imports.%NS
  900. // CHECK:STDOUT: }
  901. // CHECK:STDOUT: %default.import = import <invalid>
  902. // CHECK:STDOUT: %C: type = export C, imports.%import_ref.0ac [template = constants.%C]
  903. // CHECK:STDOUT: }
  904. // CHECK:STDOUT:
  905. // CHECK:STDOUT: class @C [from "base.carbon"] {
  906. // CHECK:STDOUT: !members:
  907. // CHECK:STDOUT: .Self = imports.%import_ref.2c4
  908. // CHECK:STDOUT: .x = imports.%import_ref.276
  909. // CHECK:STDOUT: complete_type_witness = imports.%import_ref.56d
  910. // CHECK:STDOUT: }
  911. // CHECK:STDOUT: