Files
swift-mirror/test/SILGen/closure_script_global_escape.swift
Michael Gottesman 20c3e1e92f [semantic-sil] Update 45 SILGen tests for ownership.
Very roughly this increases the total coverage of SILGen tests with ownership
enabled to ~20%.

rdar://33358110
2017-08-20 19:11:55 -07:00

41 lines
1.4 KiB
Swift

// RUN: %target-swift-frontend -module-name foo -enable-sil-ownership -emit-silgen %s | %FileCheck %s
// RUN: %target-swift-frontend -module-name foo -enable-sil-ownership -emit-sil -verify %s
// CHECK-LABEL: sil @main
// CHECK: [[GLOBAL:%.*]] = global_addr @_T03foo4flagSbv
// CHECK: [[MARK:%.*]] = mark_uninitialized [var] [[GLOBAL]]
var flag: Bool // expected-note* {{defined here}}
// CHECK: mark_function_escape [[MARK]]
func useFlag() { // expected-error{{'flag' used by function definition before being initialized}}
_ = flag
}
// CHECK: [[CLOSURE:%.*]] = function_ref @_T03fooyycfU_
// CHECK: mark_function_escape [[MARK]]
// CHECK: thin_to_thick_function [[CLOSURE]]
_ = { _ = flag } // expected-error{{'flag' captured by a closure before being initialized}}
// CHECK: mark_function_escape [[MARK]]
// CHECK: [[CLOSURE:%.*]] = function_ref @_T03fooyycfU0_
// CHECK: apply [[CLOSURE]]
_ = { _ = flag }() // expected-error{{'flag' captured by a closure before being initialized}}
flag = true
// CHECK: mark_function_escape [[MARK]]
func useFlag2() {
_ = flag
}
// CHECK: [[CLOSURE:%.*]] = function_ref @_T03fooyycfU1_
// CHECK: mark_function_escape [[MARK]]
// CHECK: thin_to_thick_function [[CLOSURE]]
_ = { _ = flag }
// CHECK: mark_function_escape [[MARK]]
// CHECK: [[CLOSURE:%.*]] = function_ref @_T03fooyycfU2_
// CHECK: apply [[CLOSURE]]
_ = { _ = flag }()