Skip to content

Commit bb434eb

Browse files
committed
Check for the presence of eof before charging ahead with a brace skip
1 parent 758acaf commit bb434eb

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5618,11 +5618,12 @@ Parser::parseDeclPrecedenceGroup(ParseDeclOptions flags,
56185618
if (parseIdentifier(name, nameLoc, diag::expected_precedencegroup_name)) {
56195619
// If the identifier is missing or a keyword or something, try to skip
56205620
// skip the entire body.
5621-
if (consumeIf(tok::l_brace) ||
5622-
(peekToken().is(tok::l_brace), consumeToken(),
5623-
consumeIf(tok::l_brace))) {
5621+
if (consumeIf(tok::l_brace)) {
56245622
skipUntilDeclRBrace();
56255623
(void) consumeIf(tok::r_brace);
5624+
} else if (Tok.isNot(tok::eof) && peekToken().is(tok::l_brace)) {
5625+
consumeToken();
5626+
skipBracedBlock(*this);
56265627
}
56275628
return nullptr;
56285629
}

validation-test/compiler_crashers/28502-tok-isnot-tok-eof-lexing-past-eof.swift renamed to validation-test/compiler_crashers_fixed/28502-tok-isnot-tok-eof-lexing-past-eof.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
// See http://swift.org/LICENSE.txt for license information
66
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
77

8-
// RUN: not --crash %target-swift-frontend %s -emit-ir
8+
// RUN: not %target-swift-frontend %s -emit-ir
99
// REQUIRES: asserts
1010
e(){precedencegroup

0 commit comments

Comments
 (0)