decl.carbon 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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/testdata/min_prelude/destroy.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/var/decl.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/var/decl.carbon
  14. // --- basic.carbon
  15. fn Main() {
  16. var x: ();
  17. }
  18. // CHECK:STDOUT: --- basic.carbon
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: constants {
  21. // CHECK:STDOUT: %Main.type: type = fn_type @Main [concrete]
  22. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  23. // CHECK:STDOUT: %Main: %Main.type = struct_value () [concrete]
  24. // CHECK:STDOUT: %pattern_type.cb1: type = pattern_type %empty_tuple.type [concrete]
  25. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  26. // CHECK:STDOUT: %Op.type.a63: type = fn_type @Op.2, @Destroy.impl(%empty_tuple.type) [concrete]
  27. // CHECK:STDOUT: %Op.ea3: %Op.type.a63 = struct_value () [concrete]
  28. // CHECK:STDOUT: %ptr.843: type = ptr_type %empty_tuple.type [concrete]
  29. // CHECK:STDOUT: %Op.specific_fn: <specific function> = specific_function %Op.ea3, @Op.2(%empty_tuple.type) [concrete]
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT:
  32. // CHECK:STDOUT: imports {
  33. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  34. // CHECK:STDOUT: .Destroy = %Core.Destroy
  35. // CHECK:STDOUT: import Core//prelude
  36. // CHECK:STDOUT: import Core//prelude/...
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT:
  41. // CHECK:STDOUT: file {
  42. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  43. // CHECK:STDOUT: .Core = imports.%Core
  44. // CHECK:STDOUT: .Main = %Main.decl
  45. // CHECK:STDOUT: }
  46. // CHECK:STDOUT: %Core.import = import Core
  47. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [concrete = constants.%Main] {} {}
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: fn @Main() {
  51. // CHECK:STDOUT: !entry:
  52. // CHECK:STDOUT: name_binding_decl {
  53. // CHECK:STDOUT: %x.patt: %pattern_type.cb1 = binding_pattern x [concrete]
  54. // CHECK:STDOUT: %x.var_patt: %pattern_type.cb1 = var_pattern %x.patt [concrete]
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var %x.var_patt
  57. // CHECK:STDOUT: %.loc3_11.1: type = splice_block %.loc3_11.3 [concrete = constants.%empty_tuple.type] {
  58. // CHECK:STDOUT: %.loc3_11.2: %empty_tuple.type = tuple_literal ()
  59. // CHECK:STDOUT: %.loc3_11.3: type = converted %.loc3_11.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var
  62. // CHECK:STDOUT: %Op.bound: <bound method> = bound_method %x.var, constants.%Op.ea3
  63. // CHECK:STDOUT: %Op.specific_fn: <specific function> = specific_function constants.%Op.ea3, @Op.2(constants.%empty_tuple.type) [concrete = constants.%Op.specific_fn]
  64. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %x.var, %Op.specific_fn
  65. // CHECK:STDOUT: %addr: %ptr.843 = addr_of %x.var
  66. // CHECK:STDOUT: %no_op: init %empty_tuple.type = call %bound_method(%addr)
  67. // CHECK:STDOUT: return
  68. // CHECK:STDOUT: }
  69. // CHECK:STDOUT: