1
1
2
2
// RUN: rm -rf %t
3
3
// RUN: split-file %s %t
4
- // RUN: %target-swift-frontend -typecheck -verify -I %swift_src_root/lib/ClangImporter/SwiftBridging - I %t/Inputs %t/test.swift -enable-experimental-feature AllowUnsafeAttribute -enable-experimental-feature WarnUnsafe -enable-experimental-feature SafeInterop -cxx-interoperability-mode=default -diagnostic-style llvm 2>&1
4
+ // RUN: %target-swift-frontend -typecheck -verify -I %swift_src_root/lib/ClangImporter/SwiftBridging -Xcc -std=c++20 - I %t/Inputs %t/test.swift -enable-experimental-feature AllowUnsafeAttribute -enable-experimental-feature WarnUnsafe -enable-experimental-feature SafeInterop -enable-experimental-feature LifetimeDependence -cxx-interoperability-mode=default -diagnostic-style llvm 2>&1
5
5
6
6
// REQUIRES: objc_interop
7
7
// REQUIRES: swift_feature_AllowUnsafeAttribute
8
8
// REQUIRES: swift_feature_SafeInterop
9
9
// REQUIRES: swift_feature_WarnUnsafe
10
+ // REQUIRES: swift_feature_LifetimeDependence
10
11
11
12
//--- Inputs/module.modulemap
12
13
module Test {
@@ -16,6 +17,7 @@ module Test {
16
17
17
18
//--- Inputs/nonescapable.h
18
19
#include " swift/bridging "
20
+ #include < span>
19
21
20
22
struct SWIFT_NONESCAPABLE View {
21
23
__attribute__ ( ( swift_attr ( " @lifetime(immortal) " ) ) )
@@ -50,6 +52,9 @@ struct MyContainer {
50
52
int end( ) const { return - 1 ; }
51
53
} ;
52
54
55
+ using SpanOfInt = Unannotated;
56
+ using SpanOfIntAlias = SpanOfInt;
57
+
53
58
//--- test.swift
54
59
55
60
import Test
@@ -75,3 +80,11 @@ func useSafeParams(x: Owner, y: View, z: SafeEscapableAggregate, c: MyContainer)
75
80
76
81
func useCfType( x: CFArray ) {
77
82
}
83
+
84
+ // expected-note@+1{{make global function 'useCppSpan' @unsafe to indicate that its use is not memory-safe}}
85
+ func useCppSpan( x: SpanOfInt ) { // expected-warning{{reference to unsafe type alias 'SpanOfInt'}}
86
+ }
87
+
88
+ // expected-note@+1{{make global function 'useCppSpan2' @unsafe to indicate that its use is not memory-safe}}
89
+ func useCppSpan2( x: SpanOfIntAlias ) { // expected-warning{{reference to unsafe type alias 'SpanOfIntAlias'}}
90
+ }
0 commit comments