pattern_in_signature.carbon 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/function/declaration/pattern_in_signature.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/declaration/pattern_in_signature.carbon
  12. //@dump-sem-ir-begin
  13. fn F((unused a: {}, unused b: {}), unused c: {}) {}
  14. //@dump-sem-ir-end
  15. //@dump-sem-ir-begin
  16. fn CallF(ab: ({}, {}), c: {}) {
  17. F(ab, c);
  18. }
  19. //@dump-sem-ir-end
  20. // CHECK:STDOUT: --- pattern_in_signature.carbon
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: constants {
  23. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  24. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  25. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  26. // CHECK:STDOUT: %pattern_type.a96: type = pattern_type %empty_struct_type [concrete]
  27. // CHECK:STDOUT: %tuple.type.b6b: type = tuple_type (%empty_struct_type, %empty_struct_type) [concrete]
  28. // CHECK:STDOUT: %pattern_type.de4: type = pattern_type %tuple.type.b6b [concrete]
  29. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  30. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  31. // CHECK:STDOUT: %tuple: %tuple.type.b6b = tuple_value (%empty_struct, %empty_struct) [concrete]
  32. // CHECK:STDOUT: %CallF.type: type = fn_type @CallF [concrete]
  33. // CHECK:STDOUT: %CallF: %CallF.type = struct_value () [concrete]
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: file {
  37. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  38. // CHECK:STDOUT: %a.param_patt: %pattern_type.a96 = value_param_pattern [concrete]
  39. // CHECK:STDOUT: %a.patt: %pattern_type.a96 = at_binding_pattern a, %a.param_patt [concrete]
  40. // CHECK:STDOUT: %b.param_patt: %pattern_type.a96 = value_param_pattern [concrete]
  41. // CHECK:STDOUT: %b.patt: %pattern_type.a96 = at_binding_pattern b, %b.param_patt [concrete]
  42. // CHECK:STDOUT: %.loc14_33: %pattern_type.de4 = tuple_pattern (%a.patt, %b.patt) [concrete]
  43. // CHECK:STDOUT: %c.param_patt: %pattern_type.a96 = value_param_pattern [concrete]
  44. // CHECK:STDOUT: %c.patt: %pattern_type.a96 = at_binding_pattern c, %c.param_patt [concrete]
  45. // CHECK:STDOUT: } {
  46. // CHECK:STDOUT: %a.param: %empty_struct_type = value_param call_param0
  47. // CHECK:STDOUT: %.loc14_18.1: type = splice_block %.loc14_18.3 [concrete = constants.%empty_struct_type] {
  48. // CHECK:STDOUT: %.loc14_18.2: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  49. // CHECK:STDOUT: %.loc14_18.3: type = converted %.loc14_18.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT: %a: %empty_struct_type = value_binding a, %a.param
  52. // CHECK:STDOUT: %b.param: %empty_struct_type = value_param call_param1
  53. // CHECK:STDOUT: %.loc14_32.1: type = splice_block %.loc14_32.3 [concrete = constants.%empty_struct_type] {
  54. // CHECK:STDOUT: %.loc14_32.2: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  55. // CHECK:STDOUT: %.loc14_32.3: type = converted %.loc14_32.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT: %b: %empty_struct_type = value_binding b, %b.param
  58. // CHECK:STDOUT: %c.param: %empty_struct_type = value_param call_param2
  59. // CHECK:STDOUT: %.loc14_47.1: type = splice_block %.loc14_47.3 [concrete = constants.%empty_struct_type] {
  60. // CHECK:STDOUT: %.loc14_47.2: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  61. // CHECK:STDOUT: %.loc14_47.3: type = converted %.loc14_47.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT: %c: %empty_struct_type = value_binding c, %c.param
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT: %CallF.decl: %CallF.type = fn_decl @CallF [concrete = constants.%CallF] {
  66. // CHECK:STDOUT: %ab.param_patt: %pattern_type.de4 = value_param_pattern [concrete]
  67. // CHECK:STDOUT: %ab.patt: %pattern_type.de4 = at_binding_pattern ab, %ab.param_patt [concrete]
  68. // CHECK:STDOUT: %c.param_patt: %pattern_type.a96 = value_param_pattern [concrete]
  69. // CHECK:STDOUT: %c.patt: %pattern_type.a96 = at_binding_pattern c, %c.param_patt [concrete]
  70. // CHECK:STDOUT: } {
  71. // CHECK:STDOUT: %ab.param: %tuple.type.b6b = value_param call_param0
  72. // CHECK:STDOUT: %.loc18_21.1: type = splice_block %.loc18_21.5 [concrete = constants.%tuple.type.b6b] {
  73. // CHECK:STDOUT: %.loc18_16: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  74. // CHECK:STDOUT: %.loc18_20: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  75. // CHECK:STDOUT: %.loc18_21.2: %tuple.type.b6b = tuple_literal (%.loc18_16, %.loc18_20) [concrete = constants.%tuple]
  76. // CHECK:STDOUT: %.loc18_21.3: type = converted constants.%empty_struct, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  77. // CHECK:STDOUT: %.loc18_21.4: type = converted constants.%empty_struct, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  78. // CHECK:STDOUT: %.loc18_21.5: type = converted %.loc18_21.2, constants.%tuple.type.b6b [concrete = constants.%tuple.type.b6b]
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT: %ab: %tuple.type.b6b = value_binding ab, %ab.param
  81. // CHECK:STDOUT: %c.param: %empty_struct_type = value_param call_param1
  82. // CHECK:STDOUT: %.loc18_28.1: type = splice_block %.loc18_28.3 [concrete = constants.%empty_struct_type] {
  83. // CHECK:STDOUT: %.loc18_28.2: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  84. // CHECK:STDOUT: %.loc18_28.3: type = converted %.loc18_28.2, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT: %c: %empty_struct_type = value_binding c, %c.param
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT: }
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: fn @F(%a.param: %empty_struct_type, %b.param: %empty_struct_type, %c.param: %empty_struct_type) {
  91. // CHECK:STDOUT: !entry:
  92. // CHECK:STDOUT: return
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: fn @CallF(%ab.param: %tuple.type.b6b, %c.param: %empty_struct_type) {
  96. // CHECK:STDOUT: !entry:
  97. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
  98. // CHECK:STDOUT: %ab.ref: %tuple.type.b6b = name_ref ab, %ab
  99. // CHECK:STDOUT: %c.ref: %empty_struct_type = name_ref c, %c
  100. // CHECK:STDOUT: %tuple.elem0: %empty_struct_type = tuple_access %ab.ref, element0
  101. // CHECK:STDOUT: %tuple.elem1: %empty_struct_type = tuple_access %ab.ref, element1
  102. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.ref(%tuple.elem0, %tuple.elem1, %c.ref)
  103. // CHECK:STDOUT: return
  104. // CHECK:STDOUT: }
  105. // CHECK:STDOUT: