Selaa lähdekoodia

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162212 91177308-0d34-0410-b5e6-96231b3b80d8
Richard Smith 13 vuotta sitten
vanhempi
commit
78fe3e05a9
2 muutettua tiedostoa jossa 8 lisäystä ja 4 poistoa
  1. 5 4
      lib/Parse/ParseExprCXX.cpp
  2. 3 0
      test/Parser/cxx-casting.cpp

+ 5 - 4
lib/Parse/ParseExprCXX.cpp

@@ -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();

+ 3 - 0
test/Parser/cxx-casting.cpp

@@ -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 ';'}}