Remove special error recovery for ::(id)
authorReid Kleckner <rnk@google.com>
Fri, 9 Dec 2016 21:10:43 +0000 (21:10 +0000)
committerReid Kleckner <rnk@google.com>
Fri, 9 Dec 2016 21:10:43 +0000 (21:10 +0000)
commit6c03cfb091c5550e6e4630946498c2271eaa471d
tree9dff44e0503c4b9c8566ee0dcd32ef613ff17285
parent5869b5a4471f90490e1f16f5f1dea3a4d0b41ff3
Remove special error recovery for ::(id)

The code pattern used to implement the token rewriting hack doesn't
interact well with token caching in the pre-processor. As a result,
clang would crash on 'int f(::(id));' while doing a tenative parse of
the contents of the outer parentheses. The original code from PR11852
still doesn't crash the compiler.

This error recovery also often does the wrong thing with member function
pointers. The test case from the original PR doesn't recover the right
way either:
  void S::(*pf)() = S::f; // should be 'void (S::*pf)()'

Instead we were recovering as 'void S::*pf()', which is still wrong.

If we still think that users mistakenly parenthesize identifiers in
nested name specifiers, we should change clang to intentionally parse
that form with an error, rather than doing a token rewrite.

Fixes PR26623, but I think there will be many more bugs like this around
token rewriting in the parser.

Reviewers: rsmith, rtrieu

Differential Revision: https://reviews.llvm.org/D25882

llvm-svn: 289273
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseExprCXX.cpp
clang/test/Parser/colon-colon-parentheses.cpp