export_name.carbon 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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/function/declaration/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/function/declaration/no_prelude/export_name.carbon
  10. // ============================================================================
  11. // Setup files
  12. // ============================================================================
  13. // --- base.carbon
  14. library "base";
  15. fn F();
  16. // --- export.carbon
  17. library "export";
  18. import library "base";
  19. export F;
  20. // ============================================================================
  21. // Test files
  22. // ============================================================================
  23. // --- use_export.carbon
  24. library "use_export";
  25. import library "export";
  26. var f: () = F();
  27. // CHECK:STDOUT: --- base.carbon
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: constants {
  30. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  31. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  32. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: file {
  36. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  37. // CHECK:STDOUT: .F = %F.decl
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {}
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: fn @F();
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: --- export.carbon
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: constants {
  47. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  48. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  49. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: file {
  53. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  54. // CHECK:STDOUT: .F = %F
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT: %import_ref: %F.type = import_ref ir1, inst+1, loaded [template = constants.%F]
  57. // CHECK:STDOUT: %F: %F.type = export F, %import_ref [template = constants.%F]
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: fn @F();
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: --- use_export.carbon
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: constants {
  65. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  66. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  67. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: file {
  71. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  72. // CHECK:STDOUT: .F = %import_ref
  73. // CHECK:STDOUT: .f = %f
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT: %import_ref: %F.type = import_ref ir1, inst+6, loaded [template = constants.%F]
  76. // CHECK:STDOUT: %.loc6_9.1: %.1 = tuple_literal ()
  77. // CHECK:STDOUT: %.loc6_9.2: type = converted %.loc6_9.1, constants.%.1 [template = constants.%.1]
  78. // CHECK:STDOUT: %f.var: ref %.1 = var f
  79. // CHECK:STDOUT: %f: ref %.1 = bind_name f, %f.var
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT:
  82. // CHECK:STDOUT: fn @F();
  83. // CHECK:STDOUT:
  84. // CHECK:STDOUT: fn @__global_init() {
  85. // CHECK:STDOUT: !entry:
  86. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%import_ref [template = constants.%F]
  87. // CHECK:STDOUT: %F.call: init %.1 = call %F.ref()
  88. // CHECK:STDOUT: assign file.%f.var, %F.call
  89. // CHECK:STDOUT: return
  90. // CHECK:STDOUT: }
  91. // CHECK:STDOUT: