one_entry.carbon 6.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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: %int_32: Core.IntLiteral = int_value 32 [concrete]
  16. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  17. // CHECK:STDOUT: %struct_type.a.ba9: type = struct_type {.a: %i32} [concrete]
  18. // CHECK:STDOUT: %int_4.0c1: Core.IntLiteral = int_value 4 [concrete]
  19. // CHECK:STDOUT: %struct_type.a.a6c: type = struct_type {.a: Core.IntLiteral} [concrete]
  20. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  21. // CHECK:STDOUT: %Convert.type.1b6: type = fn_type @Convert.1, @ImplicitAs(%i32) [concrete]
  22. // CHECK:STDOUT: %impl_witness.d39: <witness> = impl_witness (imports.%Core.import_ref.a5b), @impl.4f9(%int_32) [concrete]
  23. // CHECK:STDOUT: %Convert.type.035: type = fn_type @Convert.2, @impl.4f9(%int_32) [concrete]
  24. // CHECK:STDOUT: %Convert.956: %Convert.type.035 = struct_value () [concrete]
  25. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%impl_witness.d39) [concrete]
  26. // CHECK:STDOUT: %.be7: type = fn_type_with_self_type %Convert.type.1b6, %ImplicitAs.facet [concrete]
  27. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_4.0c1, %Convert.956 [concrete]
  28. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.956, @Convert.2(%int_32) [concrete]
  29. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_4.0c1, %Convert.specific_fn [concrete]
  30. // CHECK:STDOUT: %int_4.940: %i32 = int_value 4 [concrete]
  31. // CHECK:STDOUT: %struct: %struct_type.a.ba9 = struct_value (%int_4.940) [concrete]
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT:
  34. // CHECK:STDOUT: imports {
  35. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  36. // CHECK:STDOUT: .Int = %Core.Int
  37. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  38. // CHECK:STDOUT: import Core//prelude
  39. // CHECK:STDOUT: import Core//prelude/...
  40. // CHECK:STDOUT: }
  41. // CHECK:STDOUT: }
  42. // CHECK:STDOUT:
  43. // CHECK:STDOUT: file {
  44. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  45. // CHECK:STDOUT: .Core = imports.%Core
  46. // CHECK:STDOUT: .x = %x
  47. // CHECK:STDOUT: .y = %y
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT: %Core.import = import Core
  50. // CHECK:STDOUT: name_binding_decl {
  51. // CHECK:STDOUT: %x.patt: %struct_type.a.ba9 = binding_pattern x
  52. // CHECK:STDOUT: %.loc11_1: %struct_type.a.ba9 = var_pattern %x.patt
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT: %x.var: ref %struct_type.a.ba9 = var x
  55. // CHECK:STDOUT: %.loc11_16: type = splice_block %struct_type.a.loc11 [concrete = constants.%struct_type.a.ba9] {
  56. // CHECK:STDOUT: %int_32.loc11: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  57. // CHECK:STDOUT: %i32.loc11: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  58. // CHECK:STDOUT: %struct_type.a.loc11: type = struct_type {.a: %i32} [concrete = constants.%struct_type.a.ba9]
  59. // CHECK:STDOUT: }
  60. // CHECK:STDOUT: %x: ref %struct_type.a.ba9 = bind_name x, %x.var
  61. // CHECK:STDOUT: name_binding_decl {
  62. // CHECK:STDOUT: %y.patt: %struct_type.a.ba9 = binding_pattern y
  63. // CHECK:STDOUT: %.loc12_1: %struct_type.a.ba9 = var_pattern %y.patt
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT: %y.var: ref %struct_type.a.ba9 = var y
  66. // CHECK:STDOUT: %.loc12_16: type = splice_block %struct_type.a.loc12 [concrete = constants.%struct_type.a.ba9] {
  67. // CHECK:STDOUT: %int_32.loc12: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  68. // CHECK:STDOUT: %i32.loc12: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  69. // CHECK:STDOUT: %struct_type.a.loc12: type = struct_type {.a: %i32} [concrete = constants.%struct_type.a.ba9]
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT: %y: ref %struct_type.a.ba9 = bind_name y, %y.var
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT:
  74. // CHECK:STDOUT: fn @__global_init() {
  75. // CHECK:STDOUT: !entry:
  76. // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [concrete = constants.%int_4.0c1]
  77. // CHECK:STDOUT: %.loc11_27.1: %struct_type.a.a6c = struct_literal (%int_4)
  78. // CHECK:STDOUT: %impl.elem0: %.be7 = impl_witness_access constants.%impl_witness.d39, element0 [concrete = constants.%Convert.956]
  79. // CHECK:STDOUT: %bound_method.loc11_27.1: <bound method> = bound_method %int_4, %impl.elem0 [concrete = constants.%Convert.bound]
  80. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Convert.2(constants.%int_32) [concrete = constants.%Convert.specific_fn]
  81. // CHECK:STDOUT: %bound_method.loc11_27.2: <bound method> = bound_method %int_4, %specific_fn [concrete = constants.%bound_method]
  82. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %bound_method.loc11_27.2(%int_4) [concrete = constants.%int_4.940]
  83. // CHECK:STDOUT: %.loc11_27.2: init %i32 = converted %int_4, %int.convert_checked [concrete = constants.%int_4.940]
  84. // CHECK:STDOUT: %.loc11_27.3: init %struct_type.a.ba9 = struct_init (%.loc11_27.2) to file.%x.var [concrete = constants.%struct]
  85. // CHECK:STDOUT: %.loc11_1: init %struct_type.a.ba9 = converted %.loc11_27.1, %.loc11_27.3 [concrete = constants.%struct]
  86. // CHECK:STDOUT: assign file.%x.var, %.loc11_1
  87. // CHECK:STDOUT: %x.ref: ref %struct_type.a.ba9 = name_ref x, file.%x
  88. // CHECK:STDOUT: %.loc12_20.1: ref %i32 = struct_access %x.ref, element0
  89. // CHECK:STDOUT: %.loc12_20.2: %i32 = bind_value %.loc12_20.1
  90. // CHECK:STDOUT: %.loc12_20.3: init %struct_type.a.ba9 = struct_init (%.loc12_20.2) to file.%y.var
  91. // CHECK:STDOUT: %.loc12_1: init %struct_type.a.ba9 = converted %x.ref, %.loc12_20.3
  92. // CHECK:STDOUT: assign file.%y.var, %.loc12_1
  93. // CHECK:STDOUT: return
  94. // CHECK:STDOUT: }
  95. // CHECK:STDOUT: