pointer_conversion.carbon 656 B

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