https://gcc.gnu.org/g:9e3aeec74092e91b7f66d2cc5dc5885ef728d5b6
commit 9e3aeec74092e91b7f66d2cc5dc5885ef728d5b6 Author: Kwok Cheung Yeung <kcye...@baylibre.com> Date: Mon Oct 7 16:19:39 2024 +0100 openmp: Fix error reporting in parsing of C++ OpenMP to/from clause The final 'else' when checking the motion modifiers is nested one level too deep. This patch should be folded into "OpenMP: Enable 'declare mapper' mappers for 'target update' directives" when pushing upstream. gcc/cp/ChangeLog: * parser.cc (cp_parser_omp_clause_from_to): Move an "else" clause to a higher nesting level. Diff: --- gcc/cp/ChangeLog.omp | 6 ++++++ gcc/cp/parser.cc | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/gcc/cp/ChangeLog.omp b/gcc/cp/ChangeLog.omp index f0b50bea7f9f..1136e686b18c 100644 --- a/gcc/cp/ChangeLog.omp +++ b/gcc/cp/ChangeLog.omp @@ -1,3 +1,9 @@ +2024-12-06 Andrew Stubbs <a...@baylibre.com> + Kwok Cheung Yeung <kcye...@baylibre.com> + + * parser.cc (cp_parser_omp_clause_from_to): Move an "else" clause to + a higher nesting level. + 2024-05-15 Jakub Jelinek <ja...@redhat.com> * semantics.cc (finish_omp_clauses): Diagnose grainsize diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index 4157d912039c..f52446c5e46a 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -42058,16 +42058,16 @@ cp_parser_omp_clause_from_to (cp_parser *parser, enum omp_clause_code kind, mapper_modifier = true; pos += 3; } - else - { - cp_parser_error (parser, "%<to%> or %<from%> clause with " - "modifier other than %<present%> or %<mapper%>"); - cp_parser_skip_to_closing_parenthesis (parser, - /*recovering=*/true, - /*or_comma=*/false, - /*consume_paren=*/true); - return list; - } + } + else + { + cp_parser_error (parser, "%<to%> or %<from%> clause with " + "modifier other than %<present%> or %<mapper%>"); + cp_parser_skip_to_closing_parenthesis (parser, + /*recovering=*/true, + /*or_comma=*/false, + /*consume_paren=*/true); + return list; } }