]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR fortran/88377 (ICE in gfc_omp_clause_copy_ctor, at fortran/trans...
authorJakub Jelinek <jakub@redhat.com>
Fri, 30 Aug 2019 11:18:41 +0000 (13:18 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 30 Aug 2019 11:18:41 +0000 (13:18 +0200)
Backported from mainline
2018-12-07  Jakub Jelinek  <jakub@redhat.com>

PR fortran/88377
* trans-openmp.c (gfc_omp_clause_default_ctor,
gfc_omp_clause_copy_ctor, gfc_omp_clause_assign_op,
gfc_omp_clause_linear_ctor, gfc_omp_clause_dtor): Only consider
GFC_DECL_GET_SCALAR_ALLOCATABLE vars as scalar allocatables if they
have pointer type.

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

From-SVN: r275076

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

index 073157d63193a090a2c7f3c71476f35249c7eef4..478a95c5900dfcf734103866edff9cd247317558 100644 (file)
@@ -1,6 +1,15 @@
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-12-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/88377
+       * trans-openmp.c (gfc_omp_clause_default_ctor,
+       gfc_omp_clause_copy_ctor, gfc_omp_clause_assign_op,
+       gfc_omp_clause_linear_ctor, gfc_omp_clause_dtor): Only consider
+       GFC_DECL_GET_SCALAR_ALLOCATABLE vars as scalar allocatables if they
+       have pointer type.
+
        2018-10-25  Jakub Jelinek  <jakub@redhat.com>
 
        PR fortran/87725
index e9a3b46e6e30ca66d80fb6c60a5441819a729f8e..7e24ec6706c554ba673bda3e2b0fe67612e98822 100644 (file)
@@ -460,7 +460,8 @@ gfc_omp_clause_default_ctor (tree clause, tree decl, tree outer)
 
   if ((! GFC_DESCRIPTOR_TYPE_P (type)
        || GFC_TYPE_ARRAY_AKIND (type) != GFC_ARRAY_ALLOCATABLE)
-      && !GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause)))
+      && (!GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause))
+         || !POINTER_TYPE_P (type)))
     {
       if (gfc_has_alloc_comps (type, OMP_CLAUSE_DECL (clause)))
        {
@@ -567,7 +568,8 @@ gfc_omp_clause_copy_ctor (tree clause, tree dest, tree src)
 
   if ((! GFC_DESCRIPTOR_TYPE_P (type)
        || GFC_TYPE_ARRAY_AKIND (type) != GFC_ARRAY_ALLOCATABLE)
-      && !GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause)))
+      && (!GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause))
+         || !POINTER_TYPE_P (type)))
     {
       if (gfc_has_alloc_comps (type, OMP_CLAUSE_DECL (clause)))
        {
@@ -667,7 +669,8 @@ gfc_omp_clause_assign_op (tree clause, tree dest, tree src)
 
   if ((! GFC_DESCRIPTOR_TYPE_P (type)
        || GFC_TYPE_ARRAY_AKIND (type) != GFC_ARRAY_ALLOCATABLE)
-      && !GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause)))
+      && (!GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause))
+         || !POINTER_TYPE_P (type)))
     {
       if (gfc_has_alloc_comps (type, OMP_CLAUSE_DECL (clause)))
        {
@@ -905,7 +908,8 @@ gfc_omp_clause_linear_ctor (tree clause, tree dest, tree src, tree add)
 
   if ((! GFC_DESCRIPTOR_TYPE_P (type)
        || GFC_TYPE_ARRAY_AKIND (type) != GFC_ARRAY_ALLOCATABLE)
-      && !GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause)))
+      && (!GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause))
+         || !POINTER_TYPE_P (type)))
     {
       gcc_assert (TREE_CODE (type) == ARRAY_TYPE);
       if (!TYPE_DOMAIN (type)
@@ -989,7 +993,8 @@ gfc_omp_clause_dtor (tree clause, tree decl)
 
   if ((! GFC_DESCRIPTOR_TYPE_P (type)
        || GFC_TYPE_ARRAY_AKIND (type) != GFC_ARRAY_ALLOCATABLE)
-      && !GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause)))
+      && (!GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause))
+         || !POINTER_TYPE_P (type)))
     {
       if (gfc_has_alloc_comps (type, OMP_CLAUSE_DECL (clause)))
        return gfc_walk_alloc_comps (decl, NULL_TREE,
index 56aa953bf14034092b4234a41d344abe4d05f6ff..4797f8c2aca34cbfdc3f41ed2b74496f5c434be8 100644 (file)
@@ -3,6 +3,9 @@
        Backported from mainline
        2018-12-07  Jakub Jelinek  <jakub@redhat.com>
 
+       PR fortran/88377
+       * gfortran.dg/gomp/pr88377.f90: New test.
+
        PR c++/87506
        * g++.dg/cpp0x/constexpr-87506.C: New test.
 
diff --git a/gcc/testsuite/gfortran.dg/gomp/pr88377.f90 b/gcc/testsuite/gfortran.dg/gomp/pr88377.f90
new file mode 100644 (file)
index 0000000..87b30b8
--- /dev/null
@@ -0,0 +1,15 @@
+! PR fortran/88377
+! { dg-do compile }
+
+program pr88377
+  call s(3)
+contains
+  subroutine s(n)
+    integer :: n
+    character(n), allocatable :: x
+    x = 'abc'
+    !$omp task
+    print *, x, (x == 'abc')
+    !$omp end task
+  end
+end