alias.carbon 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. // INCLUDE-FILE: toolchain/testing/min_prelude/destroy.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/function/call/min_prelude/alias.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/call/min_prelude/alias.carbon
  12. fn A() -> () { return (); }
  13. alias B = A;
  14. fn Main() {
  15. var b: () = B();
  16. }
  17. // CHECK:STDOUT: --- alias.carbon
  18. // CHECK:STDOUT:
  19. // CHECK:STDOUT: constants {
  20. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  21. // CHECK:STDOUT: %pattern_type: type = pattern_type %empty_tuple.type [concrete]
  22. // CHECK:STDOUT: %A.type: type = fn_type @A [concrete]
  23. // CHECK:STDOUT: %A: %A.type = struct_value () [concrete]
  24. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  25. // CHECK:STDOUT: %Main.type: type = fn_type @Main [concrete]
  26. // CHECK:STDOUT: %Main: %Main.type = struct_value () [concrete]
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: imports {
  30. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  31. // CHECK:STDOUT: import Core//prelude
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: file {
  36. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  37. // CHECK:STDOUT: .Core = imports.%Core
  38. // CHECK:STDOUT: .A = %A.decl
  39. // CHECK:STDOUT: .B = %B
  40. // CHECK:STDOUT: .Main = %Main.decl
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT: %Core.import = import Core
  43. // CHECK:STDOUT: %A.decl: %A.type = fn_decl @A [concrete = constants.%A] {
  44. // CHECK:STDOUT: %return.patt: %pattern_type = return_slot_pattern [concrete]
  45. // CHECK:STDOUT: %return.param_patt: %pattern_type = out_param_pattern %return.patt, call_param0 [concrete]
  46. // CHECK:STDOUT: } {
  47. // CHECK:STDOUT: %.loc13_12.1: %empty_tuple.type = tuple_literal ()
  48. // CHECK:STDOUT: %.loc13_12.2: type = converted %.loc13_12.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  49. // CHECK:STDOUT: %return.param: ref %empty_tuple.type = out_param call_param0
  50. // CHECK:STDOUT: %return: ref %empty_tuple.type = return_slot %return.param
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, %A.decl [concrete = constants.%A]
  53. // CHECK:STDOUT: %B: %A.type = bind_alias B, %A.decl [concrete = constants.%A]
  54. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [concrete = constants.%Main] {} {}
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT:
  57. // CHECK:STDOUT: fn @A() -> %empty_tuple.type {
  58. // CHECK:STDOUT: !entry:
  59. // CHECK:STDOUT: %.loc13_24: %empty_tuple.type = tuple_literal ()
  60. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple]
  61. // CHECK:STDOUT: %.loc13_25: %empty_tuple.type = converted %.loc13_24, %empty_tuple [concrete = constants.%empty_tuple]
  62. // CHECK:STDOUT: return %.loc13_25
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT:
  65. // CHECK:STDOUT: fn @Main() {
  66. // CHECK:STDOUT: !entry:
  67. // CHECK:STDOUT: name_binding_decl {
  68. // CHECK:STDOUT: %b.patt: %pattern_type = binding_pattern b [concrete]
  69. // CHECK:STDOUT: %b.var_patt: %pattern_type = var_pattern %b.patt [concrete]
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT: %b.var: ref %empty_tuple.type = var %b.var_patt
  72. // CHECK:STDOUT: %B.ref: %A.type = name_ref B, file.%B [concrete = constants.%A]
  73. // CHECK:STDOUT: %A.call: init %empty_tuple.type = call %B.ref()
  74. // CHECK:STDOUT: assign %b.var, %A.call
  75. // CHECK:STDOUT: %.loc18_11.1: type = splice_block %.loc18_11.3 [concrete = constants.%empty_tuple.type] {
  76. // CHECK:STDOUT: %.loc18_11.2: %empty_tuple.type = tuple_literal ()
  77. // CHECK:STDOUT: %.loc18_11.3: type = converted %.loc18_11.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT: %b: ref %empty_tuple.type = bind_name b, %b.var
  80. // CHECK:STDOUT: return
  81. // CHECK:STDOUT: }
  82. // CHECK:STDOUT: