diff mbox

Fix PR72715

Message ID 61baf31c-0ba2-16c9-f222-059da4a22060@codesourcery.com
State New
Headers show

Commit Message

Cesar Philippidis Aug. 29, 2016, 9:33 p.m. UTC
It looks like the fortran FE has some preliminary support for do
concurrent loops, however it was not well tested, nor is do concurrent
supported by the OpenACC spec. This patch teaches the fortran FE to
error when an acc loop directive is applied to a do concurrent loop.

The reason why the existing do concurrent wasn't detected earlier is
because the only tests that utilized do concurrent loops contained other
expected failures, therefore the FE never successfully left the resolver
stage. And this ICE occurred as the loop was being translated into gimple.

There's one other questionably use of EXEC_DO_CONCURRENT that involves
the OpenACC cache directive. I've decided to leave gfc_exec_oacc_cache
alone for the time being because the OpenACC spec does not explicitly
define what it means by 'loop'. Then again, the user isn't required to
explicitly mark acc loops inside acc kernels regions, so perhaps it
would be better to leave the end user with more flexibility. On the
other hand, it's debatable whether do concurrent loops should even be
permitted inside acc offloaded regions.

I've applied this patch to gomp-4_0-branch. Is this OK for trunk, gcc-6
and gcc-5?

Cesar
diff mbox

Patch

2016-08-29  Cesar Philippidis  <cesar@codesourcery.com>

	PR fortran/72715

	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.


diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c
index cea37ea..83c6419 100644
--- a/gcc/fortran/openmp.c
+++ b/gcc/fortran/openmp.c
@@ -4998,7 +4998,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/gfortran.dg/goacc/loop-3-2.f95 b/gcc/testsuite/gfortran.dg/goacc/loop-3-2.f95
index 9be74a8..c091084 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 30930f4..ed3e8d5 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 0000000..68580f9
--- /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