empty.carbon 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 {} [concrete]
  16. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  17. // CHECK:STDOUT: }
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: file {
  20. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  21. // CHECK:STDOUT: .x = %x
  22. // CHECK:STDOUT: .y = %y
  23. // CHECK:STDOUT: }
  24. // CHECK:STDOUT: name_binding_decl {
  25. // CHECK:STDOUT: %x.patt: %empty_struct_type = binding_pattern x
  26. // CHECK:STDOUT: %.loc11_1: %empty_struct_type = var_pattern %x.patt
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT: %x.var: ref %empty_struct_type = var x
  29. // CHECK:STDOUT: %.loc11_9.1: type = splice_block %.loc11_9.3 [concrete = constants.%empty_struct_type] {
  30. // CHECK:STDOUT: %.loc11_9.2: %empty_struct_type = struct_literal ()
  31. // CHECK:STDOUT: %.loc11_9.3: type = converted %.loc11_9.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: %x: ref %empty_struct_type = bind_name x, %x.var
  34. // CHECK:STDOUT: name_binding_decl {
  35. // CHECK:STDOUT: %y.patt: %empty_struct_type = binding_pattern y
  36. // CHECK:STDOUT: %.loc12_1: %empty_struct_type = var_pattern %y.patt
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %y.var: ref %empty_struct_type = var y
  39. // CHECK:STDOUT: %.loc12_9.1: type = splice_block %.loc12_9.3 [concrete = constants.%empty_struct_type] {
  40. // CHECK:STDOUT: %.loc12_9.2: %empty_struct_type = struct_literal ()
  41. // CHECK:STDOUT: %.loc12_9.3: type = converted %.loc12_9.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: %y: ref %empty_struct_type = bind_name y, %y.var
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: fn @__global_init() {
  47. // CHECK:STDOUT: !entry:
  48. // CHECK:STDOUT: %.loc11_14.1: %empty_struct_type = struct_literal ()
  49. // CHECK:STDOUT: %.loc11_14.2: init %empty_struct_type = struct_init () to file.%x.var [concrete = constants.%empty_struct]
  50. // CHECK:STDOUT: %.loc11_1: init %empty_struct_type = converted %.loc11_14.1, %.loc11_14.2 [concrete = constants.%empty_struct]
  51. // CHECK:STDOUT: assign file.%x.var, %.loc11_1
  52. // CHECK:STDOUT: %x.ref: ref %empty_struct_type = name_ref x, file.%x
  53. // CHECK:STDOUT: %.loc12_13: init %empty_struct_type = struct_init () to file.%y.var [concrete = constants.%empty_struct]
  54. // CHECK:STDOUT: %.loc12_1: init %empty_struct_type = converted %x.ref, %.loc12_13 [concrete = constants.%empty_struct]
  55. // CHECK:STDOUT: assign file.%y.var, %.loc12_1
  56. // CHECK:STDOUT: return
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT: