Sandra Loosemore wrote:
The new testcase included in this patch used to ICE in gcc after
diagnosing the first error, and in g++ it only diagnosed the error in
the first metadirective, ignoring the second one.  The solution is to
make error recovery in the C front end more like that in the C++ front
end, and remove the code in both front ends that previously tried to
skip all the way over the following statement (instead of just to the
end of the metadirective pragma) after an error.

(If anyone wonders: there is still one use case left for
{c,cp}_parser_skip_to_end_of_block_or_statement - in the handling
of standalone directives (in the non-error case).)

gcc/c/ChangeLog
        * c-parser.cc (c_parser_skip_to_closing_brace): New, copied from
        the equivalent function in the C++ front end.
        (c_parser_skip_to_end_of_block_or_statement): Pass false to
        the error flag.
        (c_parser_omp_context_selector): Immediately return error_mark_node
        after giving an error that the integer trait property is invalid,
        similarly to C++ front end.
        (c_parser_omp_context_selector_specification): Likewise handle
        error return from c_parser_omp_context_selector similarly to C++.
        (c_parser_omp_metadirective): Do not call
        c_parser_skip_to_end_of_block_or_statement after an error.

gcc/cp/ChangeLog
        * parser.cc (cp_parser_omp_metadirective): Do not call
        cp_parser_skip_to_end_of_block_or_statement after an error.

gcc/testsuite/ChangeLog
        * c-c++-common/gomp/declare-variant-2.c: Adjust patterns now that
        C and C++ now behave similarly.
        * c-c++-common/gomp/metadirective-error-recovery.c: New.

LGTM. Thanks again - and I concur that it is suitable for GCC 15.

Tobias

Reply via email to