params_two_comma.carbon 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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/params_two_comma.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/call/params_two_comma.carbon
  10. fn Foo(a: i32, b: i32,) {}
  11. fn Main() {
  12. Foo(1, 2);
  13. Foo(1, 2,);
  14. }
  15. // CHECK:STDOUT: --- params_two_comma.carbon
  16. // CHECK:STDOUT:
  17. // CHECK:STDOUT: constants {
  18. // CHECK:STDOUT: %.1: Core.IntLiteral = int_value 32 [template]
  19. // CHECK:STDOUT: %Int.type: type = fn_type @Int [template]
  20. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  21. // CHECK:STDOUT: %Int: %Int.type = struct_value () [template]
  22. // CHECK:STDOUT: %i32: type = int_type signed, %.1 [template]
  23. // CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
  24. // CHECK:STDOUT: %Foo: %Foo.type = struct_value () [template]
  25. // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
  26. // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
  27. // CHECK:STDOUT: %.2: Core.IntLiteral = int_value 1 [template]
  28. // CHECK:STDOUT: %.3: Core.IntLiteral = int_value 2 [template]
  29. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  30. // CHECK:STDOUT: %Convert.type.14: type = fn_type @Convert.2, @impl.1(%.1) [template]
  31. // CHECK:STDOUT: %Convert.14: %Convert.type.14 = struct_value () [template]
  32. // CHECK:STDOUT: %.27: <witness> = interface_witness (%Convert.14) [template]
  33. // CHECK:STDOUT: %.28: <bound method> = bound_method %.2, %Convert.14 [template]
  34. // CHECK:STDOUT: %.29: <specific function> = specific_function %.28, @Convert.2(%.1) [template]
  35. // CHECK:STDOUT: %.30: %i32 = int_value 1 [template]
  36. // CHECK:STDOUT: %.31: <bound method> = bound_method %.3, %Convert.14 [template]
  37. // CHECK:STDOUT: %.32: <specific function> = specific_function %.31, @Convert.2(%.1) [template]
  38. // CHECK:STDOUT: %.33: %i32 = int_value 2 [template]
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: imports {
  42. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  43. // CHECK:STDOUT: .Int = %import_ref.1
  44. // CHECK:STDOUT: .ImplicitAs = %import_ref.2
  45. // CHECK:STDOUT: import Core//prelude
  46. // CHECK:STDOUT: import Core//prelude/...
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: file {
  51. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  52. // CHECK:STDOUT: .Core = imports.%Core
  53. // CHECK:STDOUT: .Foo = %Foo.decl
  54. // CHECK:STDOUT: .Main = %Main.decl
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT: %Core.import = import Core
  57. // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
  58. // CHECK:STDOUT: %a.patt: %i32 = binding_pattern a
  59. // CHECK:STDOUT: %a.param_patt: %i32 = value_param_pattern %a.patt, runtime_param0
  60. // CHECK:STDOUT: %b.patt: %i32 = binding_pattern b
  61. // CHECK:STDOUT: %b.param_patt: %i32 = value_param_pattern %b.patt, runtime_param1
  62. // CHECK:STDOUT: } {
  63. // CHECK:STDOUT: %.loc11_11.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  64. // CHECK:STDOUT: %int.make_type_signed.loc11_11: init type = call constants.%Int(%.loc11_11.1) [template = constants.%i32]
  65. // CHECK:STDOUT: %.loc11_11.2: type = value_of_initializer %int.make_type_signed.loc11_11 [template = constants.%i32]
  66. // CHECK:STDOUT: %.loc11_11.3: type = converted %int.make_type_signed.loc11_11, %.loc11_11.2 [template = constants.%i32]
  67. // CHECK:STDOUT: %.loc11_19.1: Core.IntLiteral = int_value 32 [template = constants.%.1]
  68. // CHECK:STDOUT: %int.make_type_signed.loc11_19: init type = call constants.%Int(%.loc11_19.1) [template = constants.%i32]
  69. // CHECK:STDOUT: %.loc11_19.2: type = value_of_initializer %int.make_type_signed.loc11_19 [template = constants.%i32]
  70. // CHECK:STDOUT: %.loc11_19.3: type = converted %int.make_type_signed.loc11_19, %.loc11_19.2 [template = constants.%i32]
  71. // CHECK:STDOUT: %a.param: %i32 = value_param runtime_param0
  72. // CHECK:STDOUT: %a: %i32 = bind_name a, %a.param
  73. // CHECK:STDOUT: %b.param: %i32 = value_param runtime_param1
  74. // CHECK:STDOUT: %b: %i32 = bind_name b, %b.param
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: fn @Foo(%a.param_patt: %i32, %b.param_patt: %i32) {
  80. // CHECK:STDOUT: !entry:
  81. // CHECK:STDOUT: return
  82. // CHECK:STDOUT: }
  83. // CHECK:STDOUT:
  84. // CHECK:STDOUT: fn @Main() {
  85. // CHECK:STDOUT: !entry:
  86. // CHECK:STDOUT: %Foo.ref.loc14: %Foo.type = name_ref Foo, file.%Foo.decl [template = constants.%Foo]
  87. // CHECK:STDOUT: %.loc14_7.1: Core.IntLiteral = int_value 1 [template = constants.%.2]
  88. // CHECK:STDOUT: %.loc14_10.1: Core.IntLiteral = int_value 2 [template = constants.%.3]
  89. // CHECK:STDOUT: %.loc14_7.2: %Convert.type.2 = interface_witness_access constants.%.27, element0 [template = constants.%Convert.14]
  90. // CHECK:STDOUT: %.loc14_7.3: <bound method> = bound_method %.loc14_7.1, %.loc14_7.2 [template = constants.%.28]
  91. // CHECK:STDOUT: %.loc14_7.4: <specific function> = specific_function %.loc14_7.3, @Convert.2(constants.%.1) [template = constants.%.29]
  92. // CHECK:STDOUT: %int.convert_checked.loc14_7: init %i32 = call %.loc14_7.4(%.loc14_7.1) [template = constants.%.30]
  93. // CHECK:STDOUT: %.loc14_7.5: %i32 = value_of_initializer %int.convert_checked.loc14_7 [template = constants.%.30]
  94. // CHECK:STDOUT: %.loc14_7.6: %i32 = converted %.loc14_7.1, %.loc14_7.5 [template = constants.%.30]
  95. // CHECK:STDOUT: %.loc14_10.2: %Convert.type.2 = interface_witness_access constants.%.27, element0 [template = constants.%Convert.14]
  96. // CHECK:STDOUT: %.loc14_10.3: <bound method> = bound_method %.loc14_10.1, %.loc14_10.2 [template = constants.%.31]
  97. // CHECK:STDOUT: %.loc14_10.4: <specific function> = specific_function %.loc14_10.3, @Convert.2(constants.%.1) [template = constants.%.32]
  98. // CHECK:STDOUT: %int.convert_checked.loc14_10: init %i32 = call %.loc14_10.4(%.loc14_10.1) [template = constants.%.33]
  99. // CHECK:STDOUT: %.loc14_10.5: %i32 = value_of_initializer %int.convert_checked.loc14_10 [template = constants.%.33]
  100. // CHECK:STDOUT: %.loc14_10.6: %i32 = converted %.loc14_10.1, %.loc14_10.5 [template = constants.%.33]
  101. // CHECK:STDOUT: %Foo.call.loc14: init %empty_tuple.type = call %Foo.ref.loc14(%.loc14_7.6, %.loc14_10.6)
  102. // CHECK:STDOUT: %Foo.ref.loc15: %Foo.type = name_ref Foo, file.%Foo.decl [template = constants.%Foo]
  103. // CHECK:STDOUT: %.loc15_7.1: Core.IntLiteral = int_value 1 [template = constants.%.2]
  104. // CHECK:STDOUT: %.loc15_10.1: Core.IntLiteral = int_value 2 [template = constants.%.3]
  105. // CHECK:STDOUT: %.loc15_7.2: %Convert.type.2 = interface_witness_access constants.%.27, element0 [template = constants.%Convert.14]
  106. // CHECK:STDOUT: %.loc15_7.3: <bound method> = bound_method %.loc15_7.1, %.loc15_7.2 [template = constants.%.28]
  107. // CHECK:STDOUT: %.loc15_7.4: <specific function> = specific_function %.loc15_7.3, @Convert.2(constants.%.1) [template = constants.%.29]
  108. // CHECK:STDOUT: %int.convert_checked.loc15_7: init %i32 = call %.loc15_7.4(%.loc15_7.1) [template = constants.%.30]
  109. // CHECK:STDOUT: %.loc15_7.5: %i32 = value_of_initializer %int.convert_checked.loc15_7 [template = constants.%.30]
  110. // CHECK:STDOUT: %.loc15_7.6: %i32 = converted %.loc15_7.1, %.loc15_7.5 [template = constants.%.30]
  111. // CHECK:STDOUT: %.loc15_10.2: %Convert.type.2 = interface_witness_access constants.%.27, element0 [template = constants.%Convert.14]
  112. // CHECK:STDOUT: %.loc15_10.3: <bound method> = bound_method %.loc15_10.1, %.loc15_10.2 [template = constants.%.31]
  113. // CHECK:STDOUT: %.loc15_10.4: <specific function> = specific_function %.loc15_10.3, @Convert.2(constants.%.1) [template = constants.%.32]
  114. // CHECK:STDOUT: %int.convert_checked.loc15_10: init %i32 = call %.loc15_10.4(%.loc15_10.1) [template = constants.%.33]
  115. // CHECK:STDOUT: %.loc15_10.5: %i32 = value_of_initializer %int.convert_checked.loc15_10 [template = constants.%.33]
  116. // CHECK:STDOUT: %.loc15_10.6: %i32 = converted %.loc15_10.1, %.loc15_10.5 [template = constants.%.33]
  117. // CHECK:STDOUT: %Foo.call.loc15: init %empty_tuple.type = call %Foo.ref.loc15(%.loc15_7.6, %.loc15_10.6)
  118. // CHECK:STDOUT: return
  119. // CHECK:STDOUT: }
  120. // CHECK:STDOUT: