nested_struct_in_place.carbon 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 F() -> (i32, i32, i32);
  7. fn G() {
  8. var v: {.a: (i32, i32, i32), .b: (i32, i32, i32)} = {.a = F(), .b = F()};
  9. }
  10. // CHECK:STDOUT: constants {
  11. // CHECK:STDOUT: %.loc7_25.1: type = tuple_type (type, type, type)
  12. // CHECK:STDOUT: %.loc7_25.2: type = tuple_type (i32, i32, i32)
  13. // CHECK:STDOUT: %.loc7_25.3: type = ptr_type (i32, i32, i32)
  14. // CHECK:STDOUT: %.loc10_51.1: type = struct_type {.a: (i32, i32, i32)*, .b: (i32, i32, i32)*}
  15. // CHECK:STDOUT: %.loc10_51.2: type = ptr_type {.a: (i32, i32, i32)*, .b: (i32, i32, i32)*}
  16. // CHECK:STDOUT: }
  17. // CHECK:STDOUT:
  18. // CHECK:STDOUT: file "nested_struct_in_place.carbon" {
  19. // CHECK:STDOUT: %F: <function> = fn_decl @F
  20. // CHECK:STDOUT: %G: <function> = fn_decl @G
  21. // CHECK:STDOUT: }
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: fn @F() -> %return: (i32, i32, i32);
  24. // CHECK:STDOUT:
  25. // CHECK:STDOUT: fn @G() {
  26. // CHECK:STDOUT: !entry:
  27. // CHECK:STDOUT: %.loc10_29: (type, type, type) = tuple_literal (i32, i32, i32)
  28. // CHECK:STDOUT: %.loc7_25.1: type = converted %.loc10_29, constants.%.loc7_25.2
  29. // CHECK:STDOUT: %.loc10_50: (type, type, type) = tuple_literal (i32, i32, i32)
  30. // CHECK:STDOUT: %.loc7_25.2: type = converted %.loc10_50, constants.%.loc7_25.2
  31. // CHECK:STDOUT: %.loc10_51: type = struct_type {.a: (i32, i32, i32), .b: (i32, i32, i32)}
  32. // CHECK:STDOUT: %v.var: ref {.a: (i32, i32, i32), .b: (i32, i32, i32)} = var v
  33. // CHECK:STDOUT: %v: ref {.a: (i32, i32, i32), .b: (i32, i32, i32)} = bind_name v, %v.var
  34. // CHECK:STDOUT: %F.ref.loc10_61: <function> = name_reference F, file.%F
  35. // CHECK:STDOUT: %.loc10_74.1: ref (i32, i32, i32) = struct_access %v.var, member0
  36. // CHECK:STDOUT: %.loc10_62: init (i32, i32, i32) = call %F.ref.loc10_61() to %.loc10_74.1
  37. // CHECK:STDOUT: %F.ref.loc10_71: <function> = name_reference F, file.%F
  38. // CHECK:STDOUT: %.loc10_74.2: ref (i32, i32, i32) = struct_access %v.var, member1
  39. // CHECK:STDOUT: %.loc10_72: init (i32, i32, i32) = call %F.ref.loc10_71() to %.loc10_74.2
  40. // CHECK:STDOUT: %.loc10_74.3: {.a: (i32, i32, i32), .b: (i32, i32, i32)} = struct_literal (%.loc10_62, %.loc10_72)
  41. // CHECK:STDOUT: %.loc10_74.4: init {.a: (i32, i32, i32), .b: (i32, i32, i32)} = struct_init (%.loc10_62, %.loc10_72) to %v.var
  42. // CHECK:STDOUT: %.loc10_74.5: init {.a: (i32, i32, i32), .b: (i32, i32, i32)} = converted %.loc10_74.3, %.loc10_74.4
  43. // CHECK:STDOUT: assign %v.var, %.loc10_74.5
  44. // CHECK:STDOUT: return
  45. // CHECK:STDOUT: }