decl_with_init.carbon 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/var/no_prelude/decl_with_init.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/var/no_prelude/decl_with_init.carbon
  10. fn Main() {
  11. var x: () = ();
  12. }
  13. // CHECK:STDOUT: --- decl_with_init.carbon
  14. // CHECK:STDOUT:
  15. // CHECK:STDOUT: constants {
  16. // CHECK:STDOUT: %Main.type: type = fn_type @Main [template]
  17. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  18. // CHECK:STDOUT: %Main: %Main.type = struct_value () [template]
  19. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
  20. // CHECK:STDOUT: }
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: file {
  23. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  24. // CHECK:STDOUT: .Main = %Main.decl
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [template = constants.%Main] {} {}
  27. // CHECK:STDOUT: }
  28. // CHECK:STDOUT:
  29. // CHECK:STDOUT: fn @Main() {
  30. // CHECK:STDOUT: !entry:
  31. // CHECK:STDOUT: name_binding_decl {
  32. // CHECK:STDOUT: %x.patt: %empty_tuple.type = binding_pattern x
  33. // CHECK:STDOUT: %.loc12_3.1: %empty_tuple.type = var_pattern %x.patt
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var x
  36. // CHECK:STDOUT: %.loc12_16.1: %empty_tuple.type = tuple_literal ()
  37. // CHECK:STDOUT: %.loc12_16.2: init %empty_tuple.type = tuple_init () to %x.var [template = constants.%empty_tuple]
  38. // CHECK:STDOUT: %.loc12_3.2: init %empty_tuple.type = converted %.loc12_16.1, %.loc12_16.2 [template = constants.%empty_tuple]
  39. // CHECK:STDOUT: assign %x.var, %.loc12_3.2
  40. // CHECK:STDOUT: %.loc12_11.1: type = splice_block %.loc12_11.3 [template = constants.%empty_tuple.type] {
  41. // CHECK:STDOUT: %.loc12_11.2: %empty_tuple.type = tuple_literal ()
  42. // CHECK:STDOUT: %.loc12_11.3: type = converted %.loc12_11.2, constants.%empty_tuple.type [template = constants.%empty_tuple.type]
  43. // CHECK:STDOUT: }
  44. // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var
  45. // CHECK:STDOUT: return
  46. // CHECK:STDOUT: }
  47. // CHECK:STDOUT: