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 <sloosemore@baylibre.com>
This commit is contained in:
Tobias Burnus
2026-03-19 22:55:56 +00:00
committed by Sandra Loosemore
parent 8e650f59f3
commit 25ffcf2197
2 changed files with 29 additions and 0 deletions

View File

@@ -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 %<map%> clause "
"with %<iterator%>");
continue;
}
tree decl = OMP_CLAUSE_DECL (clause);
tree unshared, type;
bool nonunit_array_with_mapper = false;

View File

@@ -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);
}
}