Skip to content

Commit 42e554e

Browse files
committed
[Parse] Set AttrRange for @nonisolated
Make sure we set the `AttrRange` in cases where `@` is present, but `unsafe` isn't present. rdar://147965036
1 parent ec64114 commit 42e554e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3741,6 +3741,7 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
37413741
break;
37423742
}
37433743
case DeclAttrKind::Nonisolated: {
3744+
AttrRange = Loc;
37443745
std::optional<bool> isUnsafe(false);
37453746
if (EnableParameterizedNonisolated) {
37463747
isUnsafe =

test/Concurrency/nonisolated_rules.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,12 @@ struct UnsafeInitialization {
177177
self.ns = ns // okay
178178
}
179179
}
180+
181+
// rdar://147965036 - Make sure we don't crash.
182+
func rdar147965036() {
183+
func test(_: () -> Void) {}
184+
test { @nonisolated in
185+
// expected-error@-1 {{'nonisolated' is a declaration modifier, not an attribute}}
186+
// expected-error@-2 {{'nonisolated' is not supported on a closure}}
187+
}
188+
}

0 commit comments

Comments
 (0)