pointer_conversion.carbon 659 B

1234567891011121314151617181920212223242526272829303132333435
  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. // NOAUTOUPDATE
  6. package ExplorerTest api;
  7. base class A {
  8. var a: i32;
  9. }
  10. base class B {
  11. extend base: A;
  12. var b: i32;
  13. }
  14. class C {
  15. extend base: B;
  16. var c: i32;
  17. }
  18. fn Main() -> i32 {
  19. var c: C = {.base = {.base = {.a = 1}, .b = 2}, .c = 3};
  20. let (pa: A*, pb: B*, pc: C*) = (&c, &c, &c);
  21. Print("{0}", pa->a);
  22. Print("{0}", pb->b);
  23. Print("{0}", pc->c);
  24. return 0;
  25. }
  26. // CHECK:STDOUT: 1
  27. // CHECK:STDOUT: 2
  28. // CHECK:STDOUT: 3
  29. // CHECK:STDOUT: result: 0