aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2020-08-20 13:33:21 +0200
committerTobias Burnus <tobias@codesourcery.com>2020-08-20 13:33:40 +0200
commit656218ab982cc22b826227045826c92743143af1 (patch)
treec133194474a2e0c74e5a1e8854d35cda80e3d29b /gcc
parent1763ec9b20c0146a5a47f2259a44db1fbb9c923a (diff)
downloadgcc-656218ab982cc22b826227045826c92743143af1.zip
gcc-656218ab982cc22b826227045826c92743143af1.tar.gz
gcc-656218ab982cc22b826227045826c92743143af1.tar.bz2
Fortran: Fix OpenMP's 'if(simd:' etc. conditions
gcc/fortran/ChangeLog: * openmp.c (gfc_match_omp_clauses): Re-order 'if' clause pasing to avoid creating spurious symbols. libgomp/ChangeLog: * testsuite/libgomp.fortran/lastprivate-conditional-10.f90: New test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/fortran/openmp.c4
-rw-r--r--gcc/testsuite/gfortran.dg/gomp/pr67500.f9057
2 files changed, 59 insertions, 2 deletions
diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c
index 4d33a45..5098373 100644
--- a/gcc/fortran/openmp.c
+++ b/gcc/fortran/openmp.c
@@ -1299,8 +1299,6 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
&& c->if_expr == NULL
&& gfc_match ("if ( ") == MATCH_YES)
{
- if (gfc_match ("%e )", &c->if_expr) == MATCH_YES)
- continue;
if (!openacc)
{
/* This should match the enum gfc_omp_if_kind order. */
@@ -1323,6 +1321,8 @@ gfc_match_omp_clauses (gfc_omp_clauses **cp, const omp_mask mask,
if (i < OMP_IF_LAST)
continue;
}
+ if (gfc_match ("%e )", &c->if_expr) == MATCH_YES)
+ continue;
gfc_current_locus = old_loc;
}
if ((mask & OMP_CLAUSE_IF_PRESENT)
diff --git a/gcc/testsuite/gfortran.dg/gomp/pr67500.f90 b/gcc/testsuite/gfortran.dg/gomp/pr67500.f90
new file mode 100644
index 0000000..1cecdc4
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/pr67500.f90
@@ -0,0 +1,57 @@
+! Fortran version of PR c/67500
+! { dg-do compile }
+
+subroutine f1
+ !$omp declare simd simdlen(d) ! { dg-error "requires a scalar INTEGER expression" }
+end subroutine
+
+subroutine f2
+ !$omp declare simd simdlen(0.5) ! { dg-error "requires a scalar INTEGER expression" }
+end
+
+subroutine f3 (i)
+ !$omp declare simd simdlen(-2) ! { dg-warning "INTEGER expression of SIMDLEN clause at .1. must be positive" }
+end subroutine
+
+subroutine f4
+ !$omp declare simd simdlen(0) ! { dg-warning "INTEGER expression of SIMDLEN clause at .1. must be positive" }
+end
+
+subroutine foo(p, d, n)
+ integer, allocatable :: p(:)
+ real, value :: d
+ integer, value :: n
+ integer :: i
+
+ !$omp simd safelen(d) ! { dg-error "requires a scalar INTEGER expression" }
+ do i = 1, 16
+ end do
+
+ !$omp simd safelen(0.5) ! { dg-error "requires a scalar INTEGER expression" }
+ do i = 1, 16
+ end do
+
+ !$omp simd safelen(-2) ! { dg-warning "INTEGER expression of SAFELEN clause at .1. must be positive" }
+ do i = 1, 16
+ end do
+
+ !$omp simd safelen(0) ! { dg-warning "INTEGER expression of SAFELEN clause at .1. must be positive" }
+ do i = 1, 16
+ end do
+
+ !$omp simd aligned(p:n) ! { dg-error "requires a scalar positive constant integer alignment expression" }
+ do i = 1, 16
+ end do
+
+ !$omp simd aligned(p:0.5) ! { dg-error "requires a scalar positive constant integer alignment expression" }
+ do i = 1, 16
+ end do
+
+ !$omp simd aligned(p:-2) ! { dg-error "requires a scalar positive constant integer alignment expression" }
+ do i = 1, 16
+ end do
+
+ !$omp simd aligned(p:0) ! { dg-error "requires a scalar positive constant integer alignment expression" }
+ do i = 1, 16
+ end do
+end