Skip to content

Commit 501cc36

Browse files
author
Gabor Horvath
committed
[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
1 parent 4432378 commit 501cc36

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/PrintAsClang/PrintAsClang.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,8 @@ static void writePostImportPrologue(raw_ostream &os, ModuleDecl &M) {
567567
"#pragma clang diagnostic ignored \"-Wunknown-pragmas\"\n"
568568
"#pragma clang diagnostic ignored \"-Wnullability\"\n"
569569
"#pragma clang diagnostic ignored "
570+
"\"-Warc-bridge-casts-disallowed-in-nonarc\"\n"
571+
"#pragma clang diagnostic ignored "
570572
"\"-Wdollar-in-identifier-extension\"\n"
571573
"#pragma clang diagnostic ignored "
572574
"\"-Wunsafe-buffer-usage\"\n"

test/Interop/SwiftToObjCxx/optional-objc-class-in-obj-cxx.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
// 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
44
// RUN: %target-interop-build-clangxx -std=gnu++20 -fobjc-arc -c -x objective-c++-header %t/UseCoreFoundation.h -o %t/o.o
5+
// 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
56

67
// REQUIRES: objc_interop
78

@@ -14,3 +15,7 @@ public class TestFoundationType {
1415
_bundle = bundle
1516
}
1617
}
18+
19+
public func getArray() -> [String] {
20+
[]
21+
}

0 commit comments

Comments
 (0)