|
1 | 1 | // RUN: %empty-directory(%t) |
2 | | -// RUN: %target-swift-frontend -enable-experimental-feature LayoutStringValueWitnesses -enable-layout-string-value-witnesses -parse-stdlib -emit-module -emit-module-path=%t/layout_string_witnesses_types.swiftmodule %S/Inputs/layout_string_witnesses_types.swift |
| 2 | +// RUN: %target-swift-frontend -I %S/Inputs/CTypes -enable-experimental-feature LayoutStringValueWitnesses -enable-layout-string-value-witnesses -parse-stdlib -emit-module -emit-module-path=%t/layout_string_witnesses_types.swiftmodule %S/Inputs/layout_string_witnesses_types.swift |
3 | 3 |
|
4 | 4 | // NOTE: We have to build this as dylib to turn private external symbols into local symbols, so we can observe potential issues with linkage |
5 | | -// RUN: %target-build-swift-dylib(%t/%target-library-name(layout_string_witnesses_types)) -Xfrontend -enable-experimental-feature -Xfrontend LayoutStringValueWitnesses -Xfrontend -enable-layout-string-value-witnesses -Xfrontend -parse-stdlib -parse-as-library %S/Inputs/layout_string_witnesses_types.swift |
| 5 | +// RUN: %target-build-swift-dylib(%t/%target-library-name(layout_string_witnesses_types)) -I %S/Inputs/CTypes -Xfrontend -enable-experimental-feature -Xfrontend LayoutStringValueWitnesses -Xfrontend -enable-layout-string-value-witnesses -Xfrontend -parse-stdlib -parse-as-library %S/Inputs/layout_string_witnesses_types.swift |
6 | 6 | // RUN: %target-codesign %t/%target-library-name(layout_string_witnesses_types) |
7 | 7 | // RUN: %target-swift-frontend -enable-experimental-feature LayoutStringValueWitnesses -enable-layout-string-value-witnesses -enable-library-evolution -emit-module -emit-module-path=%t/layout_string_witnesses_types_resilient.swiftmodule %S/Inputs/layout_string_witnesses_types_resilient.swift |
8 | 8 | // RUN: %target-build-swift -g -Xfrontend -enable-experimental-feature -Xfrontend LayoutStringValueWitnesses -Xfrontend -enable-layout-string-value-witnesses -Xfrontend -enable-library-evolution -c -parse-as-library -o %t/layout_string_witnesses_types_resilient.o %S/Inputs/layout_string_witnesses_types_resilient.swift |
@@ -1180,6 +1180,49 @@ func testMultiPayloadError() { |
1180 | 1180 |
|
1181 | 1181 | testMultiPayloadError() |
1182 | 1182 |
|
| 1183 | +func testCTypeAligned() { |
| 1184 | + let ptr = UnsafeMutablePointer<CTypeAligned>.allocate(capacity: 1) |
| 1185 | + |
| 1186 | + // initWithCopy |
| 1187 | + do { |
| 1188 | + let x = CTypeAligned(SimpleClass(x: 23)) |
| 1189 | + testInit(ptr, to: x) |
| 1190 | + } |
| 1191 | + |
| 1192 | + // assignWithTake |
| 1193 | + do { |
| 1194 | + let y = CTypeAligned(SimpleClass(x: 1)) |
| 1195 | + |
| 1196 | + // CHECK-NEXT: Before deinit |
| 1197 | + print("Before deinit") |
| 1198 | + |
| 1199 | + // CHECK-NEXT: SimpleClass deinitialized! |
| 1200 | + testAssign(ptr, from: y) |
| 1201 | + } |
| 1202 | + |
| 1203 | + // assignWithCopy |
| 1204 | + do { |
| 1205 | + var z = CTypeAligned(SimpleClass(x: 5)) |
| 1206 | + |
| 1207 | + // CHECK-NEXT: Before deinit |
| 1208 | + print("Before deinit") |
| 1209 | + |
| 1210 | + // CHECK-NEXT: SimpleClass deinitialized! |
| 1211 | + testAssignCopy(ptr, from: &z) |
| 1212 | + } |
| 1213 | + |
| 1214 | + // CHECK-NEXT: Before deinit |
| 1215 | + print("Before deinit") |
| 1216 | + |
| 1217 | + // destroy |
| 1218 | + // CHECK-NEXT: SimpleClass deinitialized! |
| 1219 | + testDestroy(ptr) |
| 1220 | + |
| 1221 | + ptr.deallocate() |
| 1222 | +} |
| 1223 | + |
| 1224 | +testCTypeAligned() |
| 1225 | + |
1183 | 1226 | #if os(macOS) |
1184 | 1227 | func testObjc() { |
1185 | 1228 | let ptr = UnsafeMutablePointer<ObjcWrapper>.allocate(capacity: 1) |
|
0 commit comments