Skip to content

Commit 7a500a1

Browse files
committed
stdlib: Float16 needs an @available annotation for macOS
Even though Float16 is unavailable on macOS, the type metadata can still be referenced, for example from another unavailable declaration. Make sure it has the correct OS version annotation so that it can be weak linked. Part of <rdar://problem/72151067>.
1 parent 37d52fb commit 7a500a1

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

stdlib/public/core/FloatingPointTypes.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,7 @@ extension ${Self} : ConcurrentValue { }
13561356
${SelfDocComment}
13571357
@frozen
13581358
% if bits == 16:
1359-
@available(iOS 14, tvOS 14, watchOS 7, *)
1359+
@available(macOS 11, iOS 14, tvOS 14, watchOS 7, *)
13601360
@available(macOS, unavailable)
13611361
@available(macCatalyst, unavailable)
13621362
% else:

test/IRGen/float16_macos.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %target-swift-frontend -emit-ir %s -target x86_64-apple-macos10.15 | %FileCheck %s --check-prefix=CHECK10
2+
// RUN: %target-swift-frontend -emit-ir %s -target x86_64-apple-macos11 | %FileCheck %s --check-prefix=CHECK11
3+
4+
// REQUIRES: OS=macosx
5+
// REQUIRES: CPU=x86_64
6+
// UNSUPPORTED: use_os_stdlib
7+
8+
@available(macOS 11, *)
9+
public struct Float16Wrapper {
10+
@available(macOS, unavailable)
11+
var x: Float16
12+
}
13+
14+
// CHECK10-LABEL: @"$ss7Float16VMn" = extern_weak global %swift.type_descriptor
15+
// CHECK11-LABEL: @"$ss7Float16VMn" = external global %swift.type_descriptor

0 commit comments

Comments
 (0)