]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
openmp: Gimplify OMP_CLAUSE_SIZE during gfc_omp_finish_clause [PR100965]
authorJakub Jelinek <jakub@redhat.com>
Wed, 9 Jun 2021 13:56:32 +0000 (15:56 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Wed, 9 Jun 2021 13:57:15 +0000 (15:57 +0200)
As the testcase shows, we need to gimplify OMP_CLAUSE_SIZE, so that we
don't end up with SAVE_EXPR or anything similar non-gimple in it.

2021-06-08  Jakub Jelinek  <jakub@redhat.com>

PR fortran/100965
* trans-openmp.c (gfc_omp_finish_clause): Gimplify OMP_CLAUSE_SIZE.

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

(cherry picked from commit d4d38135b3137f1d3148138340e67bdcd7ea8216)

gcc/fortran/ChangeLog.omp
gcc/fortran/trans-openmp.c
gcc/testsuite/ChangeLog.omp
gcc/testsuite/gfortran.dg/gomp/pr100965.f90 [new file with mode: 0644]

index 83efe04eff61eab7081cff7b2bf759530ab2b5b7..95509a2e67111fb232f2b9cf3269704c841d3e5d 100644 (file)
@@ -1,3 +1,11 @@
+2021-06-09  Tobias Burnus  <tobias@codesourcery.com>
+
+       Backported from master:
+       2021-06-08  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/100965
+       * trans-openmp.c (gfc_omp_finish_clause): Gimplify OMP_CLAUSE_SIZE.
+
 2021-06-08  Tobias Burnus  <tobias@codesourcery.com>
 
        Backported from master:
index 9ea064abac0911b800397c6dd4ae617bd3ffca69..1e6e7f75fe90665c4d2d75b5df4e3c17509c798d 100644 (file)
@@ -1655,6 +1655,9 @@ gfc_omp_finish_clause (tree c, gimple_seq *pre_p, bool openacc)
     OMP_CLAUSE_SIZE (c)
       = DECL_P (decl) ? DECL_SIZE_UNIT (decl)
                      : TYPE_SIZE_UNIT (TREE_TYPE (decl));
+  if (gimplify_expr (&OMP_CLAUSE_SIZE (c), pre_p,
+                    NULL, is_gimple_val, fb_rvalue) == GS_ERROR)
+    OMP_CLAUSE_SIZE (c) = size_int (0);
   if (c2)
     {
       OMP_CLAUSE_CHAIN (c2) = OMP_CLAUSE_CHAIN (last);
index a0f0bcd94df4d1e220e28429f8cc4aadcf832f6a..93b3a7ad7660c3e06a85eaa64c69469f0a3bcec2 100644 (file)
@@ -1,3 +1,11 @@
+2021-06-09  Tobias Burnus  <tobias@codesourcery.com>
+
+       Backported from master:
+       2021-06-08  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/100965
+       * gfortran.dg/gomp/pr100965.f90: New test.
+
 2021-06-08  Tobias Burnus  <tobias@codesourcery.com>
 
        Backported from master:
diff --git a/gcc/testsuite/gfortran.dg/gomp/pr100965.f90 b/gcc/testsuite/gfortran.dg/gomp/pr100965.f90
new file mode 100644 (file)
index 0000000..9044547
--- /dev/null
@@ -0,0 +1,16 @@
+! PR fortran/100965
+! { dg-do compile }
+
+implicit none
+  character(len=:), allocatable :: s
+  logical :: l
+  !$omp target map(from: l)
+    l = allocated (s)
+  !$omp end target
+  if (l) stop 1
+
+  !$omp target map(from: l)
+    l = allocated (s)
+  !$omp end target
+  if (l) stop 2
+end