+2016-08-19 Jakub Jelinek <jakub@redhat.com>
+
+ PR fortran/69281
+ * trans-openmp.c (gfc_trans_omp_parallel, gfc_trans_omp_task,
+ gfc_trans_omp_target): Wrap gfc_trans_omp_code result in an extra
+ BIND_EXPR with its own forced BLOCK.
+
2016-08-19 Janne Blomqvist <jb@gcc.gnu.org>
* intrinsics.texi (RANDOM_NUMBER): Remove reference to
gfc_start_block (&block);
omp_clauses = gfc_trans_omp_clauses (&block, code->ext.omp_clauses,
code->loc);
+ pushlevel ();
stmt = gfc_trans_omp_code (code->block->next, true);
+ stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0));
stmt = build2_loc (input_location, OMP_PARALLEL, void_type_node, stmt,
omp_clauses);
gfc_add_expr_to_block (&block, stmt);
gfc_start_block (&block);
omp_clauses = gfc_trans_omp_clauses (&block, code->ext.omp_clauses,
code->loc);
+ pushlevel ();
stmt = gfc_trans_omp_code (code->block->next, true);
+ stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0));
stmt = build2_loc (input_location, OMP_TASK, void_type_node, stmt,
omp_clauses);
gfc_add_expr_to_block (&block, stmt);
= gfc_trans_omp_clauses (&block, &clausesa[GFC_OMP_SPLIT_TARGET],
code->loc);
if (code->op == EXEC_OMP_TARGET)
- stmt = gfc_trans_omp_code (code->block->next, true);
+ {
+ pushlevel ();
+ stmt = gfc_trans_omp_code (code->block->next, true);
+ stmt = build3_v (BIND_EXPR, NULL, stmt, poplevel (1, 0));
+ }
else
{
pushlevel ();
+2016-08-19 Jakub Jelinek <jakub@redhat.com>
+
+ PR fortran/69281
+ * gfortran.dg/gomp/pr69281.f90: New test.
+
2016-08-19 Janne Blomqvist <jb@gcc.gnu.org>
* gfortran.dg/random_4.f90: Initialize seed before using, handle
--- /dev/null
+! PR fortran/69281
+! { dg-do compile }
+! { dg-additional-options "-fstack-arrays -O2" }
+
+program pr69281
+ implicit none
+ call foo1((/ 1, 3, 3, 7 /))
+ call foo2((/ 1, 3, 3, 7 /))
+ call foo3((/ 1, 3, 3, 7 /))
+ call foo4((/ 1, 3, 3, 7 /))
+ call foo5((/ 1, 3, 3, 7 /))
+ call foo6((/ 1, 3, 3, 7 /))
+contains
+ subroutine foo1(x)
+ integer, intent(in) :: x(:)
+ !$omp parallel
+ call baz(bar(x))
+ !$omp end parallel
+ end subroutine
+ subroutine foo2(x)
+ integer, intent(in) :: x(:)
+ !$omp task
+ call baz(bar(x))
+ !$omp end task
+ end subroutine
+ subroutine foo3(x)
+ integer, intent(in) :: x(:)
+ !$omp target
+ call baz(bar(x))
+ !$omp end target
+ end subroutine
+ subroutine foo4(x)
+ integer, intent(in) :: x(:)
+ !$omp target teams
+ call baz(bar(x))
+ !$omp end target teams
+ end subroutine
+ subroutine foo5(x)
+ integer, intent(in) :: x(:)
+ integer :: i
+ !$omp parallel do
+ do i = 1, 1
+ call baz(bar(x))
+ end do
+ end subroutine
+ subroutine foo6(x)
+ integer, intent(in) :: x(:)
+ integer :: i
+ !$omp target teams distribute parallel do
+ do i = 1, 1
+ call baz(bar(x))
+ end do
+ end subroutine
+ function bar(x) result(a)
+ integer, dimension(:), intent(in) :: x
+ integer, dimension(2,size(x)) :: a
+ a(1,:) = 1
+ a(2,:) = x
+ end function
+ subroutine baz(a)
+ integer, dimension(:,:), intent(in) :: a
+ end subroutine
+end program