one_entry.carbon 4.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 [template]
  16. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [template]
  17. // CHECK:STDOUT: %struct_type.a.7cc: type = struct_type {.a: %i32} [template]
  18. // CHECK:STDOUT: %int_4.0c1: Core.IntLiteral = int_value 4 [template]
  19. // CHECK:STDOUT: %struct_type.a.a6c: type = struct_type {.a: Core.IntLiteral} [template]
  20. // CHECK:STDOUT: %Convert.type.cd1: type = fn_type @Convert.1, @ImplicitAs(%i32) [template]
  21. // CHECK:STDOUT: %impl_witness.5b0: <witness> = impl_witness (imports.%import_ref.723), @impl.1(%int_32) [template]
  22. // CHECK:STDOUT: %Convert.type.466: type = fn_type @Convert.2, @impl.1(%int_32) [template]
  23. // CHECK:STDOUT: %Convert.925: %Convert.type.466 = struct_value () [template]
  24. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_4.0c1, %Convert.925 [template]
  25. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(%int_32) [template]
  26. // CHECK:STDOUT: %int_4.2ec: %i32 = int_value 4 [template]
  27. // CHECK:STDOUT: %struct: %struct_type.a.7cc = struct_value (%int_4.2ec) [template]
  28. // CHECK:STDOUT: }
  29. // CHECK:STDOUT:
  30. // CHECK:STDOUT: imports {
  31. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  32. // CHECK:STDOUT: .Int = %import_ref.187
  33. // CHECK:STDOUT: .ImplicitAs = %import_ref.a69
  34. // CHECK:STDOUT: import Core//prelude
  35. // CHECK:STDOUT: import Core//prelude/...
  36. // CHECK:STDOUT: }
  37. // CHECK:STDOUT: }
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: file {
  40. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  41. // CHECK:STDOUT: .Core = imports.%Core
  42. // CHECK:STDOUT: .x = %x
  43. // CHECK:STDOUT: .y = %y
  44. // CHECK:STDOUT: }
  45. // CHECK:STDOUT: %Core.import = import Core
  46. // CHECK:STDOUT: %x.var: ref %struct_type.a.7cc = var x
  47. // CHECK:STDOUT: %x: ref %struct_type.a.7cc = bind_name x, %x.var
  48. // CHECK:STDOUT: %y.var: ref %struct_type.a.7cc = var y
  49. // CHECK:STDOUT: %y: ref %struct_type.a.7cc = bind_name y, %y.var
  50. // CHECK:STDOUT: }
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: fn @__global_init() {
  53. // CHECK:STDOUT: !entry:
  54. // CHECK:STDOUT: %int_4: Core.IntLiteral = int_value 4 [template = constants.%int_4.0c1]
  55. // CHECK:STDOUT: %.loc11_27.1: %struct_type.a.a6c = struct_literal (%int_4)
  56. // CHECK:STDOUT: %impl.elem0: %Convert.type.cd1 = impl_witness_access constants.%impl_witness.5b0, element0 [template = constants.%Convert.925]
  57. // CHECK:STDOUT: %Convert.bound: <bound method> = bound_method %int_4, %impl.elem0 [template = constants.%Convert.bound]
  58. // CHECK:STDOUT: %Convert.specific_fn: <specific function> = specific_function %Convert.bound, @Convert.2(constants.%int_32) [template = constants.%Convert.specific_fn]
  59. // CHECK:STDOUT: %int.convert_checked: init %i32 = call %Convert.specific_fn(%int_4) [template = constants.%int_4.2ec]
  60. // CHECK:STDOUT: %.loc11_27.2: init %i32 = converted %int_4, %int.convert_checked [template = constants.%int_4.2ec]
  61. // CHECK:STDOUT: %.loc11_27.3: init %struct_type.a.7cc = struct_init (%.loc11_27.2) to file.%x.var [template = constants.%struct]
  62. // CHECK:STDOUT: %.loc11_28: init %struct_type.a.7cc = converted %.loc11_27.1, %.loc11_27.3 [template = constants.%struct]
  63. // CHECK:STDOUT: assign file.%x.var, %.loc11_28
  64. // CHECK:STDOUT: %x.ref: ref %struct_type.a.7cc = name_ref x, file.%x
  65. // CHECK:STDOUT: %.loc12_20.1: ref %i32 = struct_access %x.ref, element0
  66. // CHECK:STDOUT: %.loc12_20.2: %i32 = bind_value %.loc12_20.1
  67. // CHECK:STDOUT: %.loc12_20.3: init %struct_type.a.7cc = struct_init (%.loc12_20.2) to file.%y.var
  68. // CHECK:STDOUT: %.loc12_21: init %struct_type.a.7cc = converted %x.ref, %.loc12_20.3
  69. // CHECK:STDOUT: assign file.%y.var, %.loc12_21
  70. // CHECK:STDOUT: return
  71. // CHECK:STDOUT: }
  72. // CHECK:STDOUT: