From 25ffcf2197f8216be121e742cef47353f14ad42d Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Thu, 19 Mar 2026 22:55:56 +0000 Subject: [PATCH] openmp: sorry instead of ICE for unimplemented mapper with iterator [PR122866] Support for iterators on mapper functions is an OpenMP 5.2 feature that is not implemented yet. Presently attempting to use this feature results in an ICE; let's make it a more user-friendly "sorry" until we get around to implementing this. gcc/ChangeLog PR c/122866 * gimplify.cc (omp_instantiate_mapper): Give a sorry if there are iterators. gcc/testsuite/ChangeLog PR c/122866 * c-c++-common/gomp/pr122866.c: New. Co-authored-by: Sandra Loosemore --- gcc/gimplify.cc | 8 ++++++++ gcc/testsuite/c-c++-common/gomp/pr122866.c | 21 +++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 gcc/testsuite/c-c++-common/gomp/pr122866.c diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc index f4c8bdf9431..8bfc71315f9 100644 --- a/gcc/gimplify.cc +++ b/gcc/gimplify.cc @@ -13629,6 +13629,14 @@ omp_instantiate_mapper (gimple_seq *pre_p, continue; } + if (OMP_CLAUSE_HAS_ITERATORS (clause)) + { + sorry_at (OMP_CLAUSE_LOCATION (clause), + "user-defined mapper that uses a % clause " + "with %"); + continue; + } + tree decl = OMP_CLAUSE_DECL (clause); tree unshared, type; bool nonunit_array_with_mapper = false; diff --git a/gcc/testsuite/c-c++-common/gomp/pr122866.c b/gcc/testsuite/c-c++-common/gomp/pr122866.c new file mode 100644 index 00000000000..bb42bc634db --- /dev/null +++ b/gcc/testsuite/c-c++-common/gomp/pr122866.c @@ -0,0 +1,21 @@ +/* { dg-do "compile" } */ + +struct test { int x; }; + +#pragma omp begin declare target +void froggify (struct test); +#pragma omp end declare target + +#pragma omp declare mapper(struct test v) map(iterator(i = 0:1), tofrom: v.x) +/* { dg-message "sorry, unimplemented: user-defined mapper that uses a .map. clause with .iterator." "" { target *-*-* } .-1 } */ + +int +main () +{ + struct test s; + s.x = -1; + #pragma omp target + { + froggify (s); + } +}