mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Right now the stdlib/overlays can compile against -Onone tests with or without -enable-ownership-stripping-after-serialization. This will help me to prevent other work going on from breaking these properties.
33 lines
539 B
Swift
33 lines
539 B
Swift
// RUN: %target-swift-frontend -emit-sil -verify %s
|
|
// RUN: %target-swift-frontend -emit-sil -enable-ownership-stripping-after-serialization -verify %s
|
|
|
|
func foo<T>(a: Bool, t: T) {
|
|
let x: T
|
|
defer { print(x) }
|
|
|
|
x = t
|
|
return
|
|
}
|
|
|
|
func bar<T>(a: Bool, t: T) {
|
|
let x: T // expected-note {{defined here}}
|
|
defer { print(x) } //expected-error{{constant 'x' used before being initialized}}
|
|
|
|
if a {
|
|
x = t
|
|
return
|
|
}
|
|
}
|
|
|
|
func bas<T>(a: Bool, t: T) {
|
|
let x: T
|
|
defer { print(x) }
|
|
|
|
if a {
|
|
x = t
|
|
return
|
|
}
|
|
|
|
x = t
|
|
}
|