export_name.carbon 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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/var/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/var/no_prelude/export_name.carbon
  10. // ============================================================================
  11. // Setup files
  12. // ============================================================================
  13. // --- base.carbon
  14. library "base";
  15. var v: ();
  16. // --- export.carbon
  17. library "export";
  18. import library "base";
  19. export v;
  20. // ============================================================================
  21. // Test files
  22. // ============================================================================
  23. // --- fail_todo_use_export.carbon
  24. library "use_export";
  25. // CHECK:STDERR: fail_todo_use_export.carbon:[[@LINE+9]]:1: In import.
  26. // CHECK:STDERR: import library "export";
  27. // CHECK:STDERR: ^~~~~~
  28. // CHECK:STDERR: export.carbon:4:1: In import.
  29. // CHECK:STDERR: import library "base";
  30. // CHECK:STDERR: ^~~~~~
  31. // CHECK:STDERR: base.carbon:4:5: ERROR: Semantics TODO: `Non-constant ImportRefLoaded (comes up with var)`.
  32. // CHECK:STDERR: var v: ();
  33. // CHECK:STDERR: ^
  34. import library "export";
  35. var w: () = v;
  36. // CHECK:STDOUT: --- base.carbon
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: constants {
  39. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: file {
  43. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  44. // CHECK:STDOUT: .v = %v
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: %.loc4_9.1: %.1 = tuple_literal ()
  47. // CHECK:STDOUT: %.loc4_9.2: type = converted %.loc4_9.1, constants.%.1 [template = constants.%.1]
  48. // CHECK:STDOUT: %v.var: ref %.1 = var v
  49. // CHECK:STDOUT: %v: ref %.1 = bind_name v, %v.var
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: --- export.carbon
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: constants {
  55. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: file {
  59. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  60. // CHECK:STDOUT: .v = %v
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT: %import_ref: ref %.1 = import_ref ir1, inst+5, loaded
  63. // CHECK:STDOUT: %v: ref %.1 = export v, %import_ref
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: --- fail_todo_use_export.carbon
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: constants {
  69. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  70. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template]
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT:
  73. // CHECK:STDOUT: file {
  74. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  75. // CHECK:STDOUT: .v = %import_ref
  76. // CHECK:STDOUT: .w = %w
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT: %import_ref: ref %.1 = import_ref ir1, inst+3, loaded [template = <error>]
  79. // CHECK:STDOUT: %.loc15_9.1: %.1 = tuple_literal ()
  80. // CHECK:STDOUT: %.loc15_9.2: type = converted %.loc15_9.1, constants.%.1 [template = constants.%.1]
  81. // CHECK:STDOUT: %w.var: ref %.1 = var w
  82. // CHECK:STDOUT: %w: ref %.1 = bind_name w, %w.var
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: fn @__global_init() {
  86. // CHECK:STDOUT: !entry:
  87. // CHECK:STDOUT: %v.ref: ref %.1 = name_ref v, file.%import_ref [template = <error>]
  88. // CHECK:STDOUT: %.loc15_13: init %.1 = tuple_init () to file.%w.var [template = constants.%tuple]
  89. // CHECK:STDOUT: %.loc15_14: init %.1 = converted %v.ref, %.loc15_13 [template = constants.%tuple]
  90. // CHECK:STDOUT: assign file.%w.var, %.loc15_14
  91. // CHECK:STDOUT: return
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT: