alias.carbon 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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: %.1: type = tuple_type () [template]
  19. // CHECK:STDOUT: %A.type: type = fn_type @A [template]
  20. // CHECK:STDOUT: %A: %A.type = struct_value () [template]
  21. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template]
  22. // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
  23. // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
  24. // CHECK:STDOUT: }
  25. // CHECK:STDOUT:
  26. // CHECK:STDOUT: file {
  27. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  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 [template = constants.%A] {} {
  33. // CHECK:STDOUT: %.loc11_12.1: %.1 = tuple_literal ()
  34. // CHECK:STDOUT: %.loc11_12.2: type = converted %.loc11_12.1, constants.%.1 [template = constants.%.1]
  35. // CHECK:STDOUT: %return: ref %.1 = var <return slot>
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, %A.decl [template = constants.%A]
  38. // CHECK:STDOUT: %B: %A.type = bind_alias B, %A.decl [template = constants.%A]
  39. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: fn @A() -> %.1 {
  43. // CHECK:STDOUT: !entry:
  44. // CHECK:STDOUT: %.loc11_24: %.1 = tuple_literal ()
  45. // CHECK:STDOUT: %tuple: %.1 = tuple_value () [template = constants.%tuple]
  46. // CHECK:STDOUT: %.loc11_25: %.1 = converted %.loc11_24, %tuple [template = constants.%tuple]
  47. // CHECK:STDOUT: return %.loc11_25
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: fn @Main() {
  51. // CHECK:STDOUT: !entry:
  52. // CHECK:STDOUT: %.loc16_11.1: %.1 = tuple_literal ()
  53. // CHECK:STDOUT: %.loc16_11.2: type = converted %.loc16_11.1, constants.%.1 [template = constants.%.1]
  54. // CHECK:STDOUT: %b.var: ref %.1 = var b
  55. // CHECK:STDOUT: %b: ref %.1 = bind_name b, %b.var
  56. // CHECK:STDOUT: %B.ref: %A.type = name_ref B, file.%B [template = constants.%A]
  57. // CHECK:STDOUT: %A.call: init %.1 = call %B.ref()
  58. // CHECK:STDOUT: assign %b.var, %A.call
  59. // CHECK:STDOUT: return
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: