params_one_comma.carbon 5.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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_one_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_one_comma.carbon
  10. fn Foo(a: i32,) {}
  11. fn Main() {
  12. Foo(1);
  13. Foo(1,);
  14. }
  15. // CHECK:STDOUT: --- params_one_comma.carbon
  16. // CHECK:STDOUT:
  17. // CHECK:STDOUT: constants {
  18. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template]
  19. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  20. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [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: %int_1.1: Core.IntLiteral = int_value 1 [template]
  26. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  27. // CHECK:STDOUT: %Convert.type.10: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  28. // CHECK:STDOUT: %Convert.10: %Convert.type.10 = struct_value () [template]
  29. // CHECK:STDOUT: %interface.19: <witness> = interface_witness (%Convert.10) [template]
  30. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_1.1, %Convert.10 [template]
  31. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [template]
  32. // CHECK:STDOUT: %int_1.2: %i32 = int_value 1 [template]
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: imports {
  36. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  37. // CHECK:STDOUT: .Int = %import_ref.1
  38. // CHECK:STDOUT: .ImplicitAs = %import_ref.5
  39. // CHECK:STDOUT: import Core//prelude
  40. // CHECK:STDOUT: import Core//prelude/...
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: file {
  45. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  46. // CHECK:STDOUT: .Core = imports.%Core
  47. // CHECK:STDOUT: .Foo = %Foo.decl
  48. // CHECK:STDOUT: .Main = %Main.decl
  49. // CHECK:STDOUT: }
  50. // CHECK:STDOUT: %Core.import = import Core
  51. // CHECK:STDOUT: %Foo.decl: %Foo.type = fn_decl @Foo [template = constants.%Foo] {
  52. // CHECK:STDOUT: %a.patt: %i32 = binding_pattern a
  53. // CHECK:STDOUT: %a.param_patt: %i32 = value_param_pattern %a.patt, runtime_param0
  54. // CHECK:STDOUT: } {
  55. // CHECK:STDOUT: %a.param: %i32 = value_param runtime_param0
  56. // CHECK:STDOUT: %.loc11: type = splice_block %i32 [template = constants.%i32] {
  57. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [template = constants.%int_32]
  58. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(constants.%int_32) [template = constants.%i32]
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: %a: %i32 = bind_name a, %a.param
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: fn @Foo(%a.param_patt: %i32) {
  66. // CHECK:STDOUT: !entry:
  67. // CHECK:STDOUT: return
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT:
  70. // CHECK:STDOUT: fn @Main() {
  71. // CHECK:STDOUT: !entry:
  72. // CHECK:STDOUT: %Foo.ref.loc14: %Foo.type = name_ref Foo, file.%Foo.decl [template = constants.%Foo]
  73. // CHECK:STDOUT: %int_1.loc14: Core.IntLiteral = int_value 1 [template = constants.%int_1.1]
  74. // CHECK:STDOUT: %impl.elem0.loc14: %Convert.type.2 = interface_witness_access constants.%interface.19, element0 [template = constants.%Convert.10]
  75. // CHECK:STDOUT: %Convert.bound.loc14: <bound method> = bound_method %int_1.loc14, %impl.elem0.loc14 [template = constants.%Convert.bound]
  76. // CHECK:STDOUT: %Convert.specific_fn.loc14: <specific function> = specific_function %Convert.bound.loc14, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  77. // CHECK:STDOUT: %int.convert_checked.loc14: init %i32 = call %Convert.specific_fn.loc14(%int_1.loc14) [template = constants.%int_1.2]
  78. // CHECK:STDOUT: %.loc14_7.1: %i32 = value_of_initializer %int.convert_checked.loc14 [template = constants.%int_1.2]
  79. // CHECK:STDOUT: %.loc14_7.2: %i32 = converted %int_1.loc14, %.loc14_7.1 [template = constants.%int_1.2]
  80. // CHECK:STDOUT: %Foo.call.loc14: init %empty_tuple.type = call %Foo.ref.loc14(%.loc14_7.2)
  81. // CHECK:STDOUT: %Foo.ref.loc15: %Foo.type = name_ref Foo, file.%Foo.decl [template = constants.%Foo]
  82. // CHECK:STDOUT: %int_1.loc15: Core.IntLiteral = int_value 1 [template = constants.%int_1.1]
  83. // CHECK:STDOUT: %impl.elem0.loc15: %Convert.type.2 = interface_witness_access constants.%interface.19, element0 [template = constants.%Convert.10]
  84. // CHECK:STDOUT: %Convert.bound.loc15: <bound method> = bound_method %int_1.loc15, %impl.elem0.loc15 [template = constants.%Convert.bound]
  85. // CHECK:STDOUT: %Convert.specific_fn.loc15: <specific function> = specific_function %Convert.bound.loc15, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  86. // CHECK:STDOUT: %int.convert_checked.loc15: init %i32 = call %Convert.specific_fn.loc15(%int_1.loc15) [template = constants.%int_1.2]
  87. // CHECK:STDOUT: %.loc15_7.1: %i32 = value_of_initializer %int.convert_checked.loc15 [template = constants.%int_1.2]
  88. // CHECK:STDOUT: %.loc15_7.2: %i32 = converted %int_1.loc15, %.loc15_7.1 [template = constants.%int_1.2]
  89. // CHECK:STDOUT: %Foo.call.loc15: init %empty_tuple.type = call %Foo.ref.loc15(%.loc15_7.2)
  90. // CHECK:STDOUT: return
  91. // CHECK:STDOUT: }
  92. // CHECK:STDOUT: