From b368dd5de53fc981b5b20e2fd6d7de9116e82331 Mon Sep 17 00:00:00 2001 From: Sandra Loosemore Date: Sat, 24 May 2025 03:21:18 +0000 Subject: OpenMP: Fix ICE in metadirective recovery after error [PR120180] It's not clear whether a metadirective in a loop nest is supposed to be valid, but GCC certainly shouldn't be ICE'ing after diagnosing it as an error. gcc/c/ChangeLog PR c/120180 * c-parser.cc (c_parser_omp_metadirective): Only consume the token if it is the expected close paren. gcc/cp/ChangeLog PR c/120180 * parser.cc (cp_parser_omp_metadirective): Only consume the token if it is the expected close paren. gcc/testsuite/ChangeLog PR c/120180 * c-c++-common/gomp/pr120180.c: New. (cherry picked from commit 65e0ed2310a1b0d1a3255583bbfb8a8d86c5aea5) --- gcc/c/c-parser.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'gcc/c/c-parser.cc') diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 22ec0f8..d825e05 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -29247,7 +29247,10 @@ c_parser_omp_metadirective (c_parser *parser, bool *if_p) goto add; case CPP_CLOSE_PAREN: if (nesting_depth-- == 0) - break; + { + c_parser_consume_token (parser); + break; + } goto add; default: add: @@ -29259,8 +29262,6 @@ c_parser_omp_metadirective (c_parser *parser, bool *if_p) break; } - c_parser_consume_token (parser); - if (!skip) { c_token eol_token; -- cgit v1.1