c++: error recovery & pragmas
authorNathan Sidwell <nathan@acm.org>
Wed, 15 Jul 2020 13:00:10 +0000 (06:00 -0700)
committerNathan Sidwell <nathan@acm.org>
Wed, 15 Jul 2020 13:05:41 +0000 (06:05 -0700)
commitf0d0be62db5ba030283fa8189211830d09dfb467
tree820947e511b6978f67725536c91b30755a344166
parente0685fadb6aa7c9cc895bc14cbbe2b9026fa3a94
c++: error recovery & pragmas

Parser error recovery can get confused by the tokens within a deferred
pragma, as treats those as regular tokens.  This adjusts the recovery
so that the pragma is treated as a unit.  Also, the preprocessor now
ensures that we never have an EOF token inside a pragma -- the pragma
is always closed first.

gcc/cp/
* parser.c (cp_parser_skip_to_closing_parenthesis_1): Deal with
meeting a deferred pragma.
(cp_parser_skip_to_end_of_statement): Likewise.
(cp_parser_skip_to_end_of_block_or_statement): Likewise.
(cp_parser_skip_to_pragma_eol): We should never meet EOF.
(cp_parser_omp_declare_simd): Likewise.
(cp_parser_omp_declare_reduction, cp_parser_oacc_routine)
(pragma_lex): Likewise.
gcc/testsuite/
* g++.dg/parse/pragma-recovery.C: New.
gcc/cp/parser.c
gcc/testsuite/g++.dg/parse/pragma-recovery.C [new file with mode: 0644]