From 501cc36462b3799e958754a0ef4fd90d5d388f3c Mon Sep 17 00:00:00 2001 From: Gabor Horvath Date: Fri, 28 Nov 2025 14:48:24 +0000 Subject: [PATCH] [cxx-interop] Suppress warning in non-arc Obj-C++ We have some arc specific casts in our generated headers that can trigger some warnings in non-arc Obj-C++ code. These casts are noop in that case so it is fine to have them there. And we do want them as we want the code to be compatible both with arc and non-arc code. rdar://163281971 --- lib/PrintAsClang/PrintAsClang.cpp | 2 ++ .../SwiftToObjCxx/optional-objc-class-in-obj-cxx.swift | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/lib/PrintAsClang/PrintAsClang.cpp b/lib/PrintAsClang/PrintAsClang.cpp index 4b2da77f444..87cd3e64cf6 100644 --- a/lib/PrintAsClang/PrintAsClang.cpp +++ b/lib/PrintAsClang/PrintAsClang.cpp @@ -567,6 +567,8 @@ static void writePostImportPrologue(raw_ostream &os, ModuleDecl &M) { "#pragma clang diagnostic ignored \"-Wunknown-pragmas\"\n" "#pragma clang diagnostic ignored \"-Wnullability\"\n" "#pragma clang diagnostic ignored " + "\"-Warc-bridge-casts-disallowed-in-nonarc\"\n" + "#pragma clang diagnostic ignored " "\"-Wdollar-in-identifier-extension\"\n" "#pragma clang diagnostic ignored " "\"-Wunsafe-buffer-usage\"\n" diff --git a/test/Interop/SwiftToObjCxx/optional-objc-class-in-obj-cxx.swift b/test/Interop/SwiftToObjCxx/optional-objc-class-in-obj-cxx.swift index ba8f073aa19..f82fb4c6193 100644 --- a/test/Interop/SwiftToObjCxx/optional-objc-class-in-obj-cxx.swift +++ b/test/Interop/SwiftToObjCxx/optional-objc-class-in-obj-cxx.swift @@ -2,6 +2,7 @@ // RUN: %target-swift-frontend %s -module-name UseCoreFoundation -enable-experimental-cxx-interop -clang-header-expose-decls=all-public -typecheck -verify -emit-clang-header-path %t/UseCoreFoundation.h // RUN: %target-interop-build-clangxx -std=gnu++20 -fobjc-arc -c -x objective-c++-header %t/UseCoreFoundation.h -o %t/o.o +// RUN: %target-interop-build-clangxx -Werror=arc-bridge-casts-disallowed-in-nonarc -std=gnu++20 -fno-objc-arc -c -x objective-c++-header %t/UseCoreFoundation.h -o %t/o.o // REQUIRES: objc_interop @@ -14,3 +15,7 @@ public class TestFoundationType { _bundle = bundle } } + +public func getArray() -> [String] { + [] +}