params_two_comma.carbon 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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: %Int32.type: type = fn_type @Int32 [template]
  19. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  20. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  21. // CHECK:STDOUT: %Foo.type: type = fn_type @Foo [template]
  22. // CHECK:STDOUT: %Foo: %Foo.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: %.2: i32 = int_literal 1 [template]
  26. // CHECK:STDOUT: %.3: i32 = int_literal 2 [template]
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: file {
  30. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  31. // CHECK:STDOUT: .Core = %Core
  32. // CHECK:STDOUT: .Foo = %Foo.decl
  33. // CHECK:STDOUT: .Main = %Main.decl
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  36. // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  37. // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
  38. // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
  39. // CHECK:STDOUT: %int.make_type_32.loc11_11: init type = call constants.%Int32() [template = i32]
  40. // CHECK:STDOUT: %.loc11_11.1: type = value_of_initializer %int.make_type_32.loc11_11 [template = i32]
  41. // CHECK:STDOUT: %.loc11_11.2: type = converted %int.make_type_32.loc11_11, %.loc11_11.1 [template = i32]
  42. // CHECK:STDOUT: %a.loc11_8.1: i32 = param a
  43. // CHECK:STDOUT: @Foo.%a: i32 = bind_name a, %a.loc11_8.1
  44. // CHECK:STDOUT: %int.make_type_32.loc11_19: init type = call constants.%Int32() [template = i32]
  45. // CHECK:STDOUT: %.loc11_19.1: type = value_of_initializer %int.make_type_32.loc11_19 [template = i32]
  46. // CHECK:STDOUT: %.loc11_19.2: type = converted %int.make_type_32.loc11_19, %.loc11_19.1 [template = i32]
  47. // CHECK:STDOUT: %b.loc11_16.1: i32 = param b
  48. // CHECK:STDOUT: @Foo.%b: i32 = bind_name b, %b.loc11_16.1
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {}
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  54. // CHECK:STDOUT:
  55. // CHECK:STDOUT: fn @Foo(%a: i32, %b: i32) {
  56. // CHECK:STDOUT: !entry:
  57. // CHECK:STDOUT: return
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: fn @Main() {
  61. // CHECK:STDOUT: !entry:
  62. // CHECK:STDOUT: %Foo.ref.loc14: %Foo.type = name_ref Foo, file.%Foo.decl [template = constants.%Foo]
  63. // CHECK:STDOUT: %.loc14_7: i32 = int_literal 1 [template = constants.%.2]
  64. // CHECK:STDOUT: %.loc14_10: i32 = int_literal 2 [template = constants.%.3]
  65. // CHECK:STDOUT: %Foo.call.loc14: init %.1 = call %Foo.ref.loc14(%.loc14_7, %.loc14_10)
  66. // CHECK:STDOUT: %Foo.ref.loc15: %Foo.type = name_ref Foo, file.%Foo.decl [template = constants.%Foo]
  67. // CHECK:STDOUT: %.loc15_7: i32 = int_literal 1 [template = constants.%.2]
  68. // CHECK:STDOUT: %.loc15_10: i32 = int_literal 2 [template = constants.%.3]
  69. // CHECK:STDOUT: %Foo.call.loc15: init %.1 = call %Foo.ref.loc15(%.loc15_7, %.loc15_10)
  70. // CHECK:STDOUT: return
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT: