decl.carbon 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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.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: type = pattern_type %empty_tuple.type [concrete]
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: imports {
  28. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  29. // CHECK:STDOUT: import Core//prelude
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT: }
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: file {
  34. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  35. // CHECK:STDOUT: .Core = imports.%Core
  36. // CHECK:STDOUT: .Main = %Main.decl
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT: %Core.import = import Core
  39. // CHECK:STDOUT: %Main.decl: %Main.type = fn_decl @Main [concrete = constants.%Main] {} {}
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT:
  42. // CHECK:STDOUT: fn @Main() {
  43. // CHECK:STDOUT: !entry:
  44. // CHECK:STDOUT: name_binding_decl {
  45. // CHECK:STDOUT: %x.patt: %pattern_type = binding_pattern x [concrete]
  46. // CHECK:STDOUT: %x.var_patt: %pattern_type = var_pattern %x.patt [concrete]
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT: %x.var: ref %empty_tuple.type = var %x.var_patt
  49. // CHECK:STDOUT: %.loc3_11.1: type = splice_block %.loc3_11.3 [concrete = constants.%empty_tuple.type] {
  50. // CHECK:STDOUT: %.loc3_11.2: %empty_tuple.type = tuple_literal ()
  51. // CHECK:STDOUT: %.loc3_11.3: type = converted %.loc3_11.2, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  52. // CHECK:STDOUT: }
  53. // CHECK:STDOUT: %x: ref %empty_tuple.type = bind_name x, %x.var
  54. // CHECK:STDOUT: return
  55. // CHECK:STDOUT: }
  56. // CHECK:STDOUT: