export_name.carbon 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 "base";
  15. class C {}
  16. // --- export.carbon
  17. library "export";
  18. import library "base";
  19. export C;
  20. // ============================================================================
  21. // Test files
  22. // ============================================================================
  23. // --- use_export.carbon
  24. library "use_export";
  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: %.1: type = struct_type {} [template]
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: file {
  35. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  36. // CHECK:STDOUT: .C = %C.decl
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: class @C {
  42. // CHECK:STDOUT: !members:
  43. // CHECK:STDOUT: .Self = constants.%C
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: --- export.carbon
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: constants {
  49. // CHECK:STDOUT: %C: type = class_type @C [template]
  50. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: file {
  54. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  55. // CHECK:STDOUT: .C = %C
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+1, loaded [template = constants.%C]
  58. // CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+2, unloaded
  59. // CHECK:STDOUT: %C: type = export C, %import_ref.1 [template = constants.%C]
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: class @C {
  63. // CHECK:STDOUT: !members:
  64. // CHECK:STDOUT: .Self = file.%import_ref.2
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: --- use_export.carbon
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: constants {
  70. // CHECK:STDOUT: %C: type = class_type @C [template]
  71. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  72. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  73. // CHECK:STDOUT: %.3: type = ptr_type %.1 [template]
  74. // CHECK:STDOUT: %struct: %C = struct_value () [template]
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT:
  77. // CHECK:STDOUT: file {
  78. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  79. // CHECK:STDOUT: .C = %import_ref.1
  80. // CHECK:STDOUT: .c = %c
  81. // CHECK:STDOUT: }
  82. // CHECK:STDOUT: %import_ref.1: type = import_ref ir1, inst+6, loaded [template = constants.%C]
  83. // CHECK:STDOUT: %import_ref.2 = import_ref ir1, inst+5, unloaded
  84. // CHECK:STDOUT: %C.ref: type = name_ref C, %import_ref.1 [template = constants.%C]
  85. // CHECK:STDOUT: %c.var: ref %C = var c
  86. // CHECK:STDOUT: %c: ref %C = bind_name c, %c.var
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: class @C {
  90. // CHECK:STDOUT: !members:
  91. // CHECK:STDOUT: .Self = file.%import_ref.2
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT:
  94. // CHECK:STDOUT: fn @__global_init() {
  95. // CHECK:STDOUT: !entry:
  96. // CHECK:STDOUT: %.loc6_13.1: %.1 = struct_literal ()
  97. // CHECK:STDOUT: %.loc6_13.2: init %C = class_init (), file.%c.var [template = constants.%struct]
  98. // CHECK:STDOUT: %.loc6_14: init %C = converted %.loc6_13.1, %.loc6_13.2 [template = constants.%struct]
  99. // CHECK:STDOUT: assign file.%c.var, %.loc6_14
  100. // CHECK:STDOUT: return
  101. // CHECK:STDOUT: }
  102. // CHECK:STDOUT: