Files
swift-mirror/test/Interpreter/indirect_enum.swift
Stefan Gränitz 76243a25db [windows][toolchain] Build sanitizers and builtins standalone for all SDKs (#78861)
Unified builds of compiler-rt together with LLVM failed for the Android SDKs. It got too complicated to redirect the way LLVM would configure the nested build-trees. Standalone builds slightly increase build time, but they turned out much simpler and we end up with less duplication of definitions.
2025-01-28 22:08:07 +01:00

39 lines
697 B
Swift

// XFAIL: OS=windows-msvc
// RUN: %target-swiftc_driver %s -g -sanitize=address -o %t_asan-binary
// RUN: %target-codesign %t_asan-binary
// RUN: env ASAN_OPTIONS=detect_leaks=0 %target-run %t_asan-binary
// REQUIRES: executable_test
// REQUIRES: asan_runtime
// Make sure that we do not use-after-free here.
class Box<T> {
var value: T
init(_ inputValue: T) { value = inputValue }
}
enum Value<U> {
case inline(U)
indirect case box(Box<U>)
}
func evaluate<U>(_ v: Value<U>) {
switch v {
case .inline:
return print("foo")
case .box(let box):
return print("bar \(box)")
}
}
func main() {
let v = Value.box(Box<[Int]>([1, 2, 3]))
evaluate(v)
print(v)
}
main()