From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1534) id E07BE3858C50; Thu, 9 Feb 2023 10:01:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E07BE3858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675936879; bh=GntfPF606KwFz04WwmUuIYf1Ov5BvY9xRe885ax7NC4=; h=From:To:Subject:Date:From; b=weDBHGr5pUk4v87+76jufEB4KqHi7hz1b5IZ5ZlUxgctEkjxPDu0qi/SO0XKOB42o cx98FhFA0Svt7sLbJKwjPktfKk2tCxcOZJZ54Q6eBmyEeN1PNlFtVq6pDmKI0b7kxP QS0N83S4DqVlp7XWDVLEuJPSdTbX7vhIJFRYdoN8= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Tobias Burnus To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-5753] Fortran/OpenMP: Fix -fopenmp-simd for 'omp assume(s)' X-Act-Checkin: gcc X-Git-Author: Tobias Burnus X-Git-Refname: refs/heads/master X-Git-Oldrev: 9453e3cd0ffd0c377a648b83a9a5fdc5809e60d7 X-Git-Newrev: ae091a44f6a477fbcf463e80fd604540cad3b37f Message-Id: <20230209100119.E07BE3858C50@sourceware.org> Date: Thu, 9 Feb 2023 10:01:19 +0000 (GMT) List-Id: https://gcc.gnu.org/g:ae091a44f6a477fbcf463e80fd604540cad3b37f commit r13-5753-gae091a44f6a477fbcf463e80fd604540cad3b37f Author: Tobias Burnus Date: Thu Feb 9 10:58:00 2023 +0100 Fortran/OpenMP: Fix -fopenmp-simd for 'omp assume(s)' While 'omp assume' is enabled by -fopenmp-simd, 'omp assumes' is not; however, due to the way parsing works in Fortran (esp. for fixed-form source code), 'assumes' was parsed by 'assume' which then stumbled over the tailing 's'. gcc/fortran/ * parse.cc (decode_omp_directive): Really ignore 'assumes' with -fopenmp-simd. gcc/testsuite/ * gfortran.dg/gomp/openmp-simd-8.f90: New test. Diff: --- gcc/fortran/parse.cc | 3 +++ gcc/testsuite/gfortran.dg/gomp/openmp-simd-8.f90 | 25 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc index 039e7e7da53..f5154d97ae8 100644 --- a/gcc/fortran/parse.cc +++ b/gcc/fortran/parse.cc @@ -885,6 +885,9 @@ decode_omp_directive (void) switch (c) { case 'a': + /* For -fopenmp-simd, ignore 'assumes'; note no clause starts with 's'. */ + if (!flag_openmp && gfc_match ("assumes") == MATCH_YES) + break; matcho ("assumes", gfc_match_omp_assumes, ST_OMP_ASSUMES); matchs ("assume", gfc_match_omp_assume, ST_OMP_ASSUME); matcho ("atomic", gfc_match_omp_atomic, ST_OMP_ATOMIC); diff --git a/gcc/testsuite/gfortran.dg/gomp/openmp-simd-8.f90 b/gcc/testsuite/gfortran.dg/gomp/openmp-simd-8.f90 new file mode 100644 index 00000000000..cf92abf2f9e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/openmp-simd-8.f90 @@ -0,0 +1,25 @@ +! { dg-options "-fno-openmp -fopenmp-simd -fdump-tree-original" } + +! While 'omp assumes' is ignored with -fopenmp-simd, +! 'omp assume' is processed - check that this works. + +module m + !$omp assumes no_openmp invalid_clause ! Should get ignored +contains + integer function foo() + foo = 5 + end function +end + +program main + use m + implicit none + !$omp assumes no_openmp ! likewise ignored + integer :: n + !$omp assume holds (foo() > 0) ! should be honoured + n = foo() + if (n == 0) stop + !$omp end assume +end + +! { dg-final { scan-tree-dump "\\.ASSUME \\(foo \\(\\) > 0\\);" "original" } }