empty.carbon 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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: %empty_struct_type: type = struct_type {} [template]
  16. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [template]
  17. // CHECK:STDOUT: }
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: file {
  20. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  21. // CHECK:STDOUT: .x = %x
  22. // CHECK:STDOUT: .y = %y
  23. // CHECK:STDOUT: }
  24. // CHECK:STDOUT: %x.var: ref %empty_struct_type = var x
  25. // CHECK:STDOUT: %x: ref %empty_struct_type = bind_name x, %x.var
  26. // CHECK:STDOUT: %y.var: ref %empty_struct_type = var y
  27. // CHECK:STDOUT: %y: ref %empty_struct_type = bind_name y, %y.var
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: fn @__global_init() {
  31. // CHECK:STDOUT: !entry:
  32. // CHECK:STDOUT: %.loc11_14.1: %empty_struct_type = struct_literal ()
  33. // CHECK:STDOUT: %.loc11_14.2: init %empty_struct_type = struct_init () to file.%x.var [template = constants.%empty_struct]
  34. // CHECK:STDOUT: %.loc11_15: init %empty_struct_type = converted %.loc11_14.1, %.loc11_14.2 [template = constants.%empty_struct]
  35. // CHECK:STDOUT: assign file.%x.var, %.loc11_15
  36. // CHECK:STDOUT: %x.ref: ref %empty_struct_type = name_ref x, file.%x
  37. // CHECK:STDOUT: %.loc12_13: init %empty_struct_type = struct_init () to file.%y.var [template = constants.%empty_struct]
  38. // CHECK:STDOUT: %.loc12_14: init %empty_struct_type = converted %x.ref, %.loc12_13 [template = constants.%empty_struct]
  39. // CHECK:STDOUT: assign file.%y.var, %.loc12_14
  40. // CHECK:STDOUT: return
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: