From: Jakub Jelinek Date: Wed, 22 Jan 2020 08:50:53 +0000 (+0100) Subject: openmp: Teach omp_code_to_statement about rest of OpenMP statements X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a38979d9d7a4ab08336436052704028c56187618;p=gcc.git 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 PR fortran/93329 * openmp.c (omp_code_to_statement): Handle remaining EXEC_OMP_* cases. * gfortran.dg/goacc/pr93329.f90: New test. --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 8d963a56b66..031c75bb5e5 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2020-01-22 Jakub Jelinek + + PR fortran/93329 + * openmp.c (omp_code_to_statement): Handle remaining EXEC_OMP_* + cases. + 2020-01-21 Tobias Burnus PR fortran/93309 diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index 10622129659..3c613855639 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -5898,6 +5898,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 08c81e1bf8a..0c04921f60d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,4 +1,9 @@ -2020-01-22 Jun Ma +2020-01-22 Jakub Jelinek + + PR fortran/93329 + * gfortran.dg/goacc/pr93329.f90: New test. + +2020-01-22 Jun Ma * g++.dg/coroutines/coro1-missing-await-method.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..aed264a03e9 --- /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 ! { dg-error "OMP TARGET SIMD directive cannot be specified within" } + 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