alias.carbon 3.6 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/no_prelude/alias.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/call/no_prelude/alias.carbon
  10. fn A() -> () { return (); }
  11. alias B = A;
  12. fn Main() {
  13. var b: () = B();
  14. }
  15. // CHECK:STDOUT: --- alias.carbon
  16. // CHECK:STDOUT:
  17. // CHECK:STDOUT: constants {
  18. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  19. // CHECK:STDOUT: %A.type: type = fn_type @A [concrete]
  20. // CHECK:STDOUT: %A: %A.type = struct_value () [concrete]
  21. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  22. // CHECK:STDOUT: %Main.type: type = fn_type @Main [concrete]
  23. // CHECK:STDOUT: %Main: %Main.type = struct_value () [concrete]
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: file {
  27. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  28. // CHECK:STDOUT: .A = %A.decl
  29. // CHECK:STDOUT: .B = %B
  30. // CHECK:STDOUT: .Main = %Main.decl
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [concrete = constants.%A] {
  33. // CHECK:STDOUT: %return.patt: %empty_tuple.type = return_slot_pattern
  34. // CHECK:STDOUT: %return.param_patt: %empty_tuple.type = out_param_pattern %return.patt, call_param0
  35. // CHECK:STDOUT: } {
  36. // CHECK:STDOUT: %.loc11_12.1: %empty_tuple.type = tuple_literal ()
  37. // CHECK:STDOUT: %.loc11_12.2: type = converted %.loc11_12.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  38. // CHECK:STDOUT: %return.param: ref %empty_tuple.type = out_param call_param0
  39. // CHECK:STDOUT: %return: ref %empty_tuple.type = return_slot %return.param
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, %A.decl [concrete = constants.%A]
  42. // CHECK:STDOUT: %B: %A.type = bind_alias B, %A.decl [concrete = constants.%A]
  43. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [concrete = constants.%Main] {} {}
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT:
  46. // CHECK:STDOUT: fn @A() -> %empty_tuple.type {
  47. // CHECK:STDOUT: !entry:
  48. // CHECK:STDOUT: %.loc11_24: %empty_tuple.type = tuple_literal ()
  49. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple]
  50. // CHECK:STDOUT: %.loc11_25: %empty_tuple.type = converted %.loc11_24, %empty_tuple [concrete = constants.%empty_tuple]
  51. // CHECK:STDOUT: return %.loc11_25
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT:
  54. // CHECK:STDOUT: fn @Main() {
  55. // CHECK:STDOUT: !entry:
  56. // CHECK:STDOUT: name_binding_decl {
  57. // CHECK:STDOUT: %b.patt: %empty_tuple.type = binding_pattern b
  58. // CHECK:STDOUT: %.loc16_3: %empty_tuple.type = var_pattern %b.patt
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: %b.var: ref %empty_tuple.type = var b
  61. // CHECK:STDOUT: %B.ref: %A.type = name_ref B, file.%B [concrete = constants.%A]
  62. // CHECK:STDOUT: %A.call: init %empty_tuple.type = call %B.ref()
  63. // CHECK:STDOUT: assign %b.var, %A.call
  64. // CHECK:STDOUT: %.loc16_11.1: type = splice_block %.loc16_11.3 [concrete = constants.%empty_tuple.type] {
  65. // CHECK:STDOUT: %.loc16_11.2: %empty_tuple.type = tuple_literal ()
  66. // CHECK:STDOUT: %.loc16_11.3: type = converted %.loc16_11.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT: %b: ref %empty_tuple.type = bind_name b, %b.var
  69. // CHECK:STDOUT: return
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT: