PR13619: Make sure we're not at EOF before looking at NextToken().

llvm-svn: 162212
This commit is contained in:
Richard Smith
2012-08-20 17:37:52 +00:00
parent d4e55b8e35
commit 62e6630af9
2 changed files with 8 additions and 4 deletions

View File

@@ -926,10 +926,11 @@ ExprResult Parser::ParseCXXCasts() {
// Check for "<::" which is parsed as "[:". If found, fix token stream,
// diagnose error, suggest fix, and recover parsing.
Token Next = NextToken();
if (Tok.is(tok::l_square) && Tok.getLength() == 2 && Next.is(tok::colon) &&
areTokensAdjacent(Tok, Next))
FixDigraph(*this, PP, Tok, Next, Kind, /*AtDigraph*/true);
if (Tok.is(tok::l_square) && Tok.getLength() == 2) {
Token Next = NextToken();
if (Next.is(tok::colon) && areTokensAdjacent(Tok, Next))
FixDigraph(*this, PP, Tok, Next, Kind, /*AtDigraph*/true);
}
if (ExpectAndConsume(tok::less, diag::err_expected_less_after, CastName))
return ExprError();

View File

@@ -89,3 +89,6 @@ void test3() {
// expected-error {{expected expression}} \
// expected-error {{expected unqualified-id}}
}
// PR13619. Must be at end of file.
int n = reinterpret_cast // expected-error {{expected '<'}} expected-error {{expected ';'}}