4ce8273ccba8f2b4cf0d8b721bf35b100e19e0b2 717 B

12345678910111213141516171819202122232425262728293031
  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: 0: Heap{}, 1: C{}
  7. // CHECK:STDOUT: Initialize c from reference expression
  8. // CHECK:STDOUT: 0: Heap{}, 1: C{}
  9. // CHECK:STDOUT: c destroyed
  10. // CHECK:STDOUT: result: 0
  11. package ExplorerTest;
  12. class C {
  13. destructor[self: Self] {
  14. Print("c destroyed");
  15. }
  16. }
  17. fn FromReferenceExpression() {
  18. var c_var: C = {};
  19. heap.PrintAllocs();
  20. Print("Initialize c from reference expression");
  21. let c: C = c_var;
  22. heap.PrintAllocs();
  23. }
  24. fn Main() -> i32 {
  25. FromReferenceExpression();
  26. return 0;
  27. }