diff --git a/test/Interop/C/struct/Inputs/NoncopyableStructs.apinotes b/test/Interop/C/struct/Inputs/NoncopyableStructs.apinotes new file mode 100644 index 0000000000000..44bf09e74da51 --- /dev/null +++ b/test/Interop/C/struct/Inputs/NoncopyableStructs.apinotes @@ -0,0 +1,6 @@ +--- +Name: NoncopyableStructs +Tags: +- Name: NonCopyableWithAPINotesDeinit + SwiftCopyable: false + SwiftDestroyOp: freeNonCopyableWithAPINotesDeinit diff --git a/test/Interop/C/struct/Inputs/noncopyable-struct.h b/test/Interop/C/struct/Inputs/noncopyable-struct.h index 321a86469e6b4..71be2de1361ef 100644 --- a/test/Interop/C/struct/Inputs/noncopyable-struct.h +++ b/test/Interop/C/struct/Inputs/noncopyable-struct.h @@ -8,6 +8,10 @@ typedef struct SWIFT_NONCOPYABLE_WITH_DESTROY(freeNonCopyableWithDeinit) NonCopy void *storage; } NonCopyableWithDeinit; +typedef struct NonCopyableWithAPINotesDeinit { + void *storage; +} NonCopyableWithAPINotesDeinit; + typedef struct __attribute__((swift_attr("destroy:freeCopyableType"))) CopyableType { void *storage; } CopyableType; @@ -29,6 +33,7 @@ extern "C" { #endif void freeNonCopyableWithDeinit(NonCopyableWithDeinit ncd); +void freeNonCopyableWithAPINotesDeinit(NonCopyableWithAPINotesDeinit ncd); void freeCopyableType(CopyableType ct); diff --git a/test/Interop/C/struct/noncopyable_structs.swift b/test/Interop/C/struct/noncopyable_structs.swift index 082632ffffac6..d4700fdab74ad 100644 --- a/test/Interop/C/struct/noncopyable_structs.swift +++ b/test/Interop/C/struct/noncopyable_structs.swift @@ -26,11 +26,17 @@ func testNC() { let nc = NonCopyable() // expected-error{{'nc' consumed more than once}} consumeNC(nc) // expected-note{{consumed here}} + let ncAPI = NonCopyableWithAPINotesDeinit() // expected-error{{consumed more than once}} + consumeNCAPI(ncAPI) // expected-note{{consumed here}} + #if ERRORS consumeNC(nc) // expected-note{{consumed again here}} + consumeNCAPI(ncAPI) // expected-note{{consumed again here}} #endif } +func consumeNCAPI(_ nc: consuming NonCopyableWithAPINotesDeinit) { } + func consumeNCWithDeinit(_ nc: consuming NonCopyableWithDeinit) { } func testNCWithDeinit() {