global_decl_with_init.carbon 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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/global_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/global_decl_with_init.carbon
  10. var x: {.v: ()} = {.v = ()};
  11. // CHECK:STDOUT: --- global_decl_with_init.carbon
  12. // CHECK:STDOUT:
  13. // CHECK:STDOUT: constants {
  14. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template]
  15. // CHECK:STDOUT: %struct_type.v: type = struct_type {.v: %empty_tuple.type} [template]
  16. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [template]
  17. // CHECK:STDOUT: %struct: %struct_type.v = struct_value (%empty_tuple) [template]
  18. // CHECK:STDOUT: }
  19. // CHECK:STDOUT:
  20. // CHECK:STDOUT: file {
  21. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  22. // CHECK:STDOUT: .x = %x
  23. // CHECK:STDOUT: }
  24. // CHECK:STDOUT: %x.var: ref %struct_type.v = var x
  25. // CHECK:STDOUT: %x: ref %struct_type.v = bind_name x, %x.var
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: fn @__global_init() {
  29. // CHECK:STDOUT: !entry:
  30. // CHECK:STDOUT: %.loc11_26.1: %empty_tuple.type = tuple_literal ()
  31. // CHECK:STDOUT: %.loc11_27.1: %struct_type.v = struct_literal (%.loc11_26.1)
  32. // CHECK:STDOUT: %.loc11_27.2: ref %empty_tuple.type = struct_access file.%x.var, element0
  33. // CHECK:STDOUT: %.loc11_26.2: init %empty_tuple.type = tuple_init () to %.loc11_27.2 [template = constants.%empty_tuple]
  34. // CHECK:STDOUT: %.loc11_27.3: init %empty_tuple.type = converted %.loc11_26.1, %.loc11_26.2 [template = constants.%empty_tuple]
  35. // CHECK:STDOUT: %.loc11_27.4: init %struct_type.v = struct_init (%.loc11_27.3) to file.%x.var [template = constants.%struct]
  36. // CHECK:STDOUT: %.loc11_28: init %struct_type.v = converted %.loc11_27.1, %.loc11_27.4 [template = constants.%struct]
  37. // CHECK:STDOUT: assign file.%x.var, %.loc11_28
  38. // CHECK:STDOUT: return
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: