decl.carbon 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  25. // CHECK:STDOUT: %pattern_type.cb1: type = pattern_type %empty_tuple.type [concrete]
  26. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  27. // CHECK:STDOUT: %DestroyOp.type: type = fn_type @DestroyOp [concrete]
  28. // CHECK:STDOUT: %DestroyOp: %DestroyOp.type = struct_value () [concrete]
  29. // CHECK:STDOUT: }
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: imports {
  32. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  33. // CHECK:STDOUT: .Destroy = %Core.Destroy
  34. // CHECK:STDOUT: import Core//prelude
  35. // CHECK:STDOUT: import Core//prelude/...
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT:
  40. // CHECK:STDOUT: file {
  41. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  42. // CHECK:STDOUT: .Core = imports.%Core
  43. // CHECK:STDOUT: .Main = %Main.decl
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: %Core.import = import Core
  46. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [concrete = constants.%Main] {} {}
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: fn @Main() {
  50. // CHECK:STDOUT: !entry:
  51. // CHECK:STDOUT: name_binding_decl {
  52. // CHECK:STDOUT: %x.patt: %pattern_type.cb1 = ref_binding_pattern x [concrete]
  53. // CHECK:STDOUT: %x.var_patt: %pattern_type.cb1 = var_pattern %x.patt [concrete]
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var %x.var_patt
  56. // CHECK:STDOUT: %.loc3_11.1: type = splice_block %.loc3_11.3 [concrete = constants.%empty_tuple.type] {
  57. // CHECK:STDOUT: %.loc3_11.2: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  58. // CHECK:STDOUT: %.loc3_11.3: type = converted %.loc3_11.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: %x: ref %empty_tuple.type = ref_binding x, %x.var
  61. // CHECK:STDOUT: %DestroyOp.bound: <bound method> = bound_method %x.var, constants.%DestroyOp
  62. // CHECK:STDOUT: %DestroyOp.call: init %empty_tuple.type = call %DestroyOp.bound(%x.var)
  63. // CHECK:STDOUT: return
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: fn @DestroyOp(%self.param: %empty_tuple.type) = "no_op";
  67. // CHECK:STDOUT: