From d4722625ae34641556c1b3ea281ea4cbb0293426 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 7 Dec 2018 00:29:04 +0100 Subject: [PATCH] re PR fortran/88377 (ICE in gfc_omp_clause_copy_ctor, at fortran/trans-openmp.c:614) 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: r266879 --- gcc/fortran/ChangeLog | 9 +++++++++ gcc/fortran/trans-openmp.c | 15 ++++++++++----- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/gfortran.dg/gomp/pr88377.f90 | 15 +++++++++++++++ 4 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/gomp/pr88377.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b9fcfd617ae..9e17decbe18 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,12 @@ +2018-12-07 Jakub Jelinek + + 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-12-03 Fritz Reese Mark Eggleston diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index 483ca663663..c9fc4e49c45 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -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, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e4afdc79fdc..92bafd35d43 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2018-12-07 Jakub Jelinek + PR fortran/88377 + * gfortran.dg/gomp/pr88377.f90: New test. + PR c/88367 * gcc.dg/tree-ssa/pr88367.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 index 00000000000..87b30b8ef23 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/pr88377.f90 @@ -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 -- 2.30.2