blob: 9e36836ddfb8e9fa0bf8f5d6cbe782e2e664fe6c [file] [log] [blame]
// RUN: %empty-directory(%t)
// RUN: %target-build-swift -O %s -import-objc-header %S/Inputs/dse_with_union.h -o %t/a.out
// RUN: %target-codesign %t/a.out
// RUN: %target-run %t/a.out | %FileCheck %s
// REQUIRES: executable_test
// Check that EscapeAnalysis does not mess up with a union.
@inline(never)
func printit(_ u: inout U) {
print(u.p![0])
}
@inline(never)
func testit(s: S) {
var vs = s
withUnsafeMutablePointer(to: &vs) {
// A C union is an opaque type in swift and not considered as a "pointer"
// in escape analysis. Converting between pointer and non-pointer resulted
// in a wrong connection graph.
var u = U(p: $0)
printit(&u)
}
}
// CHECK: S(i: 27)
testit(s: S(i: 27))