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