Files
swift-mirror/test/Interop/Cxx/union/anonymous-union-partly-invalid-module-interface.swift
Egor Zhdan fec48f9e63 [cxx-interop] Synthesize a deprecated zero initializer for C++ structs
When importing a C header in the C++ language mode, Clang/Swift treat C structs as C++ structs.

Currently Swift synthesizes a default initializer that zero-initializes the backing memory of the struct for C structs, but not for C++ structs.

This is causing issues in existing projects that use C libraries and rely on having the default initializer available in Swift. This change enables the synthesis of a default initializer for C++ structs. Since many C++ structs are not designed to be initialized this way, the initializer is marked as deprecated in Swift.

rdar://109727620
2023-05-31 13:41:25 +01:00

11 lines
450 B
Swift

// RUN: %target-swift-ide-test -print-module -module-to-print=AnonymousUnionPartlyInvalid -I %S/Inputs -source-filename=x -enable-experimental-cxx-interop -enable-objc-interop | %FileCheck %s
// CHECK: class C {
// CHECK-NEXT: }
// CHECK-NEXT: struct S {
// CHECK-NEXT: @available(*, deprecated, message
// CHECK-NEXT: init()
// CHECK-NEXT: mutating func f() -> Int32
// CHECK-NEXT: }
// CHECK-NEXT: func getSPtr() -> UnsafeMutablePointer<S>!