llvm-project/clang/lib/Parse
Reid Kleckner 6c03cfb091 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
2016-12-09 21:10:43 +00:00
..
CMakeLists.txt [CMake] Reorder libdeps by alphabetical order. 2014-07-14 04:59:27 +00:00
ParseAST.cpp C++ Modules TS: add frontend support for building pcm files from module 2016-08-26 00:14:38 +00:00
ParseCXXInlineMethods.cpp Use unique_ptr for cached tokens for default arguments in C++. 2016-11-17 17:52:58 +00:00
ParseDecl.cpp Store decls in prototypes on the declarator instead of in the AST 2016-12-09 17:14:05 +00:00
ParseDeclCXX.cpp [c++1z] P0003R5: Removing dynamic exception specifications. 2016-12-08 02:49:07 +00:00
ParseExpr.cpp Store decls in prototypes on the declarator instead of in the AST 2016-12-09 17:14:05 +00:00
ParseExprCXX.cpp Remove special error recovery for ::(id) 2016-12-09 21:10:43 +00:00
ParseInit.cpp [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
ParseObjc.cpp [ObjC] Avoid a @try/@finally/@autoreleasepool fixit when parsing an expression 2016-12-01 12:14:38 +00:00
ParseOpenMP.cpp [OpenMP] Sema and parsing for 'teams distribute parallel for' pragma 2016-12-09 03:24:30 +00:00
ParsePragma.cpp [CUDA] Add #pragma clang force_cuda_host_device_{begin,end} pragmas. 2016-10-08 22:15:58 +00:00
ParseStmt.cpp [CodeCompletion] Add a block property setter completion result 2016-10-18 10:55:01 +00:00
ParseStmtAsm.cpp More diagnostic name fixups: w_ -> warn_, warning_ -> warn_, not_ -> note_. 2016-12-02 23:00:28 +00:00
ParseTemplate.cpp [NFC] Header cleanup 2016-07-18 19:02:11 +00:00
ParseTentative.cpp regcall: Implement regcall Calling Conv in clang 2016-11-02 18:29:35 +00:00
Parser.cpp [modules] Use the "redundant #include" diagnostic rather than the "module 2016-12-06 00:12:39 +00:00
RAIIObjectsForParser.h Add a new error for unexpected semi-colon before closing delimiter. 2015-05-12 21:36:35 +00:00