]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
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>
Fri, 26 Jun 2020 21:17:37 +0000 (14:17 -0700)
This is a backport from master
(commit f530bac8a11da9c85bdd8e58d589747f9825e38d).

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/ChangeLog.omp
gcc/fortran/trans-openmp.c
gcc/testsuite/ChangeLog.omp
gcc/testsuite/gfortran.dg/gomp/combined-if.f90
gcc/testsuite/gfortran.dg/gomp/pr95869.f90 [new file with mode: 0644]

index ea2fc1f423208fd982bd8d04390e69112e953d40..0118cdfc8ca872107e5b7e959266c28dd3b4d75a 100644 (file)
@@ -1,3 +1,10 @@
+2020-06-25  Tobias Burnus  <tobias@codesourcery.com>
+           Kwok Cheung Yeung  <kcy@codesourery.com>
+
+       PR fortran/95869
+
+       * trans-openmp.c (gfc_trans_omp_target): Use correct scoping block.
+
 2020-06-25  Kwok Cheung Yeung  <kcy@codesourcery.com>
 
        * trans-openmp.c (gfc_split_omp_clauses): Add if clause
index 4a65c7fd5be4f626cd356d338c7d4e30111f1d5a..6276752dc1abe3a67090e3fb6e27b0cfe0f1c701 100644 (file)
@@ -5374,7 +5374,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 0c46408323edacf8ac3105b75e3e9d07278bac53..0a8afc8644eca5ab4a3d2383cc71b905f179fa2c 100644 (file)
@@ -1,3 +1,11 @@
+2020-06-25  Tobias Burnus  <tobias@codesourcery.com>
+           Kwok Cheung Yeung  <kcy@codesourery.com>
+
+       PR fortran/95869
+
+       * gfortran.dg/gomp/combined-if.f90 (test_target_parallel): Re-enable.
+       * gfortran.dg/gomp/pr95869.f90: New.
+
 2020-06-25  Kwok Cheung Yeung  <kcy@codesourcery.com>
 
        * gfortran.dg/gomp/combined-if.f90: New.
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