decl_with_init.carbon 4.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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_with_init.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/var/decl_with_init.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: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  26. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  27. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
  28. // CHECK:STDOUT: %facet_value: %type_where = facet_value %empty_tuple.type, () [concrete]
  29. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.789: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value) [concrete]
  30. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.93e: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.789 = struct_value () [concrete]
  31. // CHECK:STDOUT: %ptr.843: type = ptr_type %empty_tuple.type [concrete]
  32. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn: <specific function> = specific_function %DestroyT.binding.as_type.as.Destroy.impl.Op.93e, @DestroyT.binding.as_type.as.Destroy.impl.Op(%facet_value) [concrete]
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: imports {
  36. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  37. // CHECK:STDOUT: .Destroy = %Core.Destroy
  38. // CHECK:STDOUT: import Core//prelude
  39. // CHECK:STDOUT: import Core//prelude/...
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: file {
  45. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  46. // CHECK:STDOUT: .Core = imports.%Core
  47. // CHECK:STDOUT: .Main = %Main.decl
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %Core.import = import Core
  50. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [concrete = constants.%Main] {} {}
  51. // CHECK:STDOUT: }
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: fn @Main() {
  54. // CHECK:STDOUT: !entry:
  55. // CHECK:STDOUT: name_binding_decl {
  56. // CHECK:STDOUT: %x.patt: %pattern_type.cb1 = binding_pattern x [concrete]
  57. // CHECK:STDOUT: %x.var_patt: %pattern_type.cb1 = var_pattern %x.patt [concrete]
  58. // CHECK:STDOUT: }
  59. // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var %x.var_patt
  60. // CHECK:STDOUT: %.loc3_16.1: %empty_tuple.type = tuple_literal ()
  61. // CHECK:STDOUT: %.loc3_16.2: init %empty_tuple.type = tuple_init () to %x.var [concrete = constants.%empty_tuple]
  62. // CHECK:STDOUT: %.loc3_3: init %empty_tuple.type = converted %.loc3_16.1, %.loc3_16.2 [concrete = constants.%empty_tuple]
  63. // CHECK:STDOUT: assign %x.var, %.loc3_3
  64. // CHECK:STDOUT: %.loc3_11.1: type = splice_block %.loc3_11.3 [concrete = constants.%empty_tuple.type] {
  65. // CHECK:STDOUT: %.loc3_11.2: %empty_tuple.type = tuple_literal ()
  66. // CHECK:STDOUT: %.loc3_11.3: type = converted %.loc3_11.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  67. // CHECK:STDOUT: }
  68. // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var
  69. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.bound: <bound method> = bound_method %x.var, constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.93e
  70. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn: <specific function> = specific_function constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.93e, @DestroyT.binding.as_type.as.Destroy.impl.Op(constants.%facet_value) [concrete = constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn]
  71. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %x.var, %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn
  72. // CHECK:STDOUT: %addr: %ptr.843 = addr_of %x.var
  73. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method(%addr)
  74. // CHECK:STDOUT: return
  75. // CHECK:STDOUT: }
  76. // CHECK:STDOUT: