From 0d00fe404c162ad0cf922ca8455aa23a74042b63 Mon Sep 17 00:00:00 2001 From: Julian Brown Date: Tue, 9 Jun 2020 06:21:34 -0700 Subject: openacc: Set bias to zero for explicit attach/detach clauses in C and C++ This is a fix for the pointer (or array) size inadvertently being used for the bias with attach and detach mapping kinds, for both C and C++. 2020-07-09 Julian Brown Thomas Schwinge gcc/c/ PR middle-end/95270 * c-typeck.c (c_finish_omp_clauses): Set OMP_CLAUSE_SIZE (bias) to zero for standalone attach/detach clauses. gcc/cp/ PR middle-end/95270 * semantics.c (finish_omp_clauses): Likewise. include/ PR middle-end/95270 * gomp-constants.h (gomp_map_kind): Expand comment for attach/detach mapping kinds. gcc/testsuite/ PR middle-end/95270 * c-c++-common/goacc/mdc-1.c: Update expected dump output for zero bias. libgomp/ PR middle-end/95270 * testsuite/libgomp.oacc-c-c++-common/pr95270-1.c: New test. * testsuite/libgomp.oacc-c-c++-common/pr95270-2.c: New test. --- include/gomp-constants.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'include/gomp-constants.h') diff --git a/include/gomp-constants.h b/include/gomp-constants.h index b42b414..7e44238a 100644 --- a/include/gomp-constants.h +++ b/include/gomp-constants.h @@ -139,7 +139,12 @@ enum gomp_map_kind /* Decrement usage count and deallocate if zero. */ GOMP_MAP_RELEASE = (GOMP_MAP_FLAG_SPECIAL_2 | GOMP_MAP_DELETE), - /* In OpenACC, attach a pointer to a mapped struct field. */ + /* The attach/detach mappings below use the OMP_CLAUSE_SIZE field as a + bias. This will typically be zero, except when mapping an array slice + with a non-zero base. In that case the bias will indicate the + (positive) difference between the start of the actual mapped data and + the "virtual" origin of the array. + In OpenACC, attach a pointer to a mapped struct field. */ GOMP_MAP_ATTACH = (GOMP_MAP_DEEP_COPY | 0), /* In OpenACC, detach a pointer to a mapped struct field. */ GOMP_MAP_DETACH = (GOMP_MAP_DEEP_COPY | 1), -- cgit v1.1