From: Kwok Cheung Yeung Date: Thu, 25 Jun 2020 11:40:53 +0000 (-0700) Subject: fortran: Fix ICE when 'if' clause used with 'target parallel' (PR95869) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f530bac8a11da9c85bdd8e58d589747f9825e38d;p=gcc.git fortran: Fix ICE when 'if' clause used with 'target parallel' (PR95869) 2020-06-25 Tobias Burnus Kwok Cheung Yeung gcc/fortran/ PR fortran/95869 * trans-openmp.c (gfc_trans_omp_target): Use correct scoping block. gcc/testsuite/ PR fortran/95869 * gfortran.dg/gomp/combined-if.f90 (test_target_parallel): Re-enable. * gfortran.dg/gomp/pr95869.f90: New. --- diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index 67b709479ca..22f8f96a60e 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -5353,7 +5353,7 @@ gfc_trans_omp_target (gfc_code *code) pushlevel (); gfc_start_block (&iblock); tree inner_clauses - = gfc_trans_omp_clauses (&block, &clausesa[GFC_OMP_SPLIT_PARALLEL], + = gfc_trans_omp_clauses (&iblock, &clausesa[GFC_OMP_SPLIT_PARALLEL], code->loc); stmt = gfc_trans_omp_code (code->block->next, true); stmt = build2_loc (input_location, OMP_PARALLEL, void_type_node, stmt, diff --git a/gcc/testsuite/gfortran.dg/gomp/combined-if.f90 b/gcc/testsuite/gfortran.dg/gomp/combined-if.f90 index 383086ca97b..bf4a9a85d34 100644 --- a/gcc/testsuite/gfortran.dg/gomp/combined-if.f90 +++ b/gcc/testsuite/gfortran.dg/gomp/combined-if.f90 @@ -18,17 +18,15 @@ contains end do end subroutine - ! TODO: This currently fails with an internal compiler error - ! (PR 95869) - !subroutine test_target_parallel - ! do j = 1, N - ! !$omp target parallel if(j .lt. LIMIT) map(tofrom: a(1:N)) - ! do i = 1, N - ! a(i) = a(i) + 1 - ! end do - ! !$omp end target parallel - ! end do - !end subroutine + subroutine test_target_parallel + do j = 1, N + !$omp target parallel if(j .lt. LIMIT) map(tofrom: a(1:N)) + do i = 1, N + a(i) = a(i) + 1 + end do + !$omp end target parallel + end do + end subroutine subroutine test_target_parallel_loop do j = 1, N @@ -105,6 +103,6 @@ contains end module -! { dg-final { scan-tree-dump-times "(?n)#pragma omp target.* if\\(" 8 "omplower" } } +! { dg-final { scan-tree-dump-times "(?n)#pragma omp target.* if\\(" 9 "omplower" } } ! { dg-final { scan-tree-dump-times "(?n)#pragma omp simd.* if\\(" 7 "omplower" } } -! { dg-final { scan-tree-dump-times "(?n)#pragma omp parallel.* if\\(" 5 "omplower" } } +! { dg-final { scan-tree-dump-times "(?n)#pragma omp parallel.* if\\(" 6 "omplower" } } diff --git a/gcc/testsuite/gfortran.dg/gomp/pr95869.f90 b/gcc/testsuite/gfortran.dg/gomp/pr95869.f90 new file mode 100644 index 00000000000..daa8d214094 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/pr95869.f90 @@ -0,0 +1,18 @@ +! PR fortran/95869 +! { dg-do compile } + +program pr95869 + implicit none + + integer, parameter :: N = 100 + integer, parameter :: LIMIT = 60 + integer :: i, j + integer, dimension(N) :: a = (/ (i, i = 1,N) /) + do j = 1, N + !$omp target parallel if(j .lt. LIMIT) map(tofrom: a(1:N)) + do i = 1, N + a(i) = a(i) + 1 + end do + !$omp end target parallel + end do +end program