import.carbon 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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/let/no_prelude/import.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/let/no_prelude/import.carbon
  10. // --- implicit.carbon
  11. package Implicit;
  12. let a: () = ();
  13. // --- implicit.impl.carbon
  14. impl package Implicit;
  15. let b: () = a;
  16. // --- other.carbon
  17. package Other;
  18. let a: () = ();
  19. // --- import_other.carbon
  20. import Other;
  21. let b: () = Other.a;
  22. // CHECK:STDOUT: --- implicit.carbon
  23. // CHECK:STDOUT:
  24. // CHECK:STDOUT: constants {
  25. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  26. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template]
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: file {
  30. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  31. // CHECK:STDOUT: .a = @__global_init.%a
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: %.loc4_9.1: %.1 = tuple_literal ()
  34. // CHECK:STDOUT: %.loc4_9.2: type = converted %.loc4_9.1, constants.%.1 [template = constants.%.1]
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: fn @__global_init() {
  38. // CHECK:STDOUT: !entry:
  39. // CHECK:STDOUT: %.loc4_14: %.1 = tuple_literal ()
  40. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template = constants.%tuple]
  41. // CHECK:STDOUT: %.loc4_15: %.1 = converted %.loc4_14, %tuple [template = constants.%tuple]
  42. // CHECK:STDOUT: %a: %.1 = bind_name a, %.loc4_15
  43. // CHECK:STDOUT: return
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: --- implicit.impl.carbon
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: constants {
  49. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: imports {
  53. // CHECK:STDOUT: %import_ref: %.1 = import_ref Implicit//default, inst+4, loaded
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: file {
  57. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  58. // CHECK:STDOUT: .a = imports.%import_ref
  59. // CHECK:STDOUT: .b = @__global_init.%b
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: %Implicit.import = import Implicit
  62. // CHECK:STDOUT: %default.import = import <invalid>
  63. // CHECK:STDOUT: %.loc4_9.1: %.1 = tuple_literal ()
  64. // CHECK:STDOUT: %.loc4_9.2: type = converted %.loc4_9.1, constants.%.1 [template = constants.%.1]
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: fn @__global_init() {
  68. // CHECK:STDOUT: !entry:
  69. // CHECK:STDOUT: %a.ref: %.1 = name_ref a, imports.%import_ref
  70. // CHECK:STDOUT: %b: %.1 = bind_name b, %a.ref
  71. // CHECK:STDOUT: return
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: --- other.carbon
  75. // CHECK:STDOUT:
  76. // CHECK:STDOUT: constants {
  77. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  78. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template]
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: file {
  82. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  83. // CHECK:STDOUT: .a = @__global_init.%a
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT: %.loc4_9.1: %.1 = tuple_literal ()
  86. // CHECK:STDOUT: %.loc4_9.2: type = converted %.loc4_9.1, constants.%.1 [template = constants.%.1]
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: fn @__global_init() {
  90. // CHECK:STDOUT: !entry:
  91. // CHECK:STDOUT: %.loc4_14: %.1 = tuple_literal ()
  92. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template = constants.%tuple]
  93. // CHECK:STDOUT: %.loc4_15: %.1 = converted %.loc4_14, %tuple [template = constants.%tuple]
  94. // CHECK:STDOUT: %a: %.1 = bind_name a, %.loc4_15
  95. // CHECK:STDOUT: return
  96. // CHECK:STDOUT: }
  97. // CHECK:STDOUT:
  98. // CHECK:STDOUT: --- import_other.carbon
  99. // CHECK:STDOUT:
  100. // CHECK:STDOUT: constants {
  101. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  102. // CHECK:STDOUT: }
  103. // CHECK:STDOUT:
  104. // CHECK:STDOUT: imports {
  105. // CHECK:STDOUT: %Other: <namespace> = namespace file.%Other.import, [template] {
  106. // CHECK:STDOUT: .a = %import_ref
  107. // CHECK:STDOUT: import Other//default
  108. // CHECK:STDOUT: }
  109. // CHECK:STDOUT: %import_ref: %.1 = import_ref Other//default, inst+4, loaded
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: file {
  113. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  114. // CHECK:STDOUT: .Other = imports.%Other
  115. // CHECK:STDOUT: .b = @__global_init.%b
  116. // CHECK:STDOUT: }
  117. // CHECK:STDOUT: %Other.import = import Other
  118. // CHECK:STDOUT: %.loc4_9.1: %.1 = tuple_literal ()
  119. // CHECK:STDOUT: %.loc4_9.2: type = converted %.loc4_9.1, constants.%.1 [template = constants.%.1]
  120. // CHECK:STDOUT: }
  121. // CHECK:STDOUT:
  122. // CHECK:STDOUT: fn @__global_init() {
  123. // CHECK:STDOUT: !entry:
  124. // CHECK:STDOUT: %Other.ref: <namespace> = name_ref Other, imports.%Other [template = imports.%Other]
  125. // CHECK:STDOUT: %a.ref: %.1 = name_ref a, imports.%import_ref
  126. // CHECK:STDOUT: %b: %.1 = bind_name b, %a.ref
  127. // CHECK:STDOUT: return
  128. // CHECK:STDOUT: }
  129. // CHECK:STDOUT: