Skip to content

Move diagnostic about @_weakLinked not working for COFF into the type checker #72015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions lib/Parse/ParseDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2873,14 +2873,6 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
DiscardAttribute = true;
}

if (Context.LangOpts.Target.isOSBinFormatCOFF()) {
if (DK == DeclAttrKind::WeakLinked) {
diagnose(Loc, diag::attr_unsupported_on_target, AttrName,
Context.LangOpts.Target.str());
DiscardAttribute = true;
}
}

if (DK == DeclAttrKind::ResultDependsOnSelf &&
!Context.LangOpts.hasFeature(Feature::NonescapableTypes)) {
diagnose(Loc, diag::requires_experimental_feature, AttrName, true,
Expand Down
10 changes: 9 additions & 1 deletion lib/Sema/TypeCheckAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
IGNORED_ATTR(StaticInitializeObjCMetadata)
IGNORED_ATTR(SynthesizedProtocol)
IGNORED_ATTR(Testable)
IGNORED_ATTR(WeakLinked)
IGNORED_ATTR(PrivateImport)
IGNORED_ATTR(DisfavoredOverload)
IGNORED_ATTR(ProjectedValueProperty)
Expand Down Expand Up @@ -368,6 +367,7 @@ class AttributeChecker : public AttributeVisitor<AttributeChecker> {
void visitUnsafeNonEscapableResultAttr(UnsafeNonEscapableResultAttr *attr);

void visitStaticExclusiveOnlyAttr(StaticExclusiveOnlyAttr *attr);
void visitWeakLinkedAttr(WeakLinkedAttr *attr);
};

} // end anonymous namespace
Expand Down Expand Up @@ -7342,6 +7342,14 @@ void AttributeChecker::visitStaticExclusiveOnlyAttr(
}
}

void AttributeChecker::visitWeakLinkedAttr(WeakLinkedAttr *attr) {
if (!Ctx.LangOpts.Target.isOSBinFormatCOFF())
return;

diagnoseAndRemoveAttr(attr, diag::attr_unsupported_on_target,
attr->getAttrName(), Ctx.LangOpts.Target.str());
}

namespace {

class ClosureAttributeChecker
Expand Down
6 changes: 6 additions & 0 deletions test/attr/attr_weaklinked.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// RUN: %target-typecheck-verify-swift

#if !os(Windows)
@_weakLinked public func f() { }
#endif