diff --git a/gcc/fortran/match.h b/gcc/fortran/match.h index aac16a8d3d0f2d931cb1c6fe958c23c210345d73..5127b4b8ea3563b3ee032210c915159800a713b6 100644 --- a/gcc/fortran/match.h +++ b/gcc/fortran/match.h @@ -175,6 +175,7 @@ match gfc_match_omp_masked_taskloop_simd (void); match gfc_match_omp_master (void); match gfc_match_omp_master_taskloop (void); match gfc_match_omp_master_taskloop_simd (void); +match gfc_match_omp_nothing (void); match gfc_match_omp_ordered (void); match gfc_match_omp_ordered_depend (void); match gfc_match_omp_parallel (void); diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index 9675b6584093bf8395ebe3475e9adab272eecae1..fd219dc9c4d7e13758495a0e511ee26238c6d512 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -4797,6 +4797,17 @@ gfc_match_omp_ordered (void) return match_omp (EXEC_OMP_ORDERED, OMP_ORDERED_CLAUSES); } +match +gfc_match_omp_nothing (void) +{ + if (gfc_match_omp_eos () != MATCH_YES) + { + gfc_error ("Unexpected junk after $OMP NOTHING statement at %C"); + return MATCH_ERROR; + } + /* Will use ST_NONE; therefore, no EXEC_OMP_ is needed. */ + return MATCH_YES; +} match gfc_match_omp_ordered_depend (void) diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index 24cc9bfb9f1d7f3d60ea1b13b895db5248ebbf98..d004732677cfaec03aaec862ee01872ce8edb56e 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -1005,6 +1005,9 @@ decode_omp_directive (void) ST_OMP_MASTER_TASKLOOP); matcho ("master", gfc_match_omp_master, ST_OMP_MASTER); break; + case 'n': + matcho ("nothing", gfc_match_omp_nothing, ST_NONE); + break; case 'l': matcho ("loop", gfc_match_omp_loop, ST_OMP_LOOP); break; diff --git a/gcc/testsuite/gfortran.dg/nothing-1.f90 b/gcc/testsuite/gfortran.dg/nothing-1.f90 new file mode 100644 index 0000000000000000000000000000000000000000..9fc24d4bd6ca8fbc0cf3ee8235bd14abee91708e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/nothing-1.f90 @@ -0,0 +1,28 @@ +module m + implicit none (type, external) + !$omp nothing + + type t + !$omp nothing + integer s + end type + +contains + +integer function foo (i) + integer :: i + + !$omp nothing + if (.false.) & +& & !$omp nothing + i = i + 1 + +! In the following, '& & !$' is not a valid OpenMP sentinel and, +! hence, the line is regarded as comment + if (.false.) & +& & !$omp nothing + then + end if + foo = i +end +end module diff --git a/gcc/testsuite/gfortran.dg/nothing-2.f90 b/gcc/testsuite/gfortran.dg/nothing-2.f90 new file mode 100644 index 0000000000000000000000000000000000000000..74a4a5a22b0f78b720e1b91b47d6ac4915b92945 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/nothing-2.f90 @@ -0,0 +1,7 @@ +pure subroutine foo + !$omp nothing ! { dg-error "OpenMP directives other than SIMD or DECLARE TARGET at .1. may not appear in PURE procedures" } +end subroutine + +subroutine bar + !$omp nothing foo ! { dg-error "Unexpected junk after $OMP NOTHING statement" } +end