reference_expr_from_value.carbon 742 B

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