From: Jakub Jelinek Date: Fri, 19 Aug 2016 15:27:40 +0000 (+0200) Subject: re PR fortran/69281 (gfortran ICE on temporary array in function call with -fstack... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=94e73c786980bd8b84c935952a05e02b9c55e05b;p=gcc.git 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 --- diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index cfc70c1b9e8..11767cdb297 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2016-08-19 Jakub Jelinek + + 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 * intrinsics.texi (RANDOM_NUMBER): Remove reference to diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index 0d646edca11..3f5db965822 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -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 (); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3807dd5e806..a4ae65dd6dd 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-08-19 Jakub Jelinek + + PR fortran/69281 + * gfortran.dg/gomp/pr69281.f90: New test. + 2016-08-19 Janne Blomqvist * gfortran.dg/random_4.f90: Initialize seed before using, handle diff --git a/gcc/testsuite/gfortran.dg/gomp/pr69281.f90 b/gcc/testsuite/gfortran.dg/gomp/pr69281.f90 new file mode 100644 index 00000000000..f323484a9b2 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/pr69281.f90 @@ -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