]> gcc.gnu.org Git - gcc.git/commitdiff
Fortran: OpenMP fix declare simd inside modules and absent linear step [PR106566]
authorTobias Burnus <tobias@codesourcery.com>
Tue, 23 Aug 2022 09:29:23 +0000 (11:29 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Tue, 23 Aug 2022 09:29:23 +0000 (11:29 +0200)
Partial backport from commit r13-2093, only, as 'OpenMP 5.2 linear
clause syntax' is not on GCC 12.

gcc/fortran/ChangeLog:

PR fortran/106566
* openmp.cc (gfc_match_omp_declare_simd): Accept module procedures.

gcc/testsuite/ChangeLog:

PR fortran/106566
* gfortran.dg/gomp/declare-simd-6.f90: New test.

(cherry picked from commit 1513512ec7d0751cba30c9c8804f2be462acfb9b)

gcc/fortran/openmp.cc
gcc/testsuite/gfortran.dg/gomp/declare-simd-6.f90 [new file with mode: 0644]

index 5018a37ec462627d7ed200d78f57745f2ee4d270..14f2521f1df31afc757b005061a0cee3cd6e39cb 100644 (file)
@@ -4027,9 +4027,13 @@ gfc_match_omp_declare_simd (void)
   gfc_omp_declare_simd *ods;
   bool needs_space = false;
 
-  switch (gfc_match (" ( %s ) ", &proc_name))
+  switch (gfc_match (" ( "))
     {
-    case MATCH_YES: break;
+    case MATCH_YES:
+      if (gfc_match_symbol (&proc_name, /* host assoc = */ true) != MATCH_YES
+         || gfc_match (" ) ") != MATCH_YES)
+       return MATCH_ERROR;
+      break;
     case MATCH_NO: proc_name = NULL; needs_space = true; break;
     case MATCH_ERROR: return MATCH_ERROR;
     }
diff --git a/gcc/testsuite/gfortran.dg/gomp/declare-simd-6.f90 b/gcc/testsuite/gfortran.dg/gomp/declare-simd-6.f90
new file mode 100644 (file)
index 0000000..83f2c0a
--- /dev/null
@@ -0,0 +1,42 @@
+! { dg-do compile }
+! { dg-additional-options "-fdump-tree-gimple" }
+!
+! PR fortran/106566
+!
+! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare simd \\(linear\\(ref\\(0\\):4\\) simdlen\\(8\\)\\)\\)\\)" 2 "gimple" } }
+! { dg-final { scan-tree-dump-times "__attribute__\\(\\(omp declare simd \\(linear\\(ref\\(0\\):8\\) simdlen\\(8\\)\\)\\)\\)" 2 "gimple" } }
+
+subroutine add_one2(p)
+  implicit none
+  !$omp declare simd(add_one2) linear(ref(p)) simdlen(8)
+  integer(kind=4) :: p
+
+  p = p + 1
+end subroutine
+
+subroutine linear_add_one2(p)
+  implicit none
+  !$omp declare simd(linear_add_one2) linear(ref(p) : 2) simdlen(8)
+  integer(kind=4) :: p
+
+  p = p + 1
+end subroutine
+
+module m
+   integer, parameter :: NN = 1023
+   integer(kind=4) :: a(NN)
+contains
+  subroutine module_add_one2(q)
+    implicit none
+    !$omp declare simd(module_add_one2) linear(ref(q)) simdlen(8)
+    integer(kind=4) :: q
+    q = q + 1
+  end subroutine
+
+  subroutine linear_add_one2(q)
+    implicit none
+    !$omp declare simd(linear_add_one2) linear(ref(q) : 2) simdlen(8)
+    integer(kind=4) :: q
+    q = q + 1
+  end subroutine
+end module
This page took 0.099457 seconds and 5 git commands to generate.