empty.carbon 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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/struct/no_prelude/empty.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/no_prelude/empty.carbon
  10. var x: {} = {};
  11. var y: {} = x;
  12. // CHECK:STDOUT: --- empty.carbon
  13. // CHECK:STDOUT:
  14. // CHECK:STDOUT: constants {
  15. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  16. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  17. // CHECK:STDOUT: %struct: %.1 = struct_value () [template]
  18. // CHECK:STDOUT: }
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: file {
  21. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  22. // CHECK:STDOUT: .x = %x
  23. // CHECK:STDOUT: .y = %y
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT: %.loc11_9.1: %.1 = struct_literal ()
  26. // CHECK:STDOUT: %.loc11_9.2: type = converted %.loc11_9.1, constants.%.1 [template = constants.%.1]
  27. // CHECK:STDOUT: %x.var: ref %.1 = var x
  28. // CHECK:STDOUT: %x: ref %.1 = bind_name x, %x.var
  29. // CHECK:STDOUT: %.loc12_9.1: %.1 = struct_literal ()
  30. // CHECK:STDOUT: %.loc12_9.2: type = converted %.loc12_9.1, constants.%.1 [template = constants.%.1]
  31. // CHECK:STDOUT: %y.var: ref %.1 = var y
  32. // CHECK:STDOUT: %y: ref %.1 = bind_name y, %y.var
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: fn @__global_init() {
  36. // CHECK:STDOUT: !entry:
  37. // CHECK:STDOUT: %.loc11_14.1: %.1 = struct_literal ()
  38. // CHECK:STDOUT: %.loc11_14.2: init %.1 = struct_init () to file.%x.var [template = constants.%struct]
  39. // CHECK:STDOUT: %.loc11_15: init %.1 = converted %.loc11_14.1, %.loc11_14.2 [template = constants.%struct]
  40. // CHECK:STDOUT: assign file.%x.var, %.loc11_15
  41. // CHECK:STDOUT: %x.ref: ref %.1 = name_ref x, file.%x
  42. // CHECK:STDOUT: %.loc12_13: init %.1 = struct_init () to file.%y.var [template = constants.%struct]
  43. // CHECK:STDOUT: %.loc12_14: init %.1 = converted %x.ref, %.loc12_13 [template = constants.%struct]
  44. // CHECK:STDOUT: assign file.%y.var, %.loc12_14
  45. // CHECK:STDOUT: return
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT: