Skip to content

Commit 3d8001f

Browse files
committed
Move diagnostic about @_weakLinked not working for COFF into the type checker
This allows us to use `@_weakLinked` inside of a `#if` properly.
1 parent 8c452b5 commit 3d8001f

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2873,14 +2873,6 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
28732873
DiscardAttribute = true;
28742874
}
28752875

2876-
if (Context.LangOpts.Target.isOSBinFormatCOFF()) {
2877-
if (DK == DeclAttrKind::WeakLinked) {
2878-
diagnose(Loc, diag::attr_unsupported_on_target, AttrName,
2879-
Context.LangOpts.Target.str());
2880-
DiscardAttribute = true;
2881-
}
2882-
}
2883-
28842876
if (DK == DeclAttrKind::ResultDependsOnSelf &&
28852877
!Context.LangOpts.hasFeature(Feature::NonescapableTypes)) {
28862878
diagnose(Loc, diag::requires_experimental_feature, AttrName, true,

lib/Sema/TypeCheckAttr.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
147147
IGNORED_ATTR(StaticInitializeObjCMetadata)
148148
IGNORED_ATTR(SynthesizedProtocol)
149149
IGNORED_ATTR(Testable)
150-
IGNORED_ATTR(WeakLinked)
151150
IGNORED_ATTR(PrivateImport)
152151
IGNORED_ATTR(DisfavoredOverload)
153152
IGNORED_ATTR(ProjectedValueProperty)
@@ -368,6 +367,7 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
368367
void visitUnsafeNonEscapableResultAttr(UnsafeNonEscapableResultAttr *attr);
369368

370369
void visitStaticExclusiveOnlyAttr(StaticExclusiveOnlyAttr *attr);
370+
void visitWeakLinkedAttr(WeakLinkedAttr *attr);
371371
};
372372

373373
} // end anonymous namespace
@@ -7342,6 +7342,13 @@ void AttributeChecker::visitStaticExclusiveOnlyAttr(
73427342
}
73437343
}
73447344

7345+
void AttributeChecker::visitWeakLinkedAttr(WeakLinkedAttr *attr) {
7346+
if (Ctx.LangOpts.Target.isOSBinFormatCOFF()) {
7347+
diagnoseAndRemoveAttr(attr, diag::attr_unsupported_on_target, AttrName,
7348+
Context.LangOpts.Target.str());
7349+
}
7350+
}
7351+
73457352
namespace {
73467353

73477354
class ClosureAttributeChecker

test/attr/attr_weaklinked.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %target-typecheck-verify-swift
2+
3+
#if !os(Windows)
4+
@_weakLinked public func f() { }
5+
#endif
6+

0 commit comments

Comments
 (0)