[PATCH] D25882: Remove special error recovery for ::(id)

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 21 14:50:39 PDT 2016


rnk created this revision.
rnk added reviewers: rsmith, rtrieu.
rnk added a subscriber: cfe-commits.

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 of this nature
due to other token rewriting attempts.


https://reviews.llvm.org/D25882

Files:
  include/clang/Parse/Parser.h
  lib/Parse/ParseExprCXX.cpp
  test/Parser/colon-colon-parentheses.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25882.75490.patch
Type: text/x-patch
Size: 5062 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161021/64a60036/attachment-0001.bin>


More information about the cfe-commits mailing list