nested_tuple.carbon 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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/tuple/nested_tuple.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/tuple/nested_tuple.carbon
  10. var x: ((i32, i32), i32) = ((12, 76), 6);
  11. // CHECK:STDOUT: --- nested_tuple.carbon
  12. // CHECK:STDOUT:
  13. // CHECK:STDOUT: constants {
  14. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  15. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  16. // CHECK:STDOUT: %tuple.type.1: type = tuple_type (type, type) [template]
  17. // CHECK:STDOUT: %tuple.type.2: type = tuple_type (%tuple.type.1, type) [template]
  18. // CHECK:STDOUT: %tuple.type.3: type = tuple_type (i32, i32) [template]
  19. // CHECK:STDOUT: %tuple.type.4: type = tuple_type (%tuple.type.3, i32) [template]
  20. // CHECK:STDOUT: %.3: i32 = int_value 12 [template]
  21. // CHECK:STDOUT: %.4: i32 = int_value 76 [template]
  22. // CHECK:STDOUT: %.5: i32 = int_value 6 [template]
  23. // CHECK:STDOUT: %tuple.1: %tuple.type.3 = tuple_value (%.3, %.4) [template]
  24. // CHECK:STDOUT: %tuple.2: %tuple.type.4 = tuple_value (%tuple.1, %.5) [template]
  25. // CHECK:STDOUT: }
  26. // CHECK:STDOUT:
  27. // CHECK:STDOUT: imports {
  28. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  29. // CHECK:STDOUT: .Int32 = %import_ref
  30. // CHECK:STDOUT: import Core//prelude
  31. // CHECK:STDOUT: import Core//prelude/...
  32. // CHECK:STDOUT: }
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT:
  35. // CHECK:STDOUT: file {
  36. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  37. // CHECK:STDOUT: .Core = imports.%Core
  38. // CHECK:STDOUT: .x = %x
  39. // CHECK:STDOUT: }
  40. // CHECK:STDOUT: %Core.import = import Core
  41. // CHECK:STDOUT: %int.make_type_32.loc11_10: init type = call constants.%Int32() [template = i32]
  42. // CHECK:STDOUT: %int.make_type_32.loc11_15: init type = call constants.%Int32() [template = i32]
  43. // CHECK:STDOUT: %.loc11_18: %tuple.type.1 = tuple_literal (%int.make_type_32.loc11_10, %int.make_type_32.loc11_15)
  44. // CHECK:STDOUT: %int.make_type_32.loc11_21: init type = call constants.%Int32() [template = i32]
  45. // CHECK:STDOUT: %.loc11_24.1: %tuple.type.2 = tuple_literal (%.loc11_18, %int.make_type_32.loc11_21)
  46. // CHECK:STDOUT: %.loc11_24.2: type = value_of_initializer %int.make_type_32.loc11_10 [template = i32]
  47. // CHECK:STDOUT: %.loc11_24.3: type = converted %int.make_type_32.loc11_10, %.loc11_24.2 [template = i32]
  48. // CHECK:STDOUT: %.loc11_24.4: type = value_of_initializer %int.make_type_32.loc11_15 [template = i32]
  49. // CHECK:STDOUT: %.loc11_24.5: type = converted %int.make_type_32.loc11_15, %.loc11_24.4 [template = i32]
  50. // CHECK:STDOUT: %.loc11_24.6: type = converted %.loc11_18, constants.%tuple.type.3 [template = constants.%tuple.type.3]
  51. // CHECK:STDOUT: %.loc11_24.7: type = value_of_initializer %int.make_type_32.loc11_21 [template = i32]
  52. // CHECK:STDOUT: %.loc11_24.8: type = converted %int.make_type_32.loc11_21, %.loc11_24.7 [template = i32]
  53. // CHECK:STDOUT: %.loc11_24.9: type = converted %.loc11_24.1, constants.%tuple.type.4 [template = constants.%tuple.type.4]
  54. // CHECK:STDOUT: %x.var: ref %tuple.type.4 = var x
  55. // CHECK:STDOUT: %x: ref %tuple.type.4 = bind_name x, %x.var
  56. // CHECK:STDOUT: }
  57. // CHECK:STDOUT:
  58. // CHECK:STDOUT: fn @__global_init() {
  59. // CHECK:STDOUT: !entry:
  60. // CHECK:STDOUT: %.loc11_30: i32 = int_value 12 [template = constants.%.3]
  61. // CHECK:STDOUT: %.loc11_34: i32 = int_value 76 [template = constants.%.4]
  62. // CHECK:STDOUT: %.loc11_36.1: %tuple.type.3 = tuple_literal (%.loc11_30, %.loc11_34)
  63. // CHECK:STDOUT: %.loc11_39: i32 = int_value 6 [template = constants.%.5]
  64. // CHECK:STDOUT: %.loc11_40.1: %tuple.type.4 = tuple_literal (%.loc11_36.1, %.loc11_39)
  65. // CHECK:STDOUT: %.loc11_40.2: ref %tuple.type.3 = tuple_access file.%x.var, element0
  66. // CHECK:STDOUT: %.loc11_36.2: ref i32 = tuple_access %.loc11_40.2, element0
  67. // CHECK:STDOUT: %.loc11_36.3: init i32 = initialize_from %.loc11_30 to %.loc11_36.2 [template = constants.%.3]
  68. // CHECK:STDOUT: %.loc11_36.4: ref i32 = tuple_access %.loc11_40.2, element1
  69. // CHECK:STDOUT: %.loc11_36.5: init i32 = initialize_from %.loc11_34 to %.loc11_36.4 [template = constants.%.4]
  70. // CHECK:STDOUT: %.loc11_36.6: init %tuple.type.3 = tuple_init (%.loc11_36.3, %.loc11_36.5) to %.loc11_40.2 [template = constants.%tuple.1]
  71. // CHECK:STDOUT: %.loc11_40.3: init %tuple.type.3 = converted %.loc11_36.1, %.loc11_36.6 [template = constants.%tuple.1]
  72. // CHECK:STDOUT: %.loc11_40.4: ref i32 = tuple_access file.%x.var, element1
  73. // CHECK:STDOUT: %.loc11_40.5: init i32 = initialize_from %.loc11_39 to %.loc11_40.4 [template = constants.%.5]
  74. // CHECK:STDOUT: %.loc11_40.6: init %tuple.type.4 = tuple_init (%.loc11_40.3, %.loc11_40.5) to file.%x.var [template = constants.%tuple.2]
  75. // CHECK:STDOUT: %.loc11_41: init %tuple.type.4 = converted %.loc11_40.1, %.loc11_40.6 [template = constants.%tuple.2]
  76. // CHECK:STDOUT: assign file.%x.var, %.loc11_41
  77. // CHECK:STDOUT: return
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT: