From 244ed2adaa3d349d381ca6ce090c2fa69b6e8d8b Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Tue, 16 Jun 2020 20:17:20 +0200 Subject: [PATCH] OpenMP/Fortran: Permit impure ELEMENTAL in omp directives MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit OpenMP since 4.5 permits IMPURE ELEMENTAL in directives and the code already only checked for PURE. – Followup for -fopenmp-simd. gcc/fortran/ChangeLog: * parse.c (decode_omp_directive): Remove "or ELEMENTAL" from "in PURE" error message also for -fopenmp-simd. gcc/testsuite/ChangeLog: * gfortran.dg/gomp/pr79154-simd.f90: New test. --- gcc/fortran/parse.c | 3 +-- gcc/testsuite/gfortran.dg/gomp/pr79154-simd.f90 | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/gomp/pr79154-simd.f90 diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index 9d90e50..46e1e1b 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -1078,8 +1078,7 @@ decode_omp_directive (void) if (!flag_openmp && gfc_pure (NULL)) { gfc_error_now ("OpenMP directives other than SIMD or DECLARE TARGET " - "at %C may not appear in PURE or ELEMENTAL " - "procedures"); + "at %C may not appear in PURE procedures"); reject_statement (); gfc_error_recovery (); return ST_NONE; diff --git a/gcc/testsuite/gfortran.dg/gomp/pr79154-simd.f90 b/gcc/testsuite/gfortran.dg/gomp/pr79154-simd.f90 new file mode 100644 index 0000000..d6b72d6 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/pr79154-simd.f90 @@ -0,0 +1,16 @@ +! { dg-options "-fno-openmp -fopenmp-simd" } +! +pure subroutine bar(a) + integer, intent(in) :: a(:) + !$omp target enter data map(to:a) ! Ignored with -fopenmp-simd otherwise invalid in PURE +end + +pure subroutine foo(a,b) + integer, intent(out) :: a(5) + integer, intent(in) :: b(5) + !$omp target teams distribute simd ! { dg-error "may not appear in PURE procedures" } + do i=1, 5 + a(i) = b(i) + end do + !$omp end target teams distribute +end subroutine -- 2.7.4