]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: Minor cleanup in parser.cc
authorLewis Hyatt <lhyatt@gmail.com>
Fri, 1 Jul 2022 17:53:34 +0000 (13:53 -0400)
committerLewis Hyatt <lhyatt@gmail.com>
Fri, 1 Jul 2022 21:33:13 +0000 (17:33 -0400)
commitff64a8c951995cb1214b4d2864a4bd553b60f249
tree6589f5a42a397e511767cbdc0b2c58eb08b7ea75
parent1f76941c09f6f62f4cbf7a9f531ec95268dd2c0a
c++: Minor cleanup in parser.cc

The code to determine whether a given token starts a module directive is
currently repeated in 4 places in parser.cc. I am about to submit a patch
that needs to add it in a 5th place, so since the code is not completely
trivial (needing to check for 3 different token types), it seems worthwhile
to factor this logic into its own function.

gcc/cp/ChangeLog:

* parser.cc (cp_token_is_module_directive): New function
refactoring common code.
(cp_parser_skip_to_closing_parenthesis_1): Use the new function.
(cp_parser_skip_to_end_of_statement): Likewise.
(cp_parser_skip_to_end_of_block_or_statement): Likewise.
(cp_parser_declaration): Likewise.
gcc/cp/parser.cc