export_name.carbon 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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/class/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/class/no_prelude/export_name.carbon
  10. // ============================================================================
  11. // Setup files
  12. // ============================================================================
  13. // --- base.carbon
  14. library "[[@TEST_NAME]]";
  15. class C {}
  16. // --- export.carbon
  17. library "[[@TEST_NAME]]";
  18. import library "base";
  19. export C;
  20. // ============================================================================
  21. // Test files
  22. // ============================================================================
  23. // --- use_export.carbon
  24. library "[[@TEST_NAME]]";
  25. import library "export";
  26. var c: C = {};
  27. // CHECK:STDOUT: --- base.carbon
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: constants {
  30. // CHECK:STDOUT: %C: type = class_type @C [template]
  31. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  32. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: file {
  36. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  37. // CHECK:STDOUT: .C = %C.decl
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: class @C {
  43. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template = constants.%complete_type]
  44. // CHECK:STDOUT: complete_type_witness = %complete_type
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: !members:
  47. // CHECK:STDOUT: .Self = constants.%C
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: --- export.carbon
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: constants {
  53. // CHECK:STDOUT: %C: type = class_type @C [template]
  54. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  55. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: imports {
  59. // CHECK:STDOUT: %Main.C: type = import_ref Main//base, C, loaded [template = constants.%C]
  60. // CHECK:STDOUT: %Main.import_ref.8f2: <witness> = import_ref Main//base, loc4_10, loaded [template = constants.%complete_type]
  61. // CHECK:STDOUT: %Main.import_ref.2c4 = import_ref Main//base, inst14 [no loc], unloaded
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: file {
  65. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  66. // CHECK:STDOUT: .C = %C
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT: %default.import = import <none>
  69. // CHECK:STDOUT: %C: type = export C, imports.%Main.C [template = constants.%C]
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: class @C [from "base.carbon"] {
  73. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8f2
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: !members:
  76. // CHECK:STDOUT: .Self = imports.%Main.import_ref.2c4
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: --- use_export.carbon
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: constants {
  82. // CHECK:STDOUT: %C: type = class_type @C [template]
  83. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [template]
  84. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [template]
  85. // CHECK:STDOUT: %C.val: %C = struct_value () [template]
  86. // CHECK:STDOUT: }
  87. // CHECK:STDOUT:
  88. // CHECK:STDOUT: imports {
  89. // CHECK:STDOUT: %Main.C: type = import_ref Main//export, C, loaded [template = constants.%C]
  90. // CHECK:STDOUT: %Main.import_ref.8db: <witness> = import_ref Main//export, inst19 [indirect], loaded [template = constants.%complete_type]
  91. // CHECK:STDOUT: %Main.import_ref.6a9 = import_ref Main//export, inst20 [indirect], unloaded
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT:
  94. // CHECK:STDOUT: file {
  95. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  96. // CHECK:STDOUT: .C = imports.%Main.C
  97. // CHECK:STDOUT: .c = %c
  98. // CHECK:STDOUT: }
  99. // CHECK:STDOUT: %default.import = import <none>
  100. // CHECK:STDOUT: name_binding_decl {
  101. // CHECK:STDOUT: %c.patt: %C = binding_pattern c
  102. // CHECK:STDOUT: %.loc6: %C = var_pattern %c.patt
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT: %c.var: ref %C = var c
  105. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Main.C [template = constants.%C]
  106. // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var
  107. // CHECK:STDOUT: }
  108. // CHECK:STDOUT:
  109. // CHECK:STDOUT: class @C [from "export.carbon"] {
  110. // CHECK:STDOUT: complete_type_witness = imports.%Main.import_ref.8db
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: !members:
  113. // CHECK:STDOUT: .Self = imports.%Main.import_ref.6a9
  114. // CHECK:STDOUT: }
  115. // CHECK:STDOUT:
  116. // CHECK:STDOUT: fn @__global_init() {
  117. // CHECK:STDOUT: !entry:
  118. // CHECK:STDOUT: %.loc6_13.1: %empty_struct_type = struct_literal ()
  119. // CHECK:STDOUT: %.loc6_13.2: init %C = class_init (), file.%c.var [template = constants.%C.val]
  120. // CHECK:STDOUT: %.loc6_1: init %C = converted %.loc6_13.1, %.loc6_13.2 [template = constants.%C.val]
  121. // CHECK:STDOUT: assign file.%c.var, %.loc6_1
  122. // CHECK:STDOUT: return
  123. // CHECK:STDOUT: }
  124. // CHECK:STDOUT: