value_expr_binding_from_reference.carbon 778 B

123456789101112131415161718192021222324252627282930313233
  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 reference expression
  8. // CHECK:STDOUT: Binding scope end
  9. // CHECK:STDOUT: 0: Heap{}, 1: C{}
  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 CallWithValueExpressionBinding(c: C) {
  19. Print("Binding scope end");
  20. }
  21. fn Main() -> i32 {
  22. var c_var: C = {};
  23. heap.PrintAllocs();
  24. Print("Bind from c reference expression");
  25. CallWithValueExpressionBinding(c_var);
  26. heap.PrintAllocs();
  27. return 0;
  28. }