Skip to content

Commit 6fbc06e

Browse files
authored
Merge pull request #72015 from DougGregor/attr-weaklinked-coff-ifdef
Move diagnostic about `@_weakLinked` not working for COFF into the type checker
2 parents 78df826 + 9e3e6e8 commit 6fbc06e

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-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: 9 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,14 @@ void AttributeChecker::visitStaticExclusiveOnlyAttr(
73427342
}
73437343
}
73447344

7345+
void AttributeChecker::visitWeakLinkedAttr(WeakLinkedAttr *attr) {
7346+
if (!Ctx.LangOpts.Target.isOSBinFormatCOFF())
7347+
return;
7348+
7349+
diagnoseAndRemoveAttr(attr, diag::attr_unsupported_on_target,
7350+
attr->getAttrName(), Ctx.LangOpts.Target.str());
7351+
}
7352+
73457353
namespace {
73467354

73477355
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)