r224232 - Parse: Don't reorder tokens using ConsumeToken

David Majnemer david.majnemer at gmail.com
Sun Dec 14 23:00:06 PST 2014


Author: majnemer
Date: Mon Dec 15 01:00:05 2014
New Revision: 224232

URL: http://llvm.org/viewvc/llvm-project?rev=224232&view=rev
Log:
Parse: Don't reorder tokens using ConsumeToken

ConsumeToken doesn't work with special tokens.  Instead, just use PP.Lex
to eat the token.

This fixes PR21817.

Modified:
    cfe/trunk/include/clang/Parse/Parser.h
    cfe/trunk/test/SemaCXX/typo-correction.cpp

Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=224232&r1=224231&r2=224232&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Mon Dec 15 01:00:05 2014
@@ -339,7 +339,7 @@ private:
   void UnconsumeToken(Token &Consumed) {
       Token Next = Tok;
       PP.EnterToken(Consumed);
-      ConsumeToken();
+      PP.Lex(Tok);
       PP.EnterToken(Next);
   }
 

Modified: cfe/trunk/test/SemaCXX/typo-correction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction.cpp?rev=224232&r1=224231&r2=224232&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/typo-correction.cpp (original)
+++ cfe/trunk/test/SemaCXX/typo-correction.cpp Mon Dec 15 01:00:05 2014
@@ -4,6 +4,11 @@
 // afoul the hard-coded limit (escape hatch) of 20 different typos whose
 // correction was attempted by Sema::CorrectTypo
 
+namespace PR21817{
+int a(-rsing[2]); // expected-error {{undeclared identifier 'rsing'; did you mean 'using'?}}
+                  // expected-error at -1 {{expected expression}}
+}
+
 struct errc {
   int v_;
   operator int() const {return v_;}





More information about the cfe-commits mailing list