Skip to content

Commit

Permalink
fix a logic error in parseList where it could drive off the end of th…
Browse files Browse the repository at this point in the history
…e file

and infinitely loop because it didn't realize that skipUntil doesn't always
consume something.

This fixes an infinite loop on this testcase:

func isSpace(c : Char) -> Bool {
  return (c == '\v' ||
          c == '\f')
}

which comes from rdar://11936003.  I'm not adding it because it only works
as the last thing in a file, and isn't likely to regress.  The diagnostics
produced are also still really really awful for this.


Swift SVN r5241
  • Loading branch information
lattner committed May 20, 2013
1 parent 8707fa7 commit a697922
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Parse/Parser.cpp
Expand Up @@ -312,8 +312,7 @@ bool Parser::parseMatchingToken(tok K, SourceLoc &TokLoc, Diag<> ErrorDiag,
/// parseList - Parse the list of statements, expressions, or declarations.
bool Parser::parseList(tok RightK, SourceLoc LeftLoc, SourceLoc &RightLoc,
tok SeparatorK, bool OptionalSep, Diag<> ErrorDiag,
std::function<bool()> callback)
{
std::function<bool()> callback) {
assert(SeparatorK == tok::comma || SeparatorK == tok::semi);

if (Tok.is(RightK)) {
Expand Down Expand Up @@ -357,6 +356,8 @@ bool Parser::parseList(tok RightK, SourceLoc LeftLoc, SourceLoc &RightLoc,
skipUntil(RightK, SeparatorK);
if (Tok.is(RightK))
break;
if (Tok.is(tok::eof))
return true;
consumeIf(SeparatorK);
}
}
Expand Down

0 comments on commit a697922

Please sign in to comment.