From 627d59b6b3062de921fbdd80b2b48de18f599d03 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Tue, 28 Jan 2020 11:54:57 +0100 Subject: [PATCH] [Fortran] avoid ICE in gfc_omp_check_optional_argument (PR93464) PR fortran/93464 * openmp.c (gfc_omp_check_optional_argument): Avoid ICE when DECL_LANG_SPECIFIC and GFC_DESCRIPTOR_TYPE_P but not GFC_DECL_SAVED_DESCRIPTOR as for local allocatable character vars. PR fortran/93464 * gfortran.dg/goacc/pr93464.f90: New. --- gcc/fortran/ChangeLog | 7 +++++++ gcc/fortran/trans-openmp.c | 3 ++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/goacc/pr93464.f90 | 16 ++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gfortran.dg/goacc/pr93464.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 4040ff284b3..eb8842b0ab8 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,10 @@ +2020-01-28 Tobias Burnus + + PR fortran/93464 + * openmp.c (gfc_omp_check_optional_argument): Avoid ICE when + DECL_LANG_SPECIFIC and GFC_DESCRIPTOR_TYPE_P but not + GFC_DECL_SAVED_DESCRIPTOR as for local allocatable character vars. + 2020-01-28 Tobias Burnus * gfortran.texi (Runtime): Remove tailing '.' in @menu. diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index fd60bbbed5d..66669550499 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -101,7 +101,8 @@ gfc_omp_check_optional_argument (tree decl, bool for_present_check) decl = GFC_DECL_SAVED_DESCRIPTOR (decl); } - if (TREE_CODE (decl) != PARM_DECL + if (decl == NULL_TREE + || TREE_CODE (decl) != PARM_DECL || !DECL_LANG_SPECIFIC (decl) || !GFC_DECL_OPTIONAL_ARGUMENT (decl)) return NULL_TREE; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index eac18206b12..d9441cb0a2e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-01-28 Tobias Burnus + + PR fortran/93464 + * gfortran.dg/goacc/pr93464.f90: New. + 2020-01-28 Richard Sandiford PR tree-optimization/93434 diff --git a/gcc/testsuite/gfortran.dg/goacc/pr93464.f90 b/gcc/testsuite/gfortran.dg/goacc/pr93464.f90 new file mode 100644 index 00000000000..922106540f9 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/goacc/pr93464.f90 @@ -0,0 +1,16 @@ +! { dg-do compile } +! +! PR fortran/93464 +! +! Contributed by G. Steinmetz +! +program p + character :: c(2) = 'a' + character, allocatable :: z(:) + !$acc parallel + !$omp target + z = c + !$acc end parallel + !$omp end target + print *, z +end -- 2.30.2