template_param.carbon 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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/generic/no_prelude/template_param.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/generic/no_prelude/template_param.carbon
  10. // --- fn.carbon
  11. library "[[@TEST_NAME]]";
  12. fn F(template T:! type) {
  13. }
  14. fn G() {
  15. F({});
  16. }
  17. // CHECK:STDOUT: --- fn.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0, template [template]
  21. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0, template [template]
  22. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  23. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  24. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  25. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  26. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  27. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  28. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F, @F(%empty_struct_type) [concrete]
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: file {
  32. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  33. // CHECK:STDOUT: .F = %F.decl
  34. // CHECK:STDOUT: .G = %G.decl
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  37. // CHECK:STDOUT: %T.patt.loc4_15.1: type = symbolic_binding_pattern T, 0, template [template = %T.patt.loc4_15.2 (constants.%T.patt)]
  38. // CHECK:STDOUT: } {
  39. // CHECK:STDOUT: %T.loc4_15.1: type = bind_symbolic_name T, 0, template [template = %T.loc4_15.2 (constants.%T)]
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {} {}
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: generic fn @F(%T.loc4_15.1: type) {
  45. // CHECK:STDOUT: %T.loc4_15.2: type = bind_symbolic_name T, 0, template [template = %T.loc4_15.2 (constants.%T)]
  46. // CHECK:STDOUT: %T.patt.loc4_15.2: type = symbolic_binding_pattern T, 0, template [template = %T.patt.loc4_15.2 (constants.%T.patt)]
  47. // CHECK:STDOUT:
  48. // CHECK:STDOUT: !definition:
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: fn(%T.patt.loc4_15.1: type) {
  51. // CHECK:STDOUT: !entry:
  52. // CHECK:STDOUT: return
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT:
  56. // CHECK:STDOUT: fn @G() {
  57. // CHECK:STDOUT: !entry:
  58. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
  59. // CHECK:STDOUT: %.loc8_6: %empty_struct_type = struct_literal ()
  60. // CHECK:STDOUT: %.loc8_7: type = converted %.loc8_6, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  61. // CHECK:STDOUT: %F.specific_fn: <specific function> = specific_function %F.ref, @F(constants.%empty_struct_type) [concrete = constants.%F.specific_fn]
  62. // CHECK:STDOUT: %F.call: init %empty_tuple.type = call %F.specific_fn()
  63. // CHECK:STDOUT: return
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: specific @F(constants.%T) {
  67. // CHECK:STDOUT: %T.loc4_15.2 => constants.%T
  68. // CHECK:STDOUT: %T.patt.loc4_15.2 => constants.%T.patt
  69. // CHECK:STDOUT: }
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: specific @F(constants.%empty_struct_type) {
  72. // CHECK:STDOUT: %T.loc4_15.2 => constants.%empty_struct_type
  73. // CHECK:STDOUT: %T.patt.loc4_15.2 => constants.%T.patt
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: !definition:
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT: