diff mbox

[committed] Fix ICE with !$omp parallel workshare (PR fortran/77352)

Message ID 20160831184832.GR14857@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Aug. 31, 2016, 6:48 p.m. UTC
Hi!

This is something I've fixed recently for a couple of construct, but left
parallel workshare untouched.  Bootstrapped/regtested on x86_64-linux and
i686-linux, committed to trunk.

2016-08-31  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/77352
	* trans-openmp.c (gfc_trans_omp_parallel_workshare): Always add a
	BIND_EXPR with BLOCK around what gfc_trans_omp_workshare returns.

	* gfortran.dg/gomp/pr77352.f90: New test.


	Jakub
diff mbox

Patch

--- gcc/fortran/trans-openmp.c.jj	2016-08-19 17:27:03.000000000 +0200
+++ gcc/fortran/trans-openmp.c	2016-08-31 10:00:54.378338571 +0200
@@ -4001,10 +4001,7 @@  gfc_trans_omp_parallel_workshare (gfc_co
 				       code->loc);
   pushlevel ();
   stmt = gfc_trans_omp_workshare (code, &workshare_clauses);
-  if (TREE_CODE (stmt) != BIND_EXPR)
-    stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0));
-  else
-    poplevel (0, 0);
+  stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0));
   stmt = build2_loc (input_location, OMP_PARALLEL, void_type_node, stmt,
 		     omp_clauses);
   OMP_PARALLEL_COMBINED (stmt) = 1;
--- gcc/testsuite/gfortran.dg/gomp/pr77352.f90.jj	2016-08-31 10:04:19.385733738 +0200
+++ gcc/testsuite/gfortran.dg/gomp/pr77352.f90	2016-08-31 10:05:48.744602500 +0200
@@ -0,0 +1,16 @@ 
+! PR fortran/77352
+! { dg-do compile }
+! { dg-additional-options "-fstack-arrays -O2" }
+! { dg-additional-options "-fopenacc" { target fopenacc } }
+
+program pr77352
+  real, allocatable :: a(:,:), b(:)
+  integer :: m, n
+  m = 4
+  n = 2
+  allocate (a(m,n), b(m))
+  a = 1.0
+!$omp parallel workshare
+  b(:) = [ sum(a, dim=1) ]
+!$omp end parallel workshare
+end