aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2024-05-15 18:34:44 +0200
committerJakub Jelinek <jakub@redhat.com>2024-05-15 18:34:44 +0200
commit7fdbefc575c24881356b5f4091fa57b5f7166a90 (patch)
tree4826d2acd9a6987fc1532fc9bb125bb50d17a275 /gcc/cp
parent99b1daae18c095d6c94d32efb77442838e11cbfb (diff)
downloadgcc-7fdbefc575c24881356b5f4091fa57b5f7166a90.zip
gcc-7fdbefc575c24881356b5f4091fa57b5f7166a90.tar.gz
gcc-7fdbefc575c24881356b5f4091fa57b5f7166a90.tar.bz2
openmp: Diagnose using grainsize+num_tasks clauses together [PR115103]
I've noticed that while we diagnose many other OpenMP exclusive clauses, we don't diagnose grainsize together with num_tasks on taskloop construct in all of C, C++ and Fortran (the implementation simply ignored grainsize in that case) and for Fortran also don't diagnose mixing nogroup clause with reduction clause(s). Fixed thusly. 2024-05-15 Jakub Jelinek <jakub@redhat.com> PR c/115103 gcc/c/ * c-typeck.cc (c_finish_omp_clauses): Diagnose grainsize used together with num_tasks. gcc/cp/ * semantics.cc (finish_omp_clauses): Diagnose grainsize used together with num_tasks. gcc/fortran/ * openmp.cc (resolve_omp_clauses): Diagnose grainsize used together with num_tasks or nogroup used together with reduction. gcc/testsuite/ * c-c++-common/gomp/clause-dups-1.c: Add 2 further expected errors. * gfortran.dg/gomp/pr115103.f90: New test.
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/semantics.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc
index df62e2d..f90c304 100644
--- a/gcc/cp/semantics.cc
+++ b/gcc/cp/semantics.cc
@@ -7098,6 +7098,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
bool mergeable_seen = false;
bool implicit_moved = false;
bool target_in_reduction_seen = false;
+ bool num_tasks_seen = false;
bitmap_obstack_initialize (NULL);
bitmap_initialize (&generic_head, &bitmap_default_obstack);
@@ -7656,6 +7657,10 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
/* FALLTHRU */
case OMP_CLAUSE_NUM_TASKS:
+ if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_NUM_TASKS)
+ num_tasks_seen = true;
+ /* FALLTHRU */
+
case OMP_CLAUSE_NUM_TEAMS:
case OMP_CLAUSE_NUM_THREADS:
case OMP_CLAUSE_NUM_GANGS:
@@ -9246,6 +9251,17 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort)
}
pc = &OMP_CLAUSE_CHAIN (c);
continue;
+ case OMP_CLAUSE_GRAINSIZE:
+ if (num_tasks_seen)
+ {
+ error_at (OMP_CLAUSE_LOCATION (c),
+ "%<grainsize%> clause must not be used together with "
+ "%<num_tasks%> clause");
+ *pc = OMP_CLAUSE_CHAIN (c);
+ continue;
+ }
+ pc = &OMP_CLAUSE_CHAIN (c);
+ continue;
case OMP_CLAUSE_ORDERED:
if (reduction_seen == -2)
error_at (OMP_CLAUSE_LOCATION (c),