]> granicus.if.org Git - clang/commitdiff
we do in fact have to cache the EOF token returned by the preprocessor.
authorChris Lattner <sabre@nondot.org>
Mon, 12 Jul 2010 04:25:32 +0000 (04:25 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 12 Jul 2010 04:25:32 +0000 (04:25 +0000)
In the case of backtracking, the cached token lexer will be the only
lexer on the stack, without this the token stack will be empty and EOF
won't be returned.

This fixes PR7072.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108124 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/PPCaching.cpp
test/Parser/backtrack-crash.cpp [new file with mode: 0644]

index 6aeb6fa3a2f77704e2a36f02499eb9868c7305a3..20e3b3dd9d8e7bb55e9be064f6e48d51aa57fec9 100644 (file)
@@ -60,13 +60,10 @@ void Preprocessor::CachingLex(Token &Result) {
     return;
   }
 
-  // We should cache the lexed token.
-
+  // Cache the lexed token.
   EnterCachingLexMode();
-  if (Result.isNot(tok::eof)) {
-    CachedTokens.push_back(Result);
-    ++CachedLexPos;
-  }
+  CachedTokens.push_back(Result);
+  ++CachedLexPos;
 }
 
 void Preprocessor::EnterCachingLexMode() {
diff --git a/test/Parser/backtrack-crash.cpp b/test/Parser/backtrack-crash.cpp
new file mode 100644 (file)
index 0000000..cc26873
--- /dev/null
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
+// PR7072
+()( // expected-error {{expected unqualified-id}}
+