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