From affd7d477acb4a19dd588e51e6d5597679d0391d Mon Sep 17 00:00:00 2001 From: Cesar Philippidis Date: Thu, 14 Feb 2019 05:44:19 -0800 Subject: [PATCH] Fix PR72715 "ICE in gfc_trans_omp_do, at fortran/trans-openmp.c:3164" The OpenACC 'resolve_oacc_nested_loops' function duplicates most code of the OpenMP 'resolve_omp_do', but didn't include the PR60127 "ICE with OpenMP and DO CONCURRENT" (trunk r210331) changes. (Probably the two functions should be unified?) The Fortran DO CONCURRENT construct is a way to tell the compiler that loop iterations don't have any interdependencies -- which is information that would very well be suitable for OpenACC/OpenMP loops. There are some "details" however, see the discussion/references in PR60127, so for the time being, make this a compile-time error instead of an ICE. gcc/fortran/ * openmp.c (resolve_oacc_nested_loops): Error on do concurrent loops. gcc/testsuite/ * gfortran.dg/goacc/loop-3-2.f95: Error on do concurrent loops. * gfortran.dg/goacc/loop-3.f95: Likewise. * gfortran.dg/goacc/pr72715.f90: New test. Reviewed-by: Thomas Schwinge From-SVN: r268875 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/openmp.c | 8 +++++++- gcc/testsuite/ChangeLog | 7 +++++++ gcc/testsuite/gfortran.dg/goacc/loop-3-2.f95 | 4 ++-- gcc/testsuite/gfortran.dg/goacc/loop-3.f95 | 4 ++-- gcc/testsuite/gfortran.dg/goacc/pr72715.f90 | 6 ++++++ 6 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/goacc/pr72715.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index c573f77410c..71cef4f1884 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2019-02-14 Cesar Philippidis + + PR fortran/72715 + * openmp.c (resolve_oacc_nested_loops): Error on do concurrent + loops. + 2019-02-13 Martin Liska PR fortran/88649 diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c index 15c5842dea4..8651afaee4f 100644 --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -5760,7 +5760,13 @@ resolve_oacc_nested_loops (gfc_code *code, gfc_code* do_code, int collapse, "at %L", &do_code->loc); break; } - gcc_assert (do_code->op == EXEC_DO || do_code->op == EXEC_DO_CONCURRENT); + if (do_code->op == EXEC_DO_CONCURRENT) + { + gfc_error ("!$ACC LOOP cannot be a DO CONCURRENT loop at %L", + &do_code->loc); + break; + } + gcc_assert (do_code->op == EXEC_DO); if (do_code->ext.iterator->var->ts.type != BT_INTEGER) gfc_error ("!$ACC LOOP iteration variable must be of type integer at %L", &do_code->loc); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index def998a14ee..6a649831c94 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2019-02-14 Cesar Philippidis + + PR fortran/72715 + * gfortran.dg/goacc/loop-3-2.f95: Error on do concurrent loops. + * gfortran.dg/goacc/loop-3.f95: Likewise. + * gfortran.dg/goacc/pr72715.f90: New test. + 2019-02-14 Martin Liska PR rtl-optimization/89242 diff --git a/gcc/testsuite/gfortran.dg/goacc/loop-3-2.f95 b/gcc/testsuite/gfortran.dg/goacc/loop-3-2.f95 index 9be74a85919..c091084a4f5 100644 --- a/gcc/testsuite/gfortran.dg/goacc/loop-3-2.f95 +++ b/gcc/testsuite/gfortran.dg/goacc/loop-3-2.f95 @@ -27,9 +27,9 @@ subroutine test1 !$acc end parallel !$acc end loop ! { dg-error "Unexpected" } - ! OpenACC supports Fortran 2008 do concurrent statement + ! OpenACC does not support Fortran 2008 do concurrent statement !$acc loop - do concurrent (i = 1:5) + do concurrent (i = 1:5) ! { dg-error "ACC LOOP cannot be a DO CONCURRENT loop" } end do !$acc loop diff --git a/gcc/testsuite/gfortran.dg/goacc/loop-3.f95 b/gcc/testsuite/gfortran.dg/goacc/loop-3.f95 index 30930f404f3..ed3e8d50a76 100644 --- a/gcc/testsuite/gfortran.dg/goacc/loop-3.f95 +++ b/gcc/testsuite/gfortran.dg/goacc/loop-3.f95 @@ -24,9 +24,9 @@ subroutine test1 !$acc end parallel !$acc end loop ! { dg-error "Unexpected" } - ! OpenACC supports Fortran 2008 do concurrent statement + ! OpenACC does not support Fortran 2008 do concurrent statement !$acc loop - do concurrent (i = 1:5) + do concurrent (i = 1:5) ! { dg-error "ACC LOOP cannot be a DO CONCURRENT loop" } end do !$acc loop diff --git a/gcc/testsuite/gfortran.dg/goacc/pr72715.f90 b/gcc/testsuite/gfortran.dg/goacc/pr72715.f90 new file mode 100644 index 00000000000..68580f9f7de --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/pr72715.f90 @@ -0,0 +1,6 @@ +program p + integer :: i + !$acc loop + do concurrent (i=1:3) ! { dg-error "ACC LOOP cannot be a DO CONCURRENT loop" } + end do +end program p