mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-30 06:35:01 +01:00
#### Functional changes * Avoid unnecessary copies when a value binding is created from a value expression in call parameters * Ensure the result of the value expression bound is destroyed * Provide storage to initializing expressions used in call parameters --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
32 lines
705 B
Plaintext
32 lines
705 B
Plaintext
// 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
|
|
// CHECK:STDOUT: 0: Heap{}, 1: C{}
|
|
// CHECK:STDOUT: Initialize c from value expression
|
|
// CHECK:STDOUT: 0: Heap{}, 1: C{}
|
|
// CHECK:STDOUT: c destroyed
|
|
// CHECK:STDOUT: result: 0
|
|
|
|
package ExplorerTest api;
|
|
|
|
class C {
|
|
destructor[self: Self] {
|
|
Print("c destroyed");
|
|
}
|
|
}
|
|
|
|
fn FromValueExpression() {
|
|
let c_let: C = {};
|
|
heap.PrintAllocs();
|
|
Print("Initialize c from value expression");
|
|
let c: C = c_let;
|
|
heap.PrintAllocs();
|
|
}
|
|
|
|
fn Main() -> i32 {
|
|
FromValueExpression();
|
|
return 0;
|
|
}
|