11
22// RUN: rm -rf %t
33// 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
55
66// REQUIRES: objc_interop
77// REQUIRES: swift_feature_AllowUnsafeAttribute
88// REQUIRES: swift_feature_SafeInterop
99// REQUIRES: swift_feature_WarnUnsafe
10+ // REQUIRES: swift_feature_LifetimeDependence
1011
1112//--- Inputs/module.modulemap
1213module Test {
@@ -16,6 +17,7 @@ module Test {
1617
1718//--- Inputs/nonescapable.h
1819#include " swift/bridging "
20+ #include < span>
1921
2022struct SWIFT_NONESCAPABLE View {
2123 __attribute__ ( ( swift_attr ( " @lifetime(immortal) " ) ) )
@@ -50,6 +52,9 @@ struct MyContainer {
5052 int end( ) const { return - 1 ; }
5153} ;
5254
55+ using SpanOfInt = Unannotated;
56+ using SpanOfIntAlias = SpanOfInt;
57+
5358//--- test.swift
5459
5560import Test
@@ -75,3 +80,11 @@ func useSafeParams(x: Owner, y: View, z: SafeEscapableAggregate, c: MyContainer)
7580
7681func useCfType( x: CFArray ) {
7782}
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