This partially undoes the commit r17-5077-g8bb7a53a0df5c5, https://gcc.gnu.org/pipermail/gcc-patches/2026-October/734176.html
Namely, that patch required a compile-time constant for the OpenMP 'priority' clause; while it seemed to be a bit odd to me, I still implemented it. Digging deeper, it seems to have been an error during the syntax handling update of OpenMP 5.1 to 5.2, where the 'constant' was added. (4.5 to 5.1 had no constant, no idea about 4.0 or earlier.) Hence, I re-enabled the runtime handling by the attached patch; the issue is also tracked at the specification side and I expect that 6.1 will permit non-constants as well. Committed as r17-5095-g1152c67150f405. Tobias
commit 1152c67150f4051d1a44ed52e8aafe3c9bbe4eb9 Author: Tobias Burnus <[email protected]> Date: Mon Oct 12 18:01:27 2026 +0200 OpenMP/Fortran: permit non-const expr for 'priority' clause again This partially reverts r17-5077-g8bb7a53a0df5c5 by permitting non-constant expressions to the 'priority' clause again. OpenMP since at least 4.5 did so until 5.1, since 5.2 it must be constant, which seems to be a syntax conversion bug (tracked as OpenMP Issue 5176). gcc/fortran/ChangeLog: * openmp.cc (resolve_omp_clauses): Permit non-constant expressions for 'priority' clause again. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/masked-1.f90: Revert to pre-r17-5077 using a non-constant priority-clause expr. * gfortran.dg/gomp/taskloop-1.f90: Likewise. * gfortran.dg/gomp/taskloop-2.f90: Use -1 as priority and update dg-*. --- gcc/fortran/openmp.cc | 2 +- gcc/testsuite/gfortran.dg/gomp/masked-1.f90 | 5 ++--- gcc/testsuite/gfortran.dg/gomp/taskloop-1.f90 | 5 ++--- gcc/testsuite/gfortran.dg/gomp/taskloop-2.f90 | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index 0ed83519a64..ac2001e29b3 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -11794,7 +11794,7 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses, "constant hint expression", &omp_clauses->hint->where); } if (omp_clauses->priority) - resolve_nonnegative_int_expr (omp_clauses->priority, "PRIORITY", false); + resolve_nonnegative_int_expr (omp_clauses->priority, "PRIORITY", true); if (omp_clauses->dist_chunk_size) { gfc_expr *expr = omp_clauses->dist_chunk_size; diff --git a/gcc/testsuite/gfortran.dg/gomp/masked-1.f90 b/gcc/testsuite/gfortran.dg/gomp/masked-1.f90 index 1502e8724af..2b2526ac712 100644 --- a/gcc/testsuite/gfortran.dg/gomp/masked-1.f90 +++ b/gcc/testsuite/gfortran.dg/gomp/masked-1.f90 @@ -42,14 +42,13 @@ subroutine foo (x, a) !$omp end masked end -subroutine foobar (d, f, fi, p, s, g, i1, i2, l, ll, nth, ntm, q, r, r2) +subroutine foobar (d, f, fi, p, s, g, i1, i2, l, ll, nth, ntm, pp, q, r, r2) implicit none (type, external) logical :: i1, i2, fi - integer :: i, d, f, p, s, g, l, ll, nth, ntm, q, r, r2 + integer :: i, d, f, p, s, g, l, ll, nth, ntm, pp, q, r, r2 allocatable :: q integer, save :: t !$omp threadprivate (t) - integer, parameter :: pp = 3 !$omp parallel masked & !$omp& private (p) firstprivate (f) if (parallel: i2) default(shared) shared(s) reduction(+:r) & diff --git a/gcc/testsuite/gfortran.dg/gomp/taskloop-1.f90 b/gcc/testsuite/gfortran.dg/gomp/taskloop-1.f90 index e3fef34b219..46901712a24 100644 --- a/gcc/testsuite/gfortran.dg/gomp/taskloop-1.f90 +++ b/gcc/testsuite/gfortran.dg/gomp/taskloop-1.f90 @@ -7,14 +7,13 @@ module m !$omp declare target to(f, l, ll, r, r2) end module m -subroutine foo(fi, p, g, s, nta, nth, ntm, i1, i2, i3, q) +subroutine foo(fi, p, pp, g, s, nta, nth, ntm, i1, i2, i3, q) use m implicit none - integer, value :: p, g, s, nta, nth, ntm + integer, value :: p, pp, g, s, nta, nth, ntm logical, value :: fi, i1, i2, i3 integer, pointer :: q(:) integer :: i - integer, parameter :: pp = 3 !$omp taskgroup task_reduction(+:r2) !allocate (r2) !$omp taskloop simd & diff --git a/gcc/testsuite/gfortran.dg/gomp/taskloop-2.f90 b/gcc/testsuite/gfortran.dg/gomp/taskloop-2.f90 index 6a81295d546..6644e82d637 100644 --- a/gcc/testsuite/gfortran.dg/gomp/taskloop-2.f90 +++ b/gcc/testsuite/gfortran.dg/gomp/taskloop-2.f90 @@ -42,7 +42,7 @@ end do do i = 1, 64 ! { dg-error "OMP SCAN between two structured block sequences" "" { target *-*-* } .-1 } end do -!$omp parallel master taskloop reduction(+: r) priority(r) ! { dg-error "INTEGER expression of PRIORITY clause at .1. must be non-negtive and constant" } +!$omp parallel master taskloop reduction(+: r) priority(-1) ! { dg-warning "INTEGER expression of PRIORITY clause at .1. must be non-negative \\\[-Wopenmp\\\]" } do i = 1, 64 end do end
