// Part of the Carbon Language project, under the Apache License v2.0 with LLVM // Exceptions. See /LICENSE for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // // AUTOUPDATE package ExplorerTest api; class C { destructor[self: Self] { Print("c destroyed"); } } fn CallWithReturnExpression() -> C { Print("Entering call"); heap.PrintAllocs(); var c: C = {}; Print("Object created, returning"); heap.PrintAllocs(); return c; } fn FromInitializingExpression_ReturnExpr() { Print("Initialize c from initializing expression (return )"); var c: C = CallWithReturnExpression(); heap.PrintAllocs(); } fn Main() -> i32 { FromInitializingExpression_ReturnExpr(); return 0; } // CHECK:STDOUT: Initialize c from initializing expression (return ) // CHECK:STDOUT: Entering call // CHECK:STDOUT: 0: Heap{}, 1: !Uninit // CHECK:STDOUT: Object created, returning // CHECK:STDOUT: 0: Heap{}, 1: !Uninit, 2: C{} // CHECK:STDOUT: c destroyed // CHECK:STDOUT: 0: Heap{}, 1: C{}, 2: !!C{} // CHECK:STDOUT: c destroyed // CHECK:STDOUT: result: 0