one_entry.carbon 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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/struct/one_entry.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/one_entry.carbon
  10. var x: {.a: i32} = {.a = 4};
  11. var y: {.a: i32} = x;
  12. // CHECK:STDOUT: --- one_entry.carbon
  13. // CHECK:STDOUT:
  14. // CHECK:STDOUT: constants {
  15. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  16. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  17. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  18. // CHECK:STDOUT: %.2: type = struct_type {.a: i32} [template]
  19. // CHECK:STDOUT: %.3: i32 = int_literal 4 [template]
  20. // CHECK:STDOUT: %struct: %.2 = struct_value (%.3) [template]
  21. // CHECK:STDOUT: }
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: imports {
  24. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  25. // CHECK:STDOUT: .Int32 = %import_ref
  26. // CHECK:STDOUT: import Core//prelude
  27. // CHECK:STDOUT: import Core//prelude/operators
  28. // CHECK:STDOUT: import Core//prelude/types
  29. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  30. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  31. // CHECK:STDOUT: import Core//prelude/operators/comparison
  32. // CHECK:STDOUT: import Core//prelude/types/bool
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  35. // CHECK:STDOUT: }
  36. // CHECK:STDOUT:
  37. // CHECK:STDOUT: file {
  38. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  39. // CHECK:STDOUT: .Core = imports.%Core
  40. // CHECK:STDOUT: .x = %x
  41. // CHECK:STDOUT: .y = %y
  42. // CHECK:STDOUT: }
  43. // CHECK:STDOUT: %Core.import = import Core
  44. // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32]
  45. // CHECK:STDOUT: %.loc11_13.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32]
  46. // CHECK:STDOUT: %.loc11_13.2: type = converted %int.make_type_32.loc11, %.loc11_13.1 [template = i32]
  47. // CHECK:STDOUT: %.loc11_16: type = struct_type {.a: i32} [template = constants.%.2]
  48. // CHECK:STDOUT: %x.var: ref %.2 = var x
  49. // CHECK:STDOUT: %x: ref %.2 = bind_name x, %x.var
  50. // CHECK:STDOUT: %int.make_type_32.loc12: init type = call constants.%Int32() [template = i32]
  51. // CHECK:STDOUT: %.loc12_13.1: type = value_of_initializer %int.make_type_32.loc12 [template = i32]
  52. // CHECK:STDOUT: %.loc12_13.2: type = converted %int.make_type_32.loc12, %.loc12_13.1 [template = i32]
  53. // CHECK:STDOUT: %.loc12_16: type = struct_type {.a: i32} [template = constants.%.2]
  54. // CHECK:STDOUT: %y.var: ref %.2 = var y
  55. // CHECK:STDOUT: %y: ref %.2 = bind_name y, %y.var
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  59. // CHECK:STDOUT:
  60. // CHECK:STDOUT: fn @__global_init() {
  61. // CHECK:STDOUT: !entry:
  62. // CHECK:STDOUT: %.loc11_26: i32 = int_literal 4 [template = constants.%.3]
  63. // CHECK:STDOUT: %.loc11_27.1: %.2 = struct_literal (%.loc11_26)
  64. // CHECK:STDOUT: %.loc11_27.2: init %.2 = struct_init (%.loc11_26) to file.%x.var [template = constants.%struct]
  65. // CHECK:STDOUT: %.loc11_28: init %.2 = converted %.loc11_27.1, %.loc11_27.2 [template = constants.%struct]
  66. // CHECK:STDOUT: assign file.%x.var, %.loc11_28
  67. // CHECK:STDOUT: %x.ref: ref %.2 = name_ref x, file.%x
  68. // CHECK:STDOUT: %.loc12_20.1: ref i32 = struct_access %x.ref, element0
  69. // CHECK:STDOUT: %.loc12_20.2: i32 = bind_value %.loc12_20.1
  70. // CHECK:STDOUT: %.loc12_20.3: init %.2 = struct_init (%.loc12_20.2) to file.%y.var
  71. // CHECK:STDOUT: %.loc12_21: init %.2 = converted %x.ref, %.loc12_20.3
  72. // CHECK:STDOUT: assign file.%y.var, %.loc12_21
  73. // CHECK:STDOUT: return
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT: