Skip to content

Commit 5877db3

Browse files
authored
Merge pull request #5099 from rintaro/rangle-location
2 parents dbfd6f5 + 056aed8 commit 5877db3

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

lib/Parse/ParseGeneric.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,22 +122,17 @@ Parser::parseGenericParameters(SourceLoc LAngleLoc) {
122122

123123
// Parse the closing '>'.
124124
SourceLoc RAngleLoc;
125-
if (!startsWithGreater(Tok)) {
125+
if (startsWithGreater(Tok)) {
126+
RAngleLoc = consumeStartingGreater();
127+
} else {
126128
if (!Invalid) {
127129
diagnose(Tok, diag::expected_rangle_generics_param);
128130
diagnose(LAngleLoc, diag::opening_angle);
129-
130131
Invalid = true;
131132
}
132-
133+
133134
// Skip until we hit the '>'.
134-
skipUntilGreaterInTypeList();
135-
if (startsWithGreater(Tok))
136-
RAngleLoc = consumeStartingGreater();
137-
else
138-
Invalid = true;
139-
} else {
140-
RAngleLoc = consumeStartingGreater();
135+
RAngleLoc = skipUntilGreaterInTypeList();
141136
}
142137

143138
if (GenericParams.empty() || Invalid) {

lib/Parse/Parser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ void Parser::skipUntilAnyOperator() {
438438
/// of generic parameters, generic arguments, or list of types in a protocol
439439
/// composition.
440440
SourceLoc Parser::skipUntilGreaterInTypeList(bool protocolComposition) {
441-
SourceLoc lastLoc = Tok.getLoc();
441+
SourceLoc lastLoc = PreviousLoc;
442442
while (true) {
443443
switch (Tok.getKind()) {
444444
case tok::eof:
@@ -473,8 +473,8 @@ SourceLoc Parser::skipUntilGreaterInTypeList(bool protocolComposition) {
473473

474474
break;
475475
}
476-
lastLoc = Tok.getLoc();
477476
skipSingle();
477+
lastLoc = PreviousLoc;
478478
}
479479
}
480480

validation-test/compiler_crashers/28429-swift-decl-print.swift renamed to validation-test/compiler_crashers_fixed/28429-swift-decl-print.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
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 -parse
8+
// RUN: not %target-swift-frontend %s -parse
99
// REQUIRES: asserts
1010
{class
1111
func g:protocol<

0 commit comments

Comments
 (0)