mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The lifetimebound annotations are now imported as lifetime dependencies. This works for basic cases but there are still some parts missing: * Support lifeitmebound annotations on constructors * A way to represent immortal/static lifetimes on the C++ side
30 lines
866 B
Swift
30 lines
866 B
Swift
// RUN: rm -rf %t
|
|
// RUN: split-file %s %t
|
|
// RUN: not %target-swift-frontend -typecheck -I %swift_src_root/lib/ClangImporter/SwiftBridging -I %t/Inputs %t/test.swift -enable-experimental-feature NonescapableTypes -cxx-interoperability-mode=default -diagnostic-style llvm 2>&1 | %FileCheck %s
|
|
|
|
//--- Inputs/module.modulemap
|
|
module Test {
|
|
header "nonescapable.h"
|
|
requires cplusplus
|
|
}
|
|
|
|
//--- Inputs/nonescapable.h
|
|
#include "swift/bridging"
|
|
|
|
struct SWIFT_NONESCAPABLE View {
|
|
View() : member(nullptr) {}
|
|
View(const int *p [[clang::lifetimebound]]) : member(p) {}
|
|
View(const View&) = default;
|
|
private:
|
|
const int *member;
|
|
};
|
|
|
|
//--- test.swift
|
|
|
|
import Test
|
|
|
|
// CHECK: error: cannot infer lifetime dependence, no parameters found that are either ~Escapable or Escapable with a borrowing ownership
|
|
public func noAnnotations() -> View {
|
|
View()
|
|
}
|