aboutsummaryrefslogtreecommitdiff
path: root/gcc/c/c-parser.cc
diff options
context:
space:
mode:
authorTobias Burnus <tburnus@baylibre.com>2024-12-12 18:58:59 +0100
committerTobias Burnus <tburnus@baylibre.com>2024-12-12 18:58:59 +0100
commit2cbb2408a830a63fbd901a4da3bfd341cec4b6ef (patch)
treef981a207e2c1b3619298c66bc1855473949e2709 /gcc/c/c-parser.cc
parentd4330ff9bc9a2995e79d88b09a2ee76673167661 (diff)
downloadgcc-2cbb2408a830a63fbd901a4da3bfd341cec4b6ef.zip
gcc-2cbb2408a830a63fbd901a4da3bfd341cec4b6ef.tar.gz
gcc-2cbb2408a830a63fbd901a4da3bfd341cec4b6ef.tar.bz2
OpenMP: Enable has_device_addr clause for 'dispatch' in C/C++
The 'has_device_addr' of 'dispatch' has to be seen in conjunction with the 'need_device_addr' modifier to the 'adjust_args' clause of 'declare variant'. As the latter has not yet been implemented, 'has_device_addr' has no real effect. However, to prepare for 'need_device_addr' and as service to the user: For C, where 'need_device_addr' is not permitted (contrary to C++ and Fortran), a note is output when then the user tries to use it (alongside the existing error that either 'nothing' or 'need_device_ptr' was expected). And, on the ME side, is is lightly handled by diagnosing when - for the same argument - there is a mismatch between the variant's adjust_args 'need_device_ptr' modifier and dispatch having an 'has_device_addr' clause (or likewise for need_device_addr with is_device_ptr) as, according to the spec, those are completely separate. Thus, 'dispatch' will still do the host to device pointer conversion for a 'need_device_ptr' argument, even if it appeared in a 'has_device_addr' clause. gcc/c/ChangeLog: * c-parser.cc (OMP_DISPATCH_CLAUSE_MASK): Add has_device_addr clause. (c_finish_omp_declare_variant): Add an 'inform' telling the user that 'need_device_addr' is invalid for C. gcc/cp/ChangeLog: * parser.cc (OMP_DISPATCH_CLAUSE_MASK): Add has_device_addr clause. gcc/ChangeLog: * gimplify.cc (gimplify_call_expr): When handling OpenMP's dispatch, add diagnostic when there is a ptr vs. addr mismatch between need_device_{addr,ptr} and {is,has}_device_{ptr,addr}, respectively. gcc/testsuite/ChangeLog: * c-c++-common/gomp/adjust-args-3.c: New test. * gcc.dg/gomp/adjust-args-2.c: New test.
Diffstat (limited to 'gcc/c/c-parser.cc')
-rw-r--r--gcc/c/c-parser.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc
index 4ec0ee8..d023580 100644
--- a/gcc/c/c-parser.cc
+++ b/gcc/c/c-parser.cc
@@ -25271,6 +25271,7 @@ c_parser_omp_dispatch_body (c_parser *parser)
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_DEPEND) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOVARIANTS) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOCONTEXT) \
+ | (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_HAS_DEVICE_ADDR) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_INTEROP) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_IS_DEVICE_PTR) \
| (OMP_CLAUSE_MASK_1 << PRAGMA_OMP_CLAUSE_NOWAIT))
@@ -26963,6 +26964,9 @@ c_finish_omp_declare_variant (c_parser *parser, tree fndecl, tree parms)
{
error_at (c_parser_peek_token (parser)->location,
"expected %<nothing%> or %<need_device_ptr%>");
+ if (strcmp (p, "need_device_addr") == 0)
+ inform (c_parser_peek_token (parser)->location,
+ "%<need_device_addr%> is not valid for C");
goto fail;
}
}