]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fortran: Add OpenMP's nothing directive support
authorTobias Burnus <tobias@codesourcery.com>
Wed, 18 Aug 2021 13:27:06 +0000 (15:27 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Wed, 18 Aug 2021 13:27:06 +0000 (15:27 +0200)
Fortran version of commit 5079b7781a2c506dcdfb241347d74c7891268225

gcc/fortran/ChangeLog:

* match.h (gfc_match_omp_nothing): New.
* openmp.c (gfc_match_omp_nothing): New.
* parse.c (decode_omp_directive): Match 'nothing' directive.

gcc/testsuite/ChangeLog:

* gfortran.dg/nothing-1.f90: New test.
* gfortran.dg/nothing-2.f90: New test.

(cherry picked from commit f74433e70ae94a3b5291e45fea488b1cfdee4a34)

gcc/fortran/ChangeLog.omp
gcc/fortran/match.h
gcc/fortran/openmp.c
gcc/fortran/parse.c
gcc/testsuite/ChangeLog.omp
gcc/testsuite/gfortran.dg/nothing-1.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/nothing-2.f90 [new file with mode: 0644]

index 53456078b65c7336fae021b34b6f29168373bc87..7db917878d9c205d33217efc1420863058531bd5 100644 (file)
@@ -1,3 +1,12 @@
+2021-08-18  Tobias Burnus  <tobias@codesourcery.com>
+
+       Backported from master:
+       2021-08-18  Tobias Burnus  <tobias@codesourcery.com>
+
+       * match.h (gfc_match_omp_nothing): New.
+       * openmp.c (gfc_match_omp_nothing): New.
+       * parse.c (decode_omp_directive): Match 'nothing' directive.
+
 2021-08-17  Tobias Burnus  <tobias@codesourcery.com>
 
        Backported from master:
index aac16a8d3d0f2d931cb1c6fe958c23c210345d73..5127b4b8ea3563b3ee032210c915159800a713b6 100644 (file)
@@ -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);
index 4cd95f568185047086798a47bf3228d803ff0d61..420f4f16e13163347ad9cd76f55815a14e0b24b1 100644 (file)
@@ -4786,6 +4786,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)
index c7cb590ae29ec4925f5c5b7e9805e9e6677c4800..1f8bcc616782ad34c012dc7caa26820d0336c5c2 100644 (file)
@@ -1007,6 +1007,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;
index 27c518d2c83f24a44ed29990d2160f8a4c7fc769..1a3c8e65783f42a061ca9aec246033d2fac93a5b 100644 (file)
@@ -1,3 +1,11 @@
+2021-08-18  Tobias Burnus  <tobias@codesourcery.com>
+
+       Backported from master:
+       2021-08-18  Tobias Burnus  <tobias@codesourcery.com>
+
+       * gfortran.dg/nothing-1.f90: New test.
+       * gfortran.dg/nothing-2.f90: New test.
+
 2021-08-18  Tobias Burnus  <tobias@codesourcery.com>
 
        Backported from master:
diff --git a/gcc/testsuite/gfortran.dg/nothing-1.f90 b/gcc/testsuite/gfortran.dg/nothing-1.f90
new file mode 100644 (file)
index 0000000..9fc24d4
--- /dev/null
@@ -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 (file)
index 0000000..74a4a5a
--- /dev/null
@@ -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