Skip to content

Commit 062be8f

Browse files
committed
Exclusivity test case for NS_NOESCAPE import.
<rdar://problem/36989789> [SR-6862]: "Unexpected partial_apply use".
1 parent aa0fd33 commit 062be8f

File tree

4 files changed

+18
-1
lines changed

4 files changed

+18
-1
lines changed

test/Inputs/clang-importer-sdk/usr/include/CoreFoundation.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,6 @@ extern CFIndex CFIndex_test;
2727
#define CF_ENUM(_type, _name) enum _name : _type _name; enum _name : _type
2828
#define CF_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type
2929

30+
#define CF_NOESCAPE __attribute__((noescape))
31+
3032
#endif

test/Inputs/clang-importer-sdk/usr/include/Foundation.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
1212

13+
#define NS_NOESCAPE CF_NOESCAPE
1314

1415
typedef struct objc_object { void *isa; } *id;
1516

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include "Foundation.h"
2+
3+
@interface SomeObjCInterface
4+
5+
+ (void)perform:(long * _Nonnull)val f:(void (NS_NOESCAPE ^ _Nullable)(void))block;
6+
7+
@end

test/SILOptimizer/exclusivity_static_diagnostics_objc.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -enforce-exclusivity=checked -swift-version 4 -emit-sil -primary-file %s -o /dev/null -verify
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -import-objc-header %S/Inputs/optional_closure_bridging.h -enforce-exclusivity=checked -swift-version 4 -emit-sil -primary-file %s -o /dev/null -verify
22
// REQUIRES: objc_interop
33

44
import Foundation
@@ -9,3 +9,10 @@ class SomeClass {
99
c()
1010
}
1111
}
12+
13+
func testOptionalImport() {
14+
var x = 0
15+
// expected-warning@+2{{overlapping accesses to 'x', but modification requires exclusive access; consider copying to a local variable}}
16+
// expected-note@+1{{conflicting access is here}}
17+
SomeObjCInterface.perform(&x) { x += 1 }
18+
}

0 commit comments

Comments
 (0)