empty_struct.carbon 2.8 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. // 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: %.1: type = struct_type {} [template]
  20. // CHECK:STDOUT: %Echo.type: type = fn_type @Echo [template]
  21. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  22. // CHECK:STDOUT: %Echo: %Echo.type = struct_value () [template]
  23. // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
  24. // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
  25. // CHECK:STDOUT: %struct: %.1 = struct_value () [template]
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: file {
  29. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  30. // CHECK:STDOUT: .Echo = %Echo.decl
  31. // CHECK:STDOUT: .Main = %Main.decl
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: %Echo.decl: %Echo.type = fn_decl @Echo [template = constants.%Echo] {
  34. // CHECK:STDOUT: %a.patt: %.1 = binding_pattern a
  35. // CHECK:STDOUT: } {
  36. // CHECK:STDOUT: %.loc11_13.1: %.1 = struct_literal ()
  37. // CHECK:STDOUT: %.loc11_13.2: type = converted %.loc11_13.1, constants.%.1 [template = constants.%.1]
  38. // CHECK:STDOUT: %a.param: %.1 = param a, runtime_param0
  39. // CHECK:STDOUT: %a: %.1 = bind_name a, %a.param
  40. // CHECK:STDOUT: %.loc11_20.1: %.1 = struct_literal ()
  41. // CHECK:STDOUT: %.loc11_20.2: type = converted %.loc11_20.1, constants.%.1 [template = constants.%.1]
  42. // CHECK:STDOUT: %return: ref %.1 = var <return slot>
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: fn @Echo(%a: %.1) -> %.1 {
  48. // CHECK:STDOUT: !entry:
  49. // CHECK:STDOUT: %a.ref: %.1 = name_ref a, %a
  50. // CHECK:STDOUT: return %a.ref
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: fn @Main() {
  54. // CHECK:STDOUT: !entry:
  55. // CHECK:STDOUT: %Echo.ref: %Echo.type = name_ref Echo, file.%Echo.decl [template = constants.%Echo]
  56. // CHECK:STDOUT: %.loc16_9: %.1 = struct_literal ()
  57. // CHECK:STDOUT: %struct: %.1 = struct_value () [template = constants.%struct]
  58. // CHECK:STDOUT: %.loc16_7: %.1 = converted %.loc16_9, %struct [template = constants.%struct]
  59. // CHECK:STDOUT: %Echo.call: init %.1 = call %Echo.ref(%.loc16_7)
  60. // CHECK:STDOUT: return
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT: