decl_with_init.carbon 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  7. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/destroy.carbon
  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: type = pattern_type %empty_tuple.type [concrete]
  25. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: imports {
  29. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  30. // CHECK:STDOUT: import Core//prelude
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: file {
  35. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  36. // CHECK:STDOUT: .Core = imports.%Core
  37. // CHECK:STDOUT: .Main = %Main.decl
  38. // CHECK:STDOUT: }
  39. // CHECK:STDOUT: %Core.import = import Core
  40. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [concrete = constants.%Main] {} {}
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: fn @Main() {
  44. // CHECK:STDOUT: !entry:
  45. // CHECK:STDOUT: name_binding_decl {
  46. // CHECK:STDOUT: %x.patt: %pattern_type = binding_pattern x [concrete]
  47. // CHECK:STDOUT: %x.var_patt: %pattern_type = var_pattern %x.patt [concrete]
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var %x.var_patt
  50. // CHECK:STDOUT: %.loc3_16.1: %empty_tuple.type = tuple_literal ()
  51. // CHECK:STDOUT: %.loc3_16.2: init %empty_tuple.type = tuple_init () to %x.var [concrete = constants.%empty_tuple]
  52. // CHECK:STDOUT: %.loc3_3: init %empty_tuple.type = converted %.loc3_16.1, %.loc3_16.2 [concrete = constants.%empty_tuple]
  53. // CHECK:STDOUT: assign %x.var, %.loc3_3
  54. // CHECK:STDOUT: %.loc3_11.1: type = splice_block %.loc3_11.3 [concrete = constants.%empty_tuple.type] {
  55. // CHECK:STDOUT: %.loc3_11.2: %empty_tuple.type = tuple_literal ()
  56. // CHECK:STDOUT: %.loc3_11.3: type = converted %.loc3_11.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var
  59. // CHECK:STDOUT: return
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: