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