]> granicus.if.org Git - clang/commitdiff
PR13619: Make sure we're not at EOF before looking at NextToken().
authorRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 20 Aug 2012 17:37:52 +0000 (17:37 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Mon, 20 Aug 2012 17:37:52 +0000 (17:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162212 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Parse/ParseExprCXX.cpp
test/Parser/cxx-casting.cpp

index f2ba4c6e115b2975b9049120cc78593671dfbc7d..baad166814684e4e02862faee7b891eac89b2f12 100644 (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();
index e7d05b4047b5dab3f1fe9ce454f999b1fe315832..01980d3341769c0f2889437721cc216c9146e8b0 100644 (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 ';'}}