diff --git a/test/Interop/Cxx/class/Inputs/simple-structs.h b/test/Interop/Cxx/class/Inputs/simple-structs.h index b8a6a4f4d034f..cdda0654dbb5f 100644 --- a/test/Interop/Cxx/class/Inputs/simple-structs.h +++ b/test/Interop/Cxx/class/Inputs/simple-structs.h @@ -52,38 +52,4 @@ struct Outer { Outer() : privStruct(1, 2, 3, 4, 5, 6), publStruct(7, 8, 9, 10, 11, 12) {} }; -struct ImmortalFRT { -private: - int priv = 1; - -public: - int publ = 2; -} __attribute__((swift_attr("import_reference"))) -__attribute__((swift_attr("retain:immortal"))) -__attribute__((swift_attr("release:immortal"))); - -struct FRTCustomStringConvertible { -public: -private: - int priv = 1; - -public: - int publ = 2; -} __attribute__((swift_attr("import_reference"))) -__attribute__((swift_attr("retain:immortal"))) -__attribute__((swift_attr("release:immortal"))); - -struct FRType { -private: - int priv = 1; - -public: - int publ = 2; -} __attribute__((swift_attr("import_reference"))) -__attribute__((swift_attr("retain:retain"))) -__attribute__((swift_attr("release:release"))); - -void retain(FRType *v) {}; -void release(FRType *v) {}; - #endif diff --git a/test/Interop/Cxx/class/print-simple-structs.swift b/test/Interop/Cxx/class/print-simple-structs.swift index 3bd7cef362440..27088944d40d0 100644 --- a/test/Interop/Cxx/class/print-simple-structs.swift +++ b/test/Interop/Cxx/class/print-simple-structs.swift @@ -1,8 +1,6 @@ -// RUN: %target-run-simple-swift(-cxx-interoperability-mode=default -Xfrontend -disable-availability-checking -I %S/Inputs) | %FileCheck %s +// RUN: %target-run-simple-swift(-cxx-interoperability-mode=default -I %S/Inputs) | %FileCheck %s // REQUIRES: executable_test -// Metadata for foreign reference types is not supported on Windows. -// UNSUPPORTED: OS=windows-msvc import SimpleStructs @@ -26,28 +24,6 @@ func printCxxStructNested() { print(s) } -func printCxxImmortalFRT() { - let s = ImmortalFRT() - print(s) -} - -extension FRTCustomStringConvertible : CustomStringConvertible { - public var description: String { - return "FRTCustomStringConvertible(publ: \(publ))" - } -} - -func printCxxFRTCustomStringConvertible() { - let s = FRTCustomStringConvertible() - print(s) -} - -func printCxxFRType() { - let s = FRType() - print(s) -} - - printCxxStructPrivateFields() // CHECK: HasPrivateFieldsOnly() @@ -59,12 +35,3 @@ printCxxStructPrivatePublicProtectedFields() printCxxStructNested() // CHECK: Outer(publStruct: {{.*}}.HasPrivatePublicProtectedFields(publ1: 8, publ2: 12)) - -printCxxImmortalFRT() -// CHECK: ImmortalFRT() - -printCxxFRTCustomStringConvertible() -// CHECK: FRTCustomStringConvertible(publ: 2) - -printCxxFRType() -// CHECK: FRType() diff --git a/test/Interop/Cxx/foreign-reference/Inputs/module.modulemap b/test/Interop/Cxx/foreign-reference/Inputs/module.modulemap index 847fa63a5f398..9b85e2ec69e4c 100644 --- a/test/Interop/Cxx/foreign-reference/Inputs/module.modulemap +++ b/test/Interop/Cxx/foreign-reference/Inputs/module.modulemap @@ -63,3 +63,8 @@ module FunctionsAndMethodsReturningFRT { header "cxx-functions-and-methods-returning-frt.h" requires cplusplus } + +module Printed { + header "printed.h" + requires cplusplus +} diff --git a/test/Interop/Cxx/foreign-reference/Inputs/printed.h b/test/Interop/Cxx/foreign-reference/Inputs/printed.h new file mode 100644 index 0000000000000..9f486cbdd3d52 --- /dev/null +++ b/test/Interop/Cxx/foreign-reference/Inputs/printed.h @@ -0,0 +1,34 @@ +struct ImmortalFRT { +private: + int priv = 1; + +public: + int publ = 2; +} __attribute__((swift_attr("import_reference"))) +__attribute__((swift_attr("retain:immortal"))) +__attribute__((swift_attr("release:immortal"))); + +struct FRTCustomStringConvertible { +public: +private: + int priv = 1; + +public: + int publ = 2; +} __attribute__((swift_attr("import_reference"))) +__attribute__((swift_attr("retain:immortal"))) +__attribute__((swift_attr("release:immortal"))); + +struct FRType { +private: + int priv = 1; + +public: + int publ = 2; +} __attribute__((swift_attr("import_reference"))) +__attribute__((swift_attr("retain:retain"))) +__attribute__((swift_attr("release:release"))); + +void retain(FRType *v) {}; +void release(FRType *v) {}; + diff --git a/test/Interop/Cxx/foreign-reference/print-reference.swift b/test/Interop/Cxx/foreign-reference/print-reference.swift new file mode 100644 index 0000000000000..4294689d32885 --- /dev/null +++ b/test/Interop/Cxx/foreign-reference/print-reference.swift @@ -0,0 +1,55 @@ +// RUN: %target-run-simple-swift(-cxx-interoperability-mode=default -I %S/Inputs) | %FileCheck %s + +// REQUIRES: executable_test + +// Metadata for foreign reference types is not supported on Windows. +// UNSUPPORTED: OS=windows-msvc + +// Temporarily disable when running with an older runtime (rdar://153205860) +// UNSUPPORTED: use_os_stdlib +// UNSUPPORTED: back_deployment_runtime + +import Printed + +func printCxxImmortalFRT() { + if #available(SwiftStdlib 6.2, *) { + let s = ImmortalFRT() + print(s) + } else { + print("runtime too old") + } +} + +@available(SwiftStdlib 5.9, *) +extension FRTCustomStringConvertible : CustomStringConvertible { + public var description: String { + return "FRTCustomStringConvertible(publ: \(publ))" + } +} + +func printCxxFRTCustomStringConvertible() { + if #available(SwiftStdlib 5.9, *) { + let s = FRTCustomStringConvertible() + print(s) + } else { + print("runtime too old") + } +} + +func printCxxFRType() { + if #available(SwiftStdlib 6.2, *) { + let s = FRType() + print(s) + } else { + print("runtime too old") + } +} + +printCxxImmortalFRT() +// CHECK: {{ImmortalFRT()|runtime too old}} + +printCxxFRTCustomStringConvertible() +// CHECK: FRTCustomStringConvertible(publ: 2) + +printCxxFRType() +// CHECK: {{FRType()|runtime too old}}