empty_struct.carbon 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. fn Echo(a: {}) -> {} {
  7. return a;
  8. }
  9. fn Main() {
  10. Echo({});
  11. }
  12. // CHECK:STDOUT: --- empty_struct.carbon
  13. // CHECK:STDOUT:
  14. // CHECK:STDOUT: constants {
  15. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  16. // CHECK:STDOUT: %Echo: type = fn_type @Echo [template]
  17. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  18. // CHECK:STDOUT: %struct.1: Echo = struct_value () [template]
  19. // CHECK:STDOUT: %Main: type = fn_type @Main [template]
  20. // CHECK:STDOUT: %struct.2: Main = struct_value () [template]
  21. // CHECK:STDOUT: %struct.3: {} = struct_value () [template]
  22. // CHECK:STDOUT: }
  23. // CHECK:STDOUT:
  24. // CHECK:STDOUT: file {
  25. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  26. // CHECK:STDOUT: .Echo = %Echo.decl
  27. // CHECK:STDOUT: .Main = %Main.decl
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT: %Echo.decl: Echo = fn_decl @Echo [template = constants.%struct.1] {
  30. // CHECK:STDOUT: %.loc7_13.1: {} = struct_literal ()
  31. // CHECK:STDOUT: %.loc7_13.2: type = converted %.loc7_13.1, constants.%.1 [template = constants.%.1]
  32. // CHECK:STDOUT: %a.loc7_9.1: {} = param a
  33. // CHECK:STDOUT: @Echo.%a: {} = bind_name a, %a.loc7_9.1
  34. // CHECK:STDOUT: %.loc7_20.1: {} = struct_literal ()
  35. // CHECK:STDOUT: %.loc7_20.2: type = converted %.loc7_20.1, constants.%.1 [template = constants.%.1]
  36. // CHECK:STDOUT: @Echo.%return: ref {} = var <return slot>
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %Main.decl: Main = fn_decl @Main [template = constants.%struct.2] {}
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: fn @Echo(%a: {}) -> {} {
  42. // CHECK:STDOUT: !entry:
  43. // CHECK:STDOUT: %a.ref: {} = name_ref a, %a
  44. // CHECK:STDOUT: return %a.ref
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT:
  47. // CHECK:STDOUT: fn @Main() {
  48. // CHECK:STDOUT: !entry:
  49. // CHECK:STDOUT: %Echo.ref: Echo = name_ref Echo, file.%Echo.decl [template = constants.%struct.1]
  50. // CHECK:STDOUT: %.loc12_9: {} = struct_literal ()
  51. // CHECK:STDOUT: %struct: {} = struct_value () [template = constants.%struct.3]
  52. // CHECK:STDOUT: %.loc12_7: {} = converted %.loc12_9, %struct [template = constants.%struct.3]
  53. // CHECK:STDOUT: %Echo.call: init {} = call %Echo.ref(%.loc12_7)
  54. // CHECK:STDOUT: return
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT: