empty.carbon 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --no-prelude-import --dump-sem-ir-ranges=if-present
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/struct/empty.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/empty.carbon
  13. var x: {} = {};
  14. var y: {} = x;
  15. // CHECK:STDOUT: --- empty.carbon
  16. // CHECK:STDOUT:
  17. // CHECK:STDOUT: constants {
  18. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  19. // CHECK:STDOUT: %pattern_type: type = pattern_type %empty_struct_type [concrete]
  20. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  21. // CHECK:STDOUT: }
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: file {
  24. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  25. // CHECK:STDOUT: .x = %x
  26. // CHECK:STDOUT: .y = %y
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT: name_binding_decl {
  29. // CHECK:STDOUT: %x.patt: %pattern_type = binding_pattern x [concrete]
  30. // CHECK:STDOUT: %x.var_patt: %pattern_type = var_pattern %x.patt [concrete]
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT: %x.var: ref %empty_struct_type = var %x.var_patt [concrete]
  33. // CHECK:STDOUT: %.loc14_9.1: type = splice_block %.loc14_9.3 [concrete = constants.%empty_struct_type] {
  34. // CHECK:STDOUT: %.loc14_9.2: %empty_struct_type = struct_literal ()
  35. // CHECK:STDOUT: %.loc14_9.3: type = converted %.loc14_9.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: %x: ref %empty_struct_type = bind_name x, %x.var [concrete = %x.var]
  38. // CHECK:STDOUT: name_binding_decl {
  39. // CHECK:STDOUT: %y.patt: %pattern_type = binding_pattern y [concrete]
  40. // CHECK:STDOUT: %y.var_patt: %pattern_type = var_pattern %y.patt [concrete]
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: %y.var: ref %empty_struct_type = var %y.var_patt [concrete]
  43. // CHECK:STDOUT: %.loc15_9.1: type = splice_block %.loc15_9.3 [concrete = constants.%empty_struct_type] {
  44. // CHECK:STDOUT: %.loc15_9.2: %empty_struct_type = struct_literal ()
  45. // CHECK:STDOUT: %.loc15_9.3: type = converted %.loc15_9.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT: %y: ref %empty_struct_type = bind_name y, %y.var [concrete = %y.var]
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: fn @__global_init() {
  51. // CHECK:STDOUT: !entry:
  52. // CHECK:STDOUT: %.loc14_14.1: %empty_struct_type = struct_literal ()
  53. // CHECK:STDOUT: %.loc14_14.2: init %empty_struct_type = struct_init () to file.%x.var [concrete = constants.%empty_struct]
  54. // CHECK:STDOUT: %.loc14_1: init %empty_struct_type = converted %.loc14_14.1, %.loc14_14.2 [concrete = constants.%empty_struct]
  55. // CHECK:STDOUT: assign file.%x.var, %.loc14_1
  56. // CHECK:STDOUT: %x.ref: ref %empty_struct_type = name_ref x, file.%x [concrete = file.%x.var]
  57. // CHECK:STDOUT: %.loc15_13: init %empty_struct_type = struct_init () to file.%y.var [concrete = constants.%empty_struct]
  58. // CHECK:STDOUT: %.loc15_1: init %empty_struct_type = converted %x.ref, %.loc15_13 [concrete = constants.%empty_struct]
  59. // CHECK:STDOUT: assign file.%y.var, %.loc15_1
  60. // CHECK:STDOUT: return
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT: