Skip to content

Commit 75faafe

Browse files
authored
Merge pull request #83671 from DougGregor/apinotes-swift-destroy-op
[Interop] Test APINotes support for noncopyable types with SwiftDestroyOp
2 parents 030564b + 73687c9 commit 75faafe

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
Name: NoncopyableStructs
3+
Tags:
4+
- Name: NonCopyableWithAPINotesDeinit
5+
SwiftCopyable: false
6+
SwiftDestroyOp: freeNonCopyableWithAPINotesDeinit

test/Interop/C/struct/Inputs/noncopyable-struct.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ typedef struct SWIFT_NONCOPYABLE_WITH_DESTROY(freeNonCopyableWithDeinit) NonCopy
88
void *storage;
99
} NonCopyableWithDeinit;
1010

11+
typedef struct NonCopyableWithAPINotesDeinit {
12+
void *storage;
13+
} NonCopyableWithAPINotesDeinit;
14+
1115
typedef struct __attribute__((swift_attr("destroy:freeCopyableType"))) CopyableType {
1216
void *storage;
1317
} CopyableType;
@@ -29,6 +33,7 @@ extern "C" {
2933
#endif
3034

3135
void freeNonCopyableWithDeinit(NonCopyableWithDeinit ncd);
36+
void freeNonCopyableWithAPINotesDeinit(NonCopyableWithAPINotesDeinit ncd);
3237
void freeCopyableType(CopyableType ct);
3338

3439

test/Interop/C/struct/noncopyable_structs.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,17 @@ func testNC() {
2626
let nc = NonCopyable() // expected-error{{'nc' consumed more than once}}
2727
consumeNC(nc) // expected-note{{consumed here}}
2828

29+
let ncAPI = NonCopyableWithAPINotesDeinit() // expected-error{{consumed more than once}}
30+
consumeNCAPI(ncAPI) // expected-note{{consumed here}}
31+
2932
#if ERRORS
3033
consumeNC(nc) // expected-note{{consumed again here}}
34+
consumeNCAPI(ncAPI) // expected-note{{consumed again here}}
3135
#endif
3236
}
3337

38+
func consumeNCAPI(_ nc: consuming NonCopyableWithAPINotesDeinit) { }
39+
3440
func consumeNCWithDeinit(_ nc: consuming NonCopyableWithDeinit) { }
3541

3642
func testNCWithDeinit() {

0 commit comments

Comments
 (0)