diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2023-01-12 11:43:37 +0100 |
---|---|---|
committer | Tobias Burnus <tobias@codesourcery.com> | 2023-01-12 11:43:37 +0100 |
commit | 2ce55247a8bf32985a96ed63a7a92d36746723dc (patch) | |
tree | 96cc787d634265231f3163720993a9aedfe88222 /gcc | |
parent | f54e3b3ba01ced7ecda3caed51b42f707d489c77 (diff) | |
download | gcc-2ce55247a8bf32985a96ed63a7a92d36746723dc.zip gcc-2ce55247a8bf32985a96ed63a7a92d36746723dc.tar.gz gcc-2ce55247a8bf32985a96ed63a7a92d36746723dc.tar.bz2 |
Fortran/OpenMP: Reject non-scalar 'holds' expr in 'omp assume(s)' [PR107706]
gcc/fortran/ChangeLog:
PR fortran/107706
* openmp.cc (gfc_resolve_omp_assumptions): Reject nonscalars.
gcc/testsuite/ChangeLog:
PR fortran/107706
* gfortran.dg/gomp/assume-2.f90: Update dg-error.
* gfortran.dg/gomp/assumes-2.f90: Likewise.
* gfortran.dg/gomp/assume-5.f90: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fortran/openmp.cc | 8 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/gomp/assume-2.f90 | 2 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/gomp/assume-5.f90 | 20 | ||||
-rw-r--r-- | gcc/testsuite/gfortran.dg/gomp/assumes-2.f90 | 2 |
4 files changed, 27 insertions, 5 deletions
diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc index b71ee46..916daeb 100644 --- a/gcc/fortran/openmp.cc +++ b/gcc/fortran/openmp.cc @@ -6911,9 +6911,11 @@ void gfc_resolve_omp_assumptions (gfc_omp_assumptions *assume) { for (gfc_expr_list *el = assume->holds; el; el = el->next) - if (!gfc_resolve_expr (el->expr) || el->expr->ts.type != BT_LOGICAL) - gfc_error ("HOLDS expression at %L must be a logical expression", - &el->expr->where); + if (!gfc_resolve_expr (el->expr) + || el->expr->ts.type != BT_LOGICAL + || el->expr->rank != 0) + gfc_error ("HOLDS expression at %L must be a scalar logical expression", + &el->expr->where); } diff --git a/gcc/testsuite/gfortran.dg/gomp/assume-2.f90 b/gcc/testsuite/gfortran.dg/gomp/assume-2.f90 index ca3e04d..dc306a9 100644 --- a/gcc/testsuite/gfortran.dg/gomp/assume-2.f90 +++ b/gcc/testsuite/gfortran.dg/gomp/assume-2.f90 @@ -22,6 +22,6 @@ subroutine foo (i, a) end if ! !$omp end assume - silence: 'Unexpected !$OMP END ASSUME statement' - !$omp assume holds (1.0) ! { dg-error "HOLDS expression at .1. must be a logical expression" } + !$omp assume holds (1.0) ! { dg-error "HOLDS expression at .1. must be a scalar logical expression" } !$omp end assume end diff --git a/gcc/testsuite/gfortran.dg/gomp/assume-5.f90 b/gcc/testsuite/gfortran.dg/gomp/assume-5.f90 new file mode 100644 index 0000000..a922f89 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/assume-5.f90 @@ -0,0 +1,20 @@ +! PR fortran/107706 +! +! Contributed by G. Steinmetz +! + +integer function f(i) + implicit none + !$omp assumes holds(i < g()) ! { dg-error "HOLDS expression at .1. must be a scalar logical expression" } + integer, value :: i + + !$omp assume holds(i < g()) ! { dg-error "HOLDS expression at .1. must be a scalar logical expression" } + block + end block + f = 3 +contains + function g() + integer :: g(2) + g = 4 + end +end diff --git a/gcc/testsuite/gfortran.dg/gomp/assumes-2.f90 b/gcc/testsuite/gfortran.dg/gomp/assumes-2.f90 index 729c973..c8719a8 100644 --- a/gcc/testsuite/gfortran.dg/gomp/assumes-2.f90 +++ b/gcc/testsuite/gfortran.dg/gomp/assumes-2.f90 @@ -4,7 +4,7 @@ module m !$omp assumes contains(target) holds(x > 0.0) !$omp assumes absent(target) !$omp assumes holds(0.0) -! { dg-error "HOLDS expression at .1. must be a logical expression" "" { target *-*-* } .-1 } +! { dg-error "HOLDS expression at .1. must be a scalar logical expression" "" { target *-*-* } .-1 } end module module m2 |