member_access.carbon 1.1 KB

123456789101112131415161718192021222324252627282930
  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. // CHECK:STDOUT: ; ModuleID = 'toolchain/lowering/testdata/struct/member_access.carbon'
  7. // CHECK:STDOUT: source_filename = "toolchain/lowering/testdata/struct/member_access.carbon"
  8. // CHECK:STDOUT:
  9. // CHECK:STDOUT: %0 = type { double, i32 }
  10. // CHECK:STDOUT: %1 = type { double, i32 }
  11. // CHECK:STDOUT:
  12. // CHECK:STDOUT: define i32 @Run() {
  13. // CHECK:STDOUT: entry:
  14. // CHECK:STDOUT: %0 = alloca %0, align 8
  15. // CHECK:STDOUT: %1 = alloca %1, align 8
  16. // CHECK:STDOUT: store ptr %1, ptr %0, align 8
  17. // CHECK:STDOUT: %2 = alloca i32, align 4
  18. // CHECK:STDOUT: %3 = getelementptr inbounds %0, ptr %0, i32 0, i32 1
  19. // CHECK:STDOUT: store ptr %3, ptr %2, align 8
  20. // CHECK:STDOUT: %4 = alloca i32, align 4
  21. // CHECK:STDOUT: store ptr %2, ptr %4, align 8
  22. // CHECK:STDOUT: ret i32 0
  23. // CHECK:STDOUT: }
  24. fn Run() -> i32 {
  25. var x: {.a: f64, .b: i32} = {.a = 0.0, .b = 1};
  26. var y: i32 = x.b;
  27. var z: i32 = y;
  28. return 0;
  29. }