global_decl_import.carbon 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/none.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/var/global_decl_import.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/var/global_decl_import.carbon
  12. // --- decl.carbon
  13. library "[[@TEST_NAME]]";
  14. var x: {.v: ()} = {.v = ()};
  15. // --- import.carbon
  16. library "[[@TEST_NAME]]";
  17. import library "decl";
  18. fn G() -> {.v: ()} {
  19. //@dump-sem-ir-begin
  20. return x;
  21. //@dump-sem-ir-end
  22. }
  23. // CHECK:STDOUT: --- import.carbon
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: constants {
  26. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  27. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  28. // CHECK:STDOUT: %struct_type.v: type = struct_type {.v: %empty_tuple.type} [concrete]
  29. // CHECK:STDOUT: %pattern_type: type = pattern_type %struct_type.v [concrete]
  30. // CHECK:STDOUT: %.c0c: ref %empty_tuple.type = struct_access imports.%x.var, element0 [concrete]
  31. // CHECK:STDOUT: %struct: %struct_type.v = struct_value (%empty_tuple) [concrete]
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: imports {
  35. // CHECK:STDOUT: %Main.x: ref %struct_type.v = import_ref Main//decl, x, loaded [concrete = %x.var]
  36. // CHECK:STDOUT: %x.patt: %pattern_type = ref_binding_pattern x [concrete]
  37. // CHECK:STDOUT: %x.var_patt: %pattern_type = var_pattern %x.patt [concrete]
  38. // CHECK:STDOUT: %x.var: ref %struct_type.v = var %x.var_patt [concrete]
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: fn @G() -> out %return.param: %struct_type.v {
  42. // CHECK:STDOUT: !entry:
  43. // CHECK:STDOUT: %x.ref: ref %struct_type.v = name_ref x, imports.%Main.x [concrete = imports.%x.var]
  44. // CHECK:STDOUT: %.loc8_10.1: ref %empty_tuple.type = struct_access %x.ref, element0 [concrete = constants.%.c0c]
  45. // CHECK:STDOUT: %.loc8_10.2: init %empty_tuple.type = tuple_init () [concrete = constants.%empty_tuple]
  46. // CHECK:STDOUT: %.loc8_10.3: init %empty_tuple.type = converted %.loc8_10.1, %.loc8_10.2 [concrete = constants.%empty_tuple]
  47. // CHECK:STDOUT: %.loc8_10.4: init %struct_type.v = struct_init (%.loc8_10.3) [concrete = constants.%struct]
  48. // CHECK:STDOUT: %.loc8_11: init %struct_type.v = converted %x.ref, %.loc8_10.4 [concrete = constants.%struct]
  49. // CHECK:STDOUT: return %.loc8_11
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: