diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 18712bf1b96b6..a90887793eced 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -1525,12 +1525,15 @@ bool Decl::isAlwaysWeakImported() const { return clangDecl->isWeakImported( getASTContext().LangOpts.getMinPlatformVersion()); + // FIXME: Weak linking on Windows is not yet supported + // https://github.com/apple/swift/issues/53303 + if (getASTContext().LangOpts.Target.isOSWindows()) + return false; + if (getAttrs().hasAttribute()) return true; - // FIXME: Weak linking on Windows is not yet supported - // https://github.com/apple/swift/issues/53303 - if (isUnavailable() && !getASTContext().LangOpts.Target.isOSWindows()) + if (isUnavailable()) return true; if (auto *accessor = dyn_cast(this)) diff --git a/test/SILGen/availability_windows.swift b/test/SILGen/availability_windows.swift new file mode 100644 index 0000000000000..0afbfc892a30c --- /dev/null +++ b/test/SILGen/availability_windows.swift @@ -0,0 +1,31 @@ +// RUN: %target-swift-emit-silgen %s -target %target-cpu-unknown-windows-msvc | %FileCheck %s +// REQUIRES: OS=windows-msvc + +@_silgen_name("windows10") +@available(Windows 10, *) +public func windows10() + +@_silgen_name("unavailable") +@available(Windows, unavailable) +public func unavailable() + + +// CHECK-LABEL: sil [ossa] @$s20availability_windows15testIfAvailableyyF : $@convention(thin) () -> () +// CHECK: cond_br +// CHECK: function_ref @windows10 +public func testIfAvailable() { + if #available(Windows 10, *) { + windows10() + } +} +// CHECK: sil [available 10] @windows10 : $@convention(thin) () -> () + +// CHECK-LABEL: sil [ossa] @$s20availability_windows15testUnavailableyyF : $@convention(thin) () -> () +// CHECK: function_ref @unavailable +@available(*, unavailable) +public func testUnavailable() { + unavailable() +} + +// FIXME: Mark [weak_imported] when weak linking is supported on Windows (https://github.com/apple/swift/issues/53303) +// CHECK: sil @unavailable : $@convention(thin) () -> ()