re PR fortran/69281 (gfortran ICE on temporary array in function call with -fstack-arrays -fopenmp)

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.

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

From-SVN: r239618
This commit is contained in:
Jakub Jelinek 2016-08-19 17:27:40 +02:00 committed by Jakub Jelinek
parent b5fd0b71fe
commit 94e73c7869
4 changed files with 84 additions and 1 deletions

View file

@ -1,3 +1,10 @@
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

View file

@ -3554,7 +3554,9 @@ gfc_trans_omp_parallel (gfc_code *code)
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);
@ -4062,7 +4064,9 @@ gfc_trans_omp_task (gfc_code *code)
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);
@ -4215,7 +4219,11 @@ gfc_trans_omp_target (gfc_code *code)
= 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 ();

View file

@ -1,3 +1,8 @@
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

View file

@ -0,0 +1,63 @@
! 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