From 62d56067c81af13471742e38e5d8ef2c5c385340 Mon Sep 17 00:00:00 2001 From: Egor Zhdan Date: Tue, 17 Jun 2025 16:27:16 +0100 Subject: [PATCH] [cxx-interop] Disable test with an older runtime 848fad00 introduced support for printing foreign reference types. It changes both the compiler and the runtime, and having the runtime change applied is required for the test to pass. Let's not try to run it with an old runtime. This change also splits up a test for printing of value types from a test for printing of foreign reference types, since we don't have any runtime restrictions for value types. rdar://153205860 --- .../Interop/Cxx/class/Inputs/simple-structs.h | 34 --------------- .../Cxx/class/print-simple-structs.swift | 35 +--------------- .../foreign-reference/Inputs/module.modulemap | 5 +++ .../Cxx/foreign-reference/Inputs/printed.h | 34 +++++++++++++++ .../foreign-reference/print-reference.swift | 42 +++++++++++++++++++ 5 files changed, 82 insertions(+), 68 deletions(-) create mode 100644 test/Interop/Cxx/foreign-reference/Inputs/printed.h create mode 100644 test/Interop/Cxx/foreign-reference/print-reference.swift 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..1a4797b06fa6e --- /dev/null +++ b/test/Interop/Cxx/foreign-reference/print-reference.swift @@ -0,0 +1,42 @@ +// RUN: %target-run-simple-swift(-cxx-interoperability-mode=default -Xfrontend -disable-availability-checking -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() { + 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) +} + +printCxxImmortalFRT() +// CHECK: ImmortalFRT() + +printCxxFRTCustomStringConvertible() +// CHECK: FRTCustomStringConvertible(publ: 2) + +printCxxFRType() +// CHECK: FRType()