public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/redhat/heads/gcc-8-branch)] openmp: Teach omp_code_to_statement about rest of OpenMP statements
@ 2020-09-17 16:41 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2020-09-17 16:41 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5a12eb46119b3b4a40ba97702efdb81a07f7a054

commit 5a12eb46119b3b4a40ba97702efdb81a07f7a054
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Feb 14 15:41:59 2020 +0100

    openmp: Teach omp_code_to_statement about rest of OpenMP statements
    
    The omp_code_to_statement function added with the initial OpenACC support
    only handled small subset of the OpenMP statements, leading to ICE if
    any other OpenMP directive appeared inside of OpenACC directive.
    
    2020-01-22  Jakub Jelinek  <jakub@redhat.com>
    
            PR fortran/93329
            * openmp.c (omp_code_to_statement): Handle remaining EXEC_OMP_*
            cases.
    
            * gfortran.dg/goacc/pr93329.f90: New test.

Diff:
---
 gcc/fortran/ChangeLog                       |   6 +
 gcc/fortran/openmp.c                        |  75 ++++++++++
 gcc/testsuite/ChangeLog                     |   3 +
 gcc/testsuite/gfortran.dg/goacc/pr93329.f90 | 223 ++++++++++++++++++++++++++++
 4 files changed, 307 insertions(+)

diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index e922c1ee652..1f17116065a 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,6 +1,12 @@
 2020-02-14  Jakub Jelinek  <jakub@redhat.com>
 
 	Backported from mainline
+	2020-01-22  Jakub Jelinek  <jakub@redhat.com>
+
+	PR fortran/93329
+	* openmp.c (omp_code_to_statement): Handle remaining EXEC_OMP_*
+	cases.
+
 	2019-12-19  Jakub Jelinek  <jakub@redhat.com>
 
 	PR fortran/92977
diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c
index 707c43cee62..5c319805c2c 100644
--- a/gcc/fortran/openmp.c
+++ b/gcc/fortran/openmp.c
@@ -5689,6 +5689,81 @@ omp_code_to_statement (gfc_code *code)
       return ST_OMP_PARALLEL_WORKSHARE;
     case EXEC_OMP_DO:
       return ST_OMP_DO;
+    case EXEC_OMP_ATOMIC:
+      return ST_OMP_ATOMIC;
+    case EXEC_OMP_BARRIER:
+      return ST_OMP_BARRIER;
+    case EXEC_OMP_CANCEL:
+      return ST_OMP_CANCEL;
+    case EXEC_OMP_CANCELLATION_POINT:
+      return ST_OMP_CANCELLATION_POINT;
+    case EXEC_OMP_FLUSH:
+      return ST_OMP_FLUSH;
+    case EXEC_OMP_DISTRIBUTE:
+      return ST_OMP_DISTRIBUTE;
+    case EXEC_OMP_DISTRIBUTE_PARALLEL_DO:
+      return ST_OMP_DISTRIBUTE_PARALLEL_DO;
+    case EXEC_OMP_DISTRIBUTE_PARALLEL_DO_SIMD:
+      return ST_OMP_DISTRIBUTE_PARALLEL_DO_SIMD;
+    case EXEC_OMP_DISTRIBUTE_SIMD:
+      return ST_OMP_DISTRIBUTE_SIMD;
+    case EXEC_OMP_DO_SIMD:
+      return ST_OMP_DO_SIMD;
+    case EXEC_OMP_SIMD:
+      return ST_OMP_SIMD;
+    case EXEC_OMP_TARGET:
+      return ST_OMP_TARGET;
+    case EXEC_OMP_TARGET_DATA:
+      return ST_OMP_TARGET_DATA;
+    case EXEC_OMP_TARGET_ENTER_DATA:
+      return ST_OMP_TARGET_ENTER_DATA;
+    case EXEC_OMP_TARGET_EXIT_DATA:
+      return ST_OMP_TARGET_EXIT_DATA;
+    case EXEC_OMP_TARGET_PARALLEL:
+      return ST_OMP_TARGET_PARALLEL;
+    case EXEC_OMP_TARGET_PARALLEL_DO:
+      return ST_OMP_TARGET_PARALLEL_DO;
+    case EXEC_OMP_TARGET_PARALLEL_DO_SIMD:
+      return ST_OMP_TARGET_PARALLEL_DO_SIMD;
+    case EXEC_OMP_TARGET_SIMD:
+      return ST_OMP_TARGET_SIMD;
+    case EXEC_OMP_TARGET_TEAMS:
+      return ST_OMP_TARGET_TEAMS;
+    case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE:
+      return ST_OMP_TARGET_TEAMS_DISTRIBUTE;
+    case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO:
+      return ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO;
+    case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
+      return ST_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD;
+    case EXEC_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD:
+      return ST_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD;
+    case EXEC_OMP_TARGET_UPDATE:
+      return ST_OMP_TARGET_UPDATE;
+    case EXEC_OMP_TASKGROUP:
+      return ST_OMP_TASKGROUP;
+    case EXEC_OMP_TASKLOOP:
+      return ST_OMP_TASKLOOP;
+    case EXEC_OMP_TASKLOOP_SIMD:
+      return ST_OMP_TASKLOOP_SIMD;
+    case EXEC_OMP_TASKWAIT:
+      return ST_OMP_TASKWAIT;
+    case EXEC_OMP_TASKYIELD:
+      return ST_OMP_TASKYIELD;
+    case EXEC_OMP_TEAMS:
+      return ST_OMP_TEAMS;
+    case EXEC_OMP_TEAMS_DISTRIBUTE:
+      return ST_OMP_TEAMS_DISTRIBUTE;
+    case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO:
+      return ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO;
+    case EXEC_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD:
+      return ST_OMP_TEAMS_DISTRIBUTE_PARALLEL_DO_SIMD;
+    case EXEC_OMP_TEAMS_DISTRIBUTE_SIMD:
+      return ST_OMP_TEAMS_DISTRIBUTE_SIMD;
+    case EXEC_OMP_PARALLEL_DO:
+      return ST_OMP_PARALLEL_DO;
+    case EXEC_OMP_PARALLEL_DO_SIMD:
+      return ST_OMP_PARALLEL_DO_SIMD;
+
     default:
       gcc_unreachable ();
     }
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8419f94444e..cbde5a03c5e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -3,6 +3,9 @@
 	Backported from mainline
 	2020-01-21  Jakub Jelinek  <jakub@redhat.com>
 
+	PR target/93333
+	* gcc.c-torture/compile/pr93333.c: New test.
+
 	PR target/93073
 	* gcc.target/powerpc/pr93073.c: New test.
 
diff --git a/gcc/testsuite/gfortran.dg/goacc/pr93329.f90 b/gcc/testsuite/gfortran.dg/goacc/pr93329.f90
new file mode 100644
index 00000000000..e1feafd2ba2
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/pr93329.f90
@@ -0,0 +1,223 @@
+! PR fortran/93329
+! { dg-do compile { target fopenmp } }
+! { dg-additional-options "-fopenmp" }
+
+  integer :: x, y, z
+  integer :: a(32)
+!$acc kernels copyout(x)
+!$omp target map(from:x)	! { dg-error "OMP TARGET directive cannot be specified within" }
+  x = 5
+!$omp end target
+!$acc end kernels
+  print *, x
+!$acc kernels
+!$omp atomic			! { dg-error "OMP ATOMIC directive cannot be specified within" }
+  x = x + 1
+!$omp end atomic
+!$acc end kernels
+!$acc kernels
+!$omp barrier			! { dg-error "OMP BARRIER directive cannot be specified within" }
+!$acc end kernels
+!$acc kernels
+!$omp cancel parallel		! { dg-error "OMP CANCEL directive cannot be specified within" }
+!$acc end kernels
+!$acc kernels
+!$omp cancellation point parallel	! { dg-error "OMP CANCELLATION POINT directive cannot be specified within" }
+!$acc end kernels
+!$acc kernels
+!$omp flush			! { dg-error "OMP FLUSH directive cannot be specified within" }
+!$acc end kernels
+!$acc kernels
+!$omp distribute		! { dg-error "OMP DISTRIBUTE directive cannot be specified within" }
+  do x = 0, 2
+  end do
+!$acc end kernels
+!$acc kernels
+!$omp distribute parallel do	! { dg-error "OMP DISTRIBUTE PARALLEL DO directive cannot be specified within" }
+  do x = 0, 2
+  end do
+!$acc end kernels
+!$acc kernels
+!$omp distribute parallel do simd	! { dg-error "OMP DISTRIBUTE PARALLEL DO SIMD directive cannot be specified within" }
+  do x = 0, 2
+  end do
+!$acc end kernels
+!$acc kernels
+!$omp distribute simd		! { dg-error "OMP DISTRIBUTE SIMD directive cannot be specified within" }
+  do x = 0, 2
+  end do
+!$acc end kernels
+!$acc kernels
+!$omp do simd			! { dg-error "OMP DO SIMD directive cannot be specified within" }
+  do x = 0, 2
+  end do
+!$acc end kernels
+!$acc kernels
+!$omp simd			! { dg-error "OMP SIMD directive cannot be specified within" }
+  do x = 0, 2
+  end do
+!$acc end kernels
+!$acc kernels
+!$omp target data map(from: x)	! { dg-error "OMP TARGET DATA directive cannot be specified within" }
+!$omp end target data
+!$acc end kernels
+!$acc kernels
+!$omp target enter data map(to: x)	! { dg-error "OMP TARGET ENTER DATA directive cannot be specified within" }
+!$acc end kernels
+!$acc kernels
+!$omp target exit data map(from: x)	! { dg-error "OMP TARGET EXIT DATA directive cannot be specified within" }
+!$acc end kernels
+!$acc kernels
+!!$omp target parallel
+!!$omp end target parallel
+!$acc end kernels
+!$acc kernels
+!$omp target parallel do	! { dg-error "OMP TARGET PARALLEL DO directive cannot be specified within" }
+  do x = 0, 2
+  end do
+!$acc end kernels
+!$acc kernels
+!$omp target parallel do simd	! { dg-error "OMP TARGET PARALLEL DO SIMD directive cannot be specified within" }
+  do x = 0, 2
+  end do
+!$acc end kernels
+!$acc kernels
+!!$omp target simd
+!  do x = 0, 2
+!  end do
+!$acc end kernels
+!$acc kernels
+!$omp target teams		! { dg-error "OMP TARGET TEAMS directive cannot be specified within" }
+!$omp end target teams
+!$acc end kernels
+!$acc kernels
+!$omp target teams distribute	! { dg-error "OMP TARGET TEAMS DISTRIBUTE directive cannot be specified within" }
+  do x = 0, 2
+  end do
+!$acc end kernels
+!$acc kernels
+!$omp target teams distribute parallel do	! { dg-error "OMP TARGET TEAMS DISTRIBUTE PARALLEL DO directive cannot be specified within" }
+  do x = 0, 2
+  end do
+!$acc end kernels
+!$acc kernels
+!$omp target teams distribute parallel do simd	! { dg-error "OMP TARGET TEAMS DISTRIBUTE PARALLEL DO SIMD directive cannot be specified within" }
+  do x = 0, 2
+  end do
+!$acc end kernels
+!$acc kernels
+!$omp target teams distribute simd	! { dg-error "OMP TARGET TEAMS DISTRIBUTE SIMD directive cannot be specified within" }
+  do x = 0, 2
+  end do
+!$acc end kernels
+!$acc kernels
+!$omp target update to(x)	! { dg-error "OMP TARGET UPDATE directive cannot be specified within" }
+!$acc end kernels
+!$acc kernels
+!$omp taskgroup			! { dg-error "OMP TASKGROUP directive cannot be specified within" }
+!$omp end taskgroup
+!$acc end kernels
+!$acc kernels
+!$omp taskloop			! { dg-error "OMP TASKLOOP directive cannot be specified within" }
+  do x = 0, 2
+  end do
+!$acc end kernels
+!$acc kernels
+!$omp taskloop simd		! { dg-error "OMP TASKLOOP SIMD directive cannot be specified within" }
+  do x = 0, 2
+  end do
+!$acc end kernels
+!$acc kernels
+!$omp taskwait			! { dg-error "OMP TASKWAIT directive cannot be specified within" }
+!$acc end kernels
+!$acc kernels
+!$omp taskyield			! { dg-error "OMP TASKYIELD directive cannot be specified within" }
+!$acc end kernels
+!$acc kernels
+!$omp teams			! { dg-error "OMP TEAMS directive cannot be specified within" }
+!$omp end teams
+!$acc end kernels
+!$acc kernels
+!$omp teams distribute		! { dg-error "OMP TEAMS DISTRIBUTE directive cannot be specified within" }
+  do x = 0, 2
+  end do
+!$acc end kernels
+!$acc kernels
+!$omp teams distribute parallel do	! { dg-error "OMP TEAMS DISTRIBUTE PARALLEL DO directive cannot be specified within" }
+  do x = 0, 2
+  end do
+!$acc end kernels
+!$acc kernels
+!$omp teams distribute parallel do simd	! { dg-error "OMP TEAMS DISTRIBUTE PARALLEL DO SIMD directive cannot be specified within" }
+  do x = 0, 2
+  end do
+!$acc end kernels
+!$acc kernels
+!$omp teams distribute simd	! { dg-error "OMP TEAMS DISTRIBUTE SIMD directive cannot be specified within" }
+  do x = 0, 2
+  end do
+!$acc end kernels
+!$acc kernels
+!$omp parallel do		! { dg-error "OMP PARALLEL DO directive cannot be specified within" }
+  do x = 0, 2
+  end do
+!$acc end kernels
+!$acc kernels
+!$omp parallel do simd		! { dg-error "OMP PARALLEL DO SIMD directive cannot be specified within" }
+  do x = 0, 2
+  end do
+!$acc end kernels
+!$acc kernels
+!$omp parallel			! { dg-error "OMP PARALLEL directive cannot be specified within" }
+!$omp end parallel
+!$acc end kernels
+!$acc kernels
+!$omp parallel sections		! { dg-error "OMP PARALLEL SECTIONS directive cannot be specified within" }
+  y = 1
+!$omp section
+  z = 2
+!$omp end parallel sections
+!$acc end kernels
+!$acc kernels
+!$omp sections			! { dg-error "OMP SECTIONS directive cannot be specified within" }
+  y = 1
+!$omp section
+  z = 2
+!$omp end sections
+!$acc end kernels
+!$acc kernels
+!$omp ordered			! { dg-error "OMP ORDERED directive cannot be specified within" }
+!$omp end ordered
+!$acc end kernels
+!$acc kernels
+!$omp critical			! { dg-error "OMP CRITICAL directive cannot be specified within" }
+!$omp end critical
+!$acc end kernels
+!$acc kernels
+!$omp master			! { dg-error "OMP MASTER directive cannot be specified within" }
+!$omp end master
+!$acc end kernels
+!$acc kernels
+!$omp single			! { dg-error "OMP SINGLE directive cannot be specified within" }
+!$omp end single
+!$acc end kernels
+!$acc kernels
+!$omp task			! { dg-error "OMP TASK directive cannot be specified within" }
+!$omp end task
+!$acc end kernels
+!$acc kernels
+!$omp workshare			! { dg-error "OMP WORKSHARE directive cannot be specified within" }
+  a(:) = 1
+!$omp end workshare
+!$acc end kernels
+!$acc kernels
+!$omp parallel workshare	! { dg-error "OMP PARALLEL WORKSHARE directive cannot be specified within" }
+  a(:) = 1
+!$omp end parallel workshare
+!$acc end kernels
+!$acc kernels
+!$omp do			! { dg-error "OMP DO directive cannot be specified within" }
+  do x = 0, 2
+  end do
+!$acc end kernels
+end


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-09-17 16:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 16:41 [gcc(refs/vendors/redhat/heads/gcc-8-branch)] openmp: Teach omp_code_to_statement about rest of OpenMP statements Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).