]> granicus.if.org Git - clang/commitdiff
Parse: Don't reorder tokens using ConsumeToken
authorDavid Majnemer <david.majnemer@gmail.com>
Mon, 15 Dec 2014 07:00:05 +0000 (07:00 +0000)
committerDavid Majnemer <david.majnemer@gmail.com>
Mon, 15 Dec 2014 07:00:05 +0000 (07:00 +0000)
ConsumeToken doesn't work with special tokens.  Instead, just use PP.Lex
to eat the token.

This fixes PR21817.

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

include/clang/Parse/Parser.h
test/SemaCXX/typo-correction.cpp

index 307446c3427b1b48efdb1109f1fd47878339058c..ba5c946d359c6d750354a129cb89bbd6b17cee18 100644 (file)
@@ -339,7 +339,7 @@ private:
   void UnconsumeToken(Token &Consumed) {
       Token Next = Tok;
       PP.EnterToken(Consumed);
-      ConsumeToken();
+      PP.Lex(Tok);
       PP.EnterToken(Next);
   }
 
index 4f1928365f82c2dd865a5407628889a471abcf9f..3b31b8db798c8724abbaa05122667ed9012ec6b4 100644 (file)
@@ -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@-1 {{expected expression}}
+}
+
 struct errc {
   int v_;
   operator int() const {return v_;}