Skip to content

Commit e0fca6c

Browse files
authored
Merge pull request #36491 from ahoppen/pr/rdar64304839
[SourceKit] Fix crash in syntax model
2 parents c5a7512 + 5d91635 commit e0fca6c

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,7 +2329,13 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
23292329
if (Status.isErrorOrHasCompletion())
23302330
return false;
23312331

2332-
AttrRange = SourceRange(Loc, Tok.getLoc());
2332+
if (!consumeIf(tok::r_paren)) {
2333+
diagnose(Tok.getLoc(), diag::attr_expected_rparen, AttrName,
2334+
DeclAttribute::isDeclModifier(DK));
2335+
return false;
2336+
}
2337+
2338+
AttrRange = SourceRange(Loc, PreviousLoc);
23332339
// For each platform version spec in the spec list, create an
23342340
// implicit AvailableAttr for the platform with the introduced
23352341
// version from the spec. For example, if we have
@@ -2393,12 +2399,6 @@ bool Parser::parseNewDeclAttribute(DeclAttributes &Attributes, SourceLoc AtLoc,
23932399
/*Implicit=*/false));
23942400
}
23952401

2396-
if (!consumeIf(tok::r_paren)) {
2397-
diagnose(Tok.getLoc(), diag::attr_expected_rparen, AttrName,
2398-
DeclAttribute::isDeclModifier(DK));
2399-
return false;
2400-
}
2401-
24022402
break;
24032403
}
24042404

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %sourcekitd-test -req=open %s -- %s
2+
// Test that this doesn't crash sourcekitd
3+
4+
@available(macOS 10.12
5+
@available(macOS 10.13
6+
func foo() {} {code}

0 commit comments

Comments
 (0)