Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions test/Interop/C/struct/Inputs/NoncopyableStructs.apinotes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
Name: NoncopyableStructs
Tags:
- Name: NonCopyableWithAPINotesDeinit
SwiftCopyable: false
SwiftDestroyOp: freeNonCopyableWithAPINotesDeinit
5 changes: 5 additions & 0 deletions test/Interop/C/struct/Inputs/noncopyable-struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,6 +33,7 @@ extern "C" {
#endif

void freeNonCopyableWithDeinit(NonCopyableWithDeinit ncd);
void freeNonCopyableWithAPINotesDeinit(NonCopyableWithAPINotesDeinit ncd);
void freeCopyableType(CopyableType ct);


Expand Down
6 changes: 6 additions & 0 deletions test/Interop/C/struct/noncopyable_structs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down