import.carbon 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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/import.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/import.carbon
  10. // --- implicit.carbon
  11. package Implicit;
  12. var a_ref: () = ();
  13. // --- implicit.impl.carbon
  14. impl package Implicit;
  15. var a: () = a_ref;
  16. // CHECK:STDOUT: --- implicit.carbon
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: constants {
  19. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  20. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
  21. // CHECK:STDOUT: }
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: file {
  24. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  25. // CHECK:STDOUT: .a_ref = %a_ref
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT: %a_ref.var: ref %empty_tuple.type = var a_ref
  28. // CHECK:STDOUT: %a_ref: ref %empty_tuple.type = bind_name a_ref, %a_ref.var
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: fn @__global_init() {
  32. // CHECK:STDOUT: !entry:
  33. // CHECK:STDOUT: %.loc4_18.1: %empty_tuple.type = tuple_literal ()
  34. // CHECK:STDOUT: %.loc4_18.2: init %empty_tuple.type = tuple_init () to file.%a_ref.var [template = constants.%empty_tuple]
  35. // CHECK:STDOUT: %.loc4_19: init %empty_tuple.type = converted %.loc4_18.1, %.loc4_18.2 [template = constants.%empty_tuple]
  36. // CHECK:STDOUT: assign file.%a_ref.var, %.loc4_19
  37. // CHECK:STDOUT: return
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: --- implicit.impl.carbon
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: constants {
  43. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  44. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: imports {
  48. // CHECK:STDOUT: %import_ref: ref %empty_tuple.type = import_ref Implicit//default, a_ref, loaded
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT:
  51. // CHECK:STDOUT: file {
  52. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  53. // CHECK:STDOUT: .a_ref = imports.%import_ref
  54. // CHECK:STDOUT: .a = %a
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT: %Implicit.import = import Implicit
  57. // CHECK:STDOUT: %default.import = import <invalid>
  58. // CHECK:STDOUT: %a.var: ref %empty_tuple.type = var a
  59. // CHECK:STDOUT: %a: ref %empty_tuple.type = bind_name a, %a.var
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT:
  62. // CHECK:STDOUT: fn @__global_init() {
  63. // CHECK:STDOUT: !entry:
  64. // CHECK:STDOUT: %a_ref.ref: ref %empty_tuple.type = name_ref a_ref, imports.%import_ref
  65. // CHECK:STDOUT: %.loc4_13: init %empty_tuple.type = tuple_init () to file.%a.var [template = constants.%empty_tuple]
  66. // CHECK:STDOUT: %.loc4_18: init %empty_tuple.type = converted %a_ref.ref, %.loc4_13 [template = constants.%empty_tuple]
  67. // CHECK:STDOUT: assign file.%a.var, %.loc4_18
  68. // CHECK:STDOUT: return
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT: