mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
26 lines
806 B
Swift
26 lines
806 B
Swift
// RUN: %target-swift-frontend -parse-as-library -O -module-name=test %s -emit-sil | %FileCheck %s
|
|
|
|
final class Item {}
|
|
|
|
final public class Escaper {
|
|
var myItem: Item = Item()
|
|
|
|
@inline(never)
|
|
func update(items: [Item]) {
|
|
myItem = items[0]
|
|
}
|
|
|
|
// CHECK-LABEL: sil [noinline] @_T04test7EscaperC15badStuffHappensyyF : $@convention(method) (@guaranteed Escaper) -> () {
|
|
// CHECK: %2 = alloc_ref $Item
|
|
// CHECK: alloc_ref [stack] [tail_elems $Item * %{{[0-9]+}} : $Builtin.Word] $_ContiguousArrayStorage<Item>
|
|
// CHECK: return
|
|
@inline(never)
|
|
public func badStuffHappens() {
|
|
// Check that 'item' is not stack promoted, because it escapes to myItem.
|
|
let item = Item()
|
|
// On the other hand, the array buffer of the array literal should be stack promoted.
|
|
update(items:[item])
|
|
}
|
|
}
|
|
|