From cceb9c943bbb81ffb0004dc978d43f63a417ccb0 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 30 May 2017 09:29:49 +0200 Subject: [PATCH] backport: re PR fortran/77666 (ICE in gfc_omp_clause_default_ctor, at fortran/trans-openmp.c:471) Backported from mainline 2016-09-27 Jakub Jelinek PR fortran/77666 * trans-openmp.c (gfc_omp_private_outer_ref): Return true even for references to allocatable arrays. * gfortran.dg/gomp/pr77666.f90: New test. From-SVN: r248613 --- gcc/fortran/ChangeLog | 6 +++++ gcc/fortran/trans-openmp.c | 6 ++--- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/gomp/pr77666.f90 | 26 ++++++++++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/gomp/pr77666.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index c21acd8a345f..0a90013c167d 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,6 +1,12 @@ 2017-05-30 Jakub Jelinek Backported from mainline + 2016-09-27 Jakub Jelinek + + PR fortran/77666 + * trans-openmp.c (gfc_omp_private_outer_ref): Return true even for + references to allocatable arrays. + 2016-09-08 Jakub Jelinek PR fortran/77500 diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index e2182f62d262..906781d9b838 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -217,6 +217,9 @@ gfc_omp_private_outer_ref (tree decl) { tree type = TREE_TYPE (decl); + if (gfc_omp_privatize_by_reference (decl)) + type = TREE_TYPE (type); + if (GFC_DESCRIPTOR_TYPE_P (type) && GFC_TYPE_ARRAY_AKIND (type) == GFC_ARRAY_ALLOCATABLE) return true; @@ -224,9 +227,6 @@ gfc_omp_private_outer_ref (tree decl) if (GFC_DECL_GET_SCALAR_ALLOCATABLE (decl)) return true; - if (gfc_omp_privatize_by_reference (decl)) - type = TREE_TYPE (type); - if (gfc_has_alloc_comps (type, decl)) return true; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 01905bceff81..092fd3c709a3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,6 +1,11 @@ 2017-05-30 Jakub Jelinek Backported from mainline + 2016-09-27 Jakub Jelinek + + PR fortran/77666 + * gfortran.dg/gomp/pr77666.f90: New test. + 2016-09-22 Jakub Jelinek PR fortran/77665 diff --git a/gcc/testsuite/gfortran.dg/gomp/pr77666.f90 b/gcc/testsuite/gfortran.dg/gomp/pr77666.f90 new file mode 100644 index 000000000000..18e039efa522 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/pr77666.f90 @@ -0,0 +1,26 @@ +! PR fortran/77666 +! { dg-do compile } + +subroutine foo(x) + interface + subroutine baz(x, y) + integer, allocatable :: x(:), y + end subroutine + end interface + integer, allocatable :: x(:), y +!$omp parallel private(x, y) + call baz (x, y) +!$omp end parallel +end +subroutine bar + interface + subroutine baz(x, y) + integer, allocatable :: x(:), y + end subroutine + end interface + integer, allocatable :: x(:), y + call baz (x, y) +!$omp parallel private(x, y) + call baz (x, y) +!$omp end parallel +end -- 2.47.2