empty_struct.carbon 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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/function/call/no_prelude/empty_struct.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/call/no_prelude/empty_struct.carbon
  10. fn Echo(a: {}) -> {} {
  11. return a;
  12. }
  13. fn Main() {
  14. Echo({});
  15. }
  16. // CHECK:STDOUT: --- empty_struct.carbon
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: constants {
  19. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  20. // CHECK:STDOUT: %Echo.type: type = fn_type @Echo [concrete]
  21. // CHECK:STDOUT: %Echo: %Echo.type = struct_value () [concrete]
  22. // CHECK:STDOUT: %Main.type: type = fn_type @Main [concrete]
  23. // CHECK:STDOUT: %Main: %Main.type = struct_value () [concrete]
  24. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: file {
  28. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  29. // CHECK:STDOUT: .Echo = %Echo.decl
  30. // CHECK:STDOUT: .Main = %Main.decl
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT: %Echo.decl: %Echo.type = fn_decl @Echo [concrete = constants.%Echo] {
  33. // CHECK:STDOUT: %a.patt: %empty_struct_type = binding_pattern a
  34. // CHECK:STDOUT: %a.param_patt: %empty_struct_type = value_param_pattern %a.patt, call_param0
  35. // CHECK:STDOUT: %return.patt: %empty_struct_type = return_slot_pattern
  36. // CHECK:STDOUT: %return.param_patt: %empty_struct_type = out_param_pattern %return.patt, call_param1
  37. // CHECK:STDOUT: } {
  38. // CHECK:STDOUT: %.loc11_20.1: %empty_struct_type = struct_literal ()
  39. // CHECK:STDOUT: %.loc11_20.2: type = converted %.loc11_20.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  40. // CHECK:STDOUT: %a.param: %empty_struct_type = value_param call_param0
  41. // CHECK:STDOUT: %.loc11_13.1: type = splice_block %.loc11_13.3 [concrete = constants.%empty_struct_type] {
  42. // CHECK:STDOUT: %.loc11_13.2: %empty_struct_type = struct_literal ()
  43. // CHECK:STDOUT: %.loc11_13.3: type = converted %.loc11_13.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: %a: %empty_struct_type = bind_name a, %a.param
  46. // CHECK:STDOUT: %return.param: ref %empty_struct_type = out_param call_param1
  47. // CHECK:STDOUT: %return: ref %empty_struct_type = return_slot %return.param
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [concrete = constants.%Main] {} {}
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: fn @Echo(%a.param_patt: %empty_struct_type) -> %empty_struct_type {
  53. // CHECK:STDOUT: !entry:
  54. // CHECK:STDOUT: %a.ref: %empty_struct_type = name_ref a, %a
  55. // CHECK:STDOUT: return %a.ref
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: fn @Main() {
  59. // CHECK:STDOUT: !entry:
  60. // CHECK:STDOUT: %Echo.ref: %Echo.type = name_ref Echo, file.%Echo.decl [concrete = constants.%Echo]
  61. // CHECK:STDOUT: %.loc16_9.1: %empty_struct_type = struct_literal ()
  62. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete = constants.%empty_struct]
  63. // CHECK:STDOUT: %.loc16_9.2: %empty_struct_type = converted %.loc16_9.1, %empty_struct [concrete = constants.%empty_struct]
  64. // CHECK:STDOUT: %Echo.call: init %empty_struct_type = call %Echo.ref(%.loc16_9.2)
  65. // CHECK:STDOUT: return
  66. // CHECK:STDOUT: }
  67. // CHECK:STDOUT: