c++: Parser initialization cleanup

Nathan Sidwell nathan@acm.org
Tue Jul 14 17:59:53 GMT 2020


The handling of PCH is a little trick, because we have to deal with it 
before allocating memory.  I found the layering somewhat confusing. 
This patch reorganizes that, so that the stopping of PCH is done in 
exactly one place, and the ordering of lexer creation relative to that 
is much clearer.

I also changed the error message about multiple source files as with 
C++20, 'modules' means something rather specific.

Other than the error message changes, no functional changes.

             gcc/cp/
             * parser.c (cp_lexer_alloc): Do not deal with PCH here.
             (cp_lexer_new_main): Deal with PCH here.  Store the tokens 
directly
             into the buffer.
             (cp_lexer_new_from_tokens): Assert last token isn't purged 
either.
             (cp_lexer_get_preprocessor_token): Change first arg to 
flags, adjust.
             (cp_parser_new): Pass the lexer in, don't create it here.
             (cp_parser_translation_unit): Initialize access checks here.
             (cp_parser_initial_pragma): First token is provided by caller,
             don't deal with PCH stopping here.  Adjust error message.
             (c_parse_file): Adjust, change error message to avoid C++20 
module
             confusion.

pushed

-- 
Nathan Sidwell
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cp-parser.diff
Type: text/x-patch
Size: 7179 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20200714/ed33f682/attachment.bin>


More information about the Gcc-patches mailing list