Skip to content

Commit 9ade20a

Browse files
committed
Fix the source ranges of ill-formed precedence groups.
rdar://problem/27662943
1 parent 5291dc6 commit 9ade20a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5684,6 +5684,11 @@ Parser::parseDeclPrecedenceGroup(ParseDeclOptions flags,
56845684
return result;
56855685
};
56865686
auto createInvalid = [&] {
5687+
// Use the last consumed token location as the rbrace to satisfy
5688+
// the AST invariant about a decl's source range including all of
5689+
// its components.
5690+
if (!rbraceLoc.isValid()) rbraceLoc = PreviousLoc;
5691+
56875692
auto result = create();
56885693
result->setInvalid();
56895694
return makeParserErrorResult(result);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %target-parse-verify-swift
2+
3+
precedencegroup; // expected-error {{expected identifier}}
4+
5+
precedencegroup A; // expected-error {{expected '{'}}
6+
7+
precedencegroup B {; // expected-error {{expected operator attribute identifier}}

0 commit comments

Comments
 (0)