From: David Majnemer Date: Mon, 15 Dec 2014 07:00:05 +0000 (+0000) Subject: Parse: Don't reorder tokens using ConsumeToken X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=541811a202dff16d5e6449a2dfa6c2a35303f04e;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224232 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Parse/Parser.h b/include/clang/Parse/Parser.h index 307446c342..ba5c946d35 100644 --- a/include/clang/Parse/Parser.h +++ b/include/clang/Parse/Parser.h @@ -339,7 +339,7 @@ private: void UnconsumeToken(Token &Consumed) { Token Next = Tok; PP.EnterToken(Consumed); - ConsumeToken(); + PP.Lex(Tok); PP.EnterToken(Next); } diff --git a/test/SemaCXX/typo-correction.cpp b/test/SemaCXX/typo-correction.cpp index 4f1928365f..3b31b8db79 100644 --- a/test/SemaCXX/typo-correction.cpp +++ b/test/SemaCXX/typo-correction.cpp @@ -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_;}