literal_member_access.carbon 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. fn G() -> {.x: i32, .y: i32, .z: i32};
  7. fn F() -> i32 {
  8. return {.a = 1, .b = G(), .c = 3}.b.y;
  9. }
  10. // CHECK:STDOUT: --- literal_member_access.carbon
  11. // CHECK:STDOUT:
  12. // CHECK:STDOUT: constants {
  13. // CHECK:STDOUT: %.1: type = struct_type {.x: i32, .y: i32, .z: i32} [template]
  14. // CHECK:STDOUT: %.2: type = ptr_type {.x: i32, .y: i32, .z: i32} [template]
  15. // CHECK:STDOUT: %.3: i32 = int_literal 1 [template]
  16. // CHECK:STDOUT: %.4: i32 = int_literal 3 [template]
  17. // CHECK:STDOUT: %.5: type = struct_type {.a: i32, .b: {.x: i32, .y: i32, .z: i32}, .c: i32} [template]
  18. // CHECK:STDOUT: %.6: type = struct_type {.a: i32, .b: {.x: i32, .y: i32, .z: i32}*, .c: i32} [template]
  19. // CHECK:STDOUT: %.7: type = ptr_type {.a: i32, .b: {.x: i32, .y: i32, .z: i32}*, .c: i32} [template]
  20. // CHECK:STDOUT: }
  21. // CHECK:STDOUT:
  22. // CHECK:STDOUT: file {
  23. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  24. // CHECK:STDOUT: .G = %G
  25. // CHECK:STDOUT: .F = %F
  26. // CHECK:STDOUT: }
  27. // CHECK:STDOUT: %G: <function> = fn_decl @G [template] {
  28. // CHECK:STDOUT: %.loc7: type = struct_type {.x: i32, .y: i32, .z: i32} [template = constants.%.1]
  29. // CHECK:STDOUT: @G.%return: ref {.x: i32, .y: i32, .z: i32} = var <return slot>
  30. // CHECK:STDOUT: }
  31. // CHECK:STDOUT: %F: <function> = fn_decl @F [template] {
  32. // CHECK:STDOUT: %return.var.loc9: ref i32 = var <return slot>
  33. // CHECK:STDOUT: }
  34. // CHECK:STDOUT: }
  35. // CHECK:STDOUT:
  36. // CHECK:STDOUT: fn @G() -> %return: {.x: i32, .y: i32, .z: i32};
  37. // CHECK:STDOUT:
  38. // CHECK:STDOUT: fn @F() -> i32 {
  39. // CHECK:STDOUT: !entry:
  40. // CHECK:STDOUT: %.loc10_16: i32 = int_literal 1 [template = constants.%.3]
  41. // CHECK:STDOUT: %G.ref: <function> = name_ref G, file.%G [template = file.%G]
  42. // CHECK:STDOUT: %.loc10_25.1: ref {.x: i32, .y: i32, .z: i32} = temporary_storage
  43. // CHECK:STDOUT: %.loc10_25.2: init {.x: i32, .y: i32, .z: i32} = call %G.ref() to %.loc10_25.1
  44. // CHECK:STDOUT: %.loc10_34: i32 = int_literal 3 [template = constants.%.4]
  45. // CHECK:STDOUT: %.loc10_35.1: {.a: i32, .b: {.x: i32, .y: i32, .z: i32}, .c: i32} = struct_literal (%.loc10_16, %.loc10_25.2, %.loc10_34)
  46. // CHECK:STDOUT: %.loc10_25.3: ref {.x: i32, .y: i32, .z: i32} = temporary %.loc10_25.1, %.loc10_25.2
  47. // CHECK:STDOUT: %.loc10_25.4: ref i32 = struct_access %.loc10_25.3, element0
  48. // CHECK:STDOUT: %.loc10_25.5: i32 = bind_value %.loc10_25.4
  49. // CHECK:STDOUT: %.loc10_25.6: ref i32 = struct_access %.loc10_25.3, element1
  50. // CHECK:STDOUT: %.loc10_25.7: i32 = bind_value %.loc10_25.6
  51. // CHECK:STDOUT: %.loc10_25.8: ref i32 = struct_access %.loc10_25.3, element2
  52. // CHECK:STDOUT: %.loc10_25.9: i32 = bind_value %.loc10_25.8
  53. // CHECK:STDOUT: %.loc10_25.10: {.x: i32, .y: i32, .z: i32} = struct_value (%.loc10_25.5, %.loc10_25.7, %.loc10_25.9)
  54. // CHECK:STDOUT: %.loc10_25.11: {.x: i32, .y: i32, .z: i32} = converted %.loc10_25.2, %.loc10_25.10
  55. // CHECK:STDOUT: %.loc10_35.2: {.a: i32, .b: {.x: i32, .y: i32, .z: i32}, .c: i32} = struct_value (%.loc10_16, %.loc10_25.11, %.loc10_34)
  56. // CHECK:STDOUT: %.loc10_35.3: {.a: i32, .b: {.x: i32, .y: i32, .z: i32}, .c: i32} = converted %.loc10_35.1, %.loc10_35.2
  57. // CHECK:STDOUT: %.loc10_36: {.x: i32, .y: i32, .z: i32} = struct_access %.loc10_35.3, element1
  58. // CHECK:STDOUT: %.loc10_38: i32 = struct_access %.loc10_36, element1
  59. // CHECK:STDOUT: return %.loc10_38
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: