empty.carbon 3.7 KB

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