diff options
author | Hafiz Abid Qadeer <abidh@codesourcery.com> | 2022-02-18 21:28:08 +0000 |
---|---|---|
committer | Hafiz Abid Qadeer <abidh@codesourcery.com> | 2022-05-06 10:45:05 +0100 |
commit | 1a8c4d9ed36556a95bd7d53c04d2ec4c95594061 (patch) | |
tree | d3fb88f1fbe3f66e9c1e85431540fb79131dd8f4 /gcc/omp-low.cc | |
parent | 8025f29fbd8f87e27354b69d0bc9eb8d1aeae94c (diff) | |
download | gcc-1a8c4d9ed36556a95bd7d53c04d2ec4c95594061.zip gcc-1a8c4d9ed36556a95bd7d53c04d2ec4c95594061.tar.gz gcc-1a8c4d9ed36556a95bd7d53c04d2ec4c95594061.tar.bz2 |
Add a restriction on allocate clause (OpenMP 5.0)
An allocate clause in target region must specify an allocator
unless the compilation unit has requires construct with
dynamic_allocators clause. Current implementation of the allocate
clause did not check for this restriction. This patch fills that
gap.
gcc/ChangeLog:
* omp-low.cc (omp_maybe_offloaded_ctx): New prototype.
(scan_sharing_clauses): Check a restriction on allocate clause.
gcc/testsuite/ChangeLog:
* c-c++-common/gomp/allocate-2.c: Add tests.
* c-c++-common/gomp/allocate-8.c: New test.
* gfortran.dg/gomp/allocate-3.f90: Add tests.
* gcc.dg/gomp/pr104517.c: Update.
Diffstat (limited to 'gcc/omp-low.cc')
-rw-r--r-- | gcc/omp-low.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gcc/omp-low.cc b/gcc/omp-low.cc index 4c52886..49481b2 100644 --- a/gcc/omp-low.cc +++ b/gcc/omp-low.cc @@ -195,6 +195,7 @@ static vec<gomp_task *> task_cpyfns; static void scan_omp (gimple_seq *, omp_context *); static tree scan_omp_1_op (tree *, int *, void *); +static bool omp_maybe_offloaded_ctx (omp_context *ctx); #define WALK_SUBSTMTS \ case GIMPLE_BIND: \ @@ -1154,6 +1155,15 @@ scan_sharing_clauses (tree clauses, omp_context *ctx) || !integer_onep (OMP_CLAUSE_ALLOCATE_ALLOCATOR (c)) || OMP_CLAUSE_ALLOCATE_ALIGN (c) != NULL_TREE)) { + /* The allocate clauses that appear on a target construct or on + constructs in a target region must specify an allocator expression + unless a requires directive with the dynamic_allocators clause + is present in the same compilation unit. */ + if (OMP_CLAUSE_ALLOCATE_ALLOCATOR (c) == NULL_TREE + && ((omp_requires_mask & OMP_REQUIRES_DYNAMIC_ALLOCATORS) == 0) + && omp_maybe_offloaded_ctx (ctx)) + error_at (OMP_CLAUSE_LOCATION (c), "%<allocate%> clause must" + " specify an allocator here"); if (ctx->allocate_map == NULL) ctx->allocate_map = new hash_map<tree, tree>; tree val = integer_zero_node; |