Skip to content

Commit 0ac53e3

Browse files
committed
Sema: Only warn about @_originallyDefinedIn attributes on non-public decls for the active platform. This prevents diagnostic spam for the common case where multiple platforms are listed in the same attribute. This has the unfortunate side effect that some useful diagnostics will be skipped depending on target platform, but it makes the behavior of this diagnostic consistent with the rest for this attribute.
Resolves rdar://90779221.
1 parent 3f37fc0 commit 0ac53e3

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3475,11 +3475,12 @@ void AttributeChecker::checkOriginalDefinedInAttrs(
34753475
for (auto *Attr: Attrs) {
34763476
static StringRef AttrName = "_originallyDefinedIn";
34773477

3478-
if (diagnoseAndRemoveAttrIfDeclIsNonPublic(Attr, /*isError=*/false))
3478+
if (!Attr->isActivePlatform(Ctx))
34793479
continue;
34803480

3481-
if (!Attr->isActivePlatform(Ctx))
3481+
if (diagnoseAndRemoveAttrIfDeclIsNonPublic(Attr, /*isError=*/false))
34823482
continue;
3483+
34833484
auto AtLoc = Attr->AtLoc;
34843485
auto Platform = Attr->Platform;
34853486
if (!seenPlatforms.insert({Platform, AtLoc}).second) {

test/Parse/original_defined_in_attr.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,19 @@ public class ToplevelClass4 {
3434

3535
@available(OSX 13.10, *)
3636
@_originallyDefinedIn(module: "foo", OSX 13.13) // expected-warning {{'@_originallyDefinedIn' does not have any effect on internal declarations}}
37-
@_originallyDefinedIn(module: "foo", iOS 7.0) // expected-warning {{'@_originallyDefinedIn' does not have any effect on internal declarations}}
37+
@_originallyDefinedIn(module: "foo", iOS 7.0)
3838
internal class ToplevelClass5 {}
3939

4040
@available(OSX 13.10, *)
4141
@_originallyDefinedIn(module: "foo", OSX 13.13) // expected-warning {{'@_originallyDefinedIn' does not have any effect on private declarations}}
42-
@_originallyDefinedIn(module: "foo", iOS 7.0) // expected-warning {{'@_originallyDefinedIn' does not have any effect on private declarations}}
42+
@_originallyDefinedIn(module: "foo", iOS 7.0)
4343
private class ToplevelClass6 {}
4444

4545
@available(OSX 13.10, *)
4646
@_originallyDefinedIn(module: "foo", OSX 13.13) // expected-warning {{'@_originallyDefinedIn' does not have any effect on fileprivate declarations}}
47-
@_originallyDefinedIn(module: "foo", iOS 7.0) // expected-warning {{'@_originallyDefinedIn' does not have any effect on fileprivate declarations}}
47+
@_originallyDefinedIn(module: "foo", iOS 7.0)
4848
fileprivate class ToplevelClass7 {}
49+
50+
@available(OSX 13.10, *)
51+
@_originallyDefinedIn(module: "foo", OSX 13.13, iOS 7.0) // expected-warning {{'@_originallyDefinedIn' does not have any effect on internal declarations}}
52+
internal class ToplevelClass8 {}

0 commit comments

Comments
 (0)