fortran: Fix ICE when 'if' clause used with 'target parallel' (PR95869)
authorKwok Cheung Yeung <kcy@codesourcery.com>
Thu, 25 Jun 2020 11:40:53 +0000 (04:40 -0700)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Thu, 25 Jun 2020 13:09:40 +0000 (06:09 -0700)
2020-06-25  Tobias Burnus  <tobias@codesourcery.com>
    Kwok Cheung Yeung  <kcy@codesourery.com>

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.

gcc/fortran/trans-openmp.c
gcc/testsuite/gfortran.dg/gomp/combined-if.f90
gcc/testsuite/gfortran.dg/gomp/pr95869.f90 [new file with mode: 0644]

index 67b709479ca9ae2221ba6058e6eee5e70d08256a..22f8f96a60e597a33627308dfcf448505719456b 100644 (file)
@@ -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,
index 383086ca97ba7303afb21997facd56482175b553..bf4a9a85d34dc98ac307c54f5af112de5e1eb4d9 100644 (file)
@@ -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 (file)
index 0000000..daa8d21
--- /dev/null
@@ -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