empty_tuple.carbon 2.8 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. // 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_tuple.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_tuple.carbon
  10. fn Echo(a: ()) -> () {
  11. return a;
  12. }
  13. fn Main() {
  14. Echo(());
  15. }
  16. // CHECK:STDOUT: --- empty_tuple.carbon
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: constants {
  19. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  20. // CHECK:STDOUT: %Echo.type: type = fn_type @Echo [template]
  21. // CHECK:STDOUT: %Echo: %Echo.type = struct_value () [template]
  22. // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
  23. // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
  24. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template]
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: file {
  28. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  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 [template = constants.%Echo] {
  33. // CHECK:STDOUT: %a.patt: %.1 = binding_pattern a
  34. // CHECK:STDOUT: } {
  35. // CHECK:STDOUT: %.loc11_13.1: %.1 = tuple_literal ()
  36. // CHECK:STDOUT: %.loc11_13.2: type = converted %.loc11_13.1, constants.%.1 [template = constants.%.1]
  37. // CHECK:STDOUT: %a.param: %.1 = param a, runtime_param0
  38. // CHECK:STDOUT: %a: %.1 = bind_name a, %a.param
  39. // CHECK:STDOUT: %.loc11_20.1: %.1 = tuple_literal ()
  40. // CHECK:STDOUT: %.loc11_20.2: type = converted %.loc11_20.1, constants.%.1 [template = constants.%.1]
  41. // CHECK:STDOUT: %return: ref %.1 = var <return slot>
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: fn @Echo(%a: %.1) -> %.1 {
  47. // CHECK:STDOUT: !entry:
  48. // CHECK:STDOUT: %a.ref: %.1 = name_ref a, %a
  49. // CHECK:STDOUT: return %a.ref
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: fn @Main() {
  53. // CHECK:STDOUT: !entry:
  54. // CHECK:STDOUT: %Echo.ref: %Echo.type = name_ref Echo, file.%Echo.decl [template = constants.%Echo]
  55. // CHECK:STDOUT: %.loc16_9: %.1 = tuple_literal ()
  56. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template = constants.%tuple]
  57. // CHECK:STDOUT: %.loc16_7: %.1 = converted %.loc16_9, %tuple [template = constants.%tuple]
  58. // CHECK:STDOUT: %Echo.call: init %.1 = call %Echo.ref(%.loc16_7)
  59. // CHECK:STDOUT: return
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: